3 min read - Posted 11 Mar 19

OpenZeppelin Part 1: Introductory

Introductory To OpenZeppelin

What Is OpenZeppelin?

OpenZeppelin is a library of reusable smart contracts to use with Ethereum and other EVM and eWASM blockchains. The contracts focus on secure and simple open source code. They are continuously tested and community reviewed to ensure they follow the best industry standards and security practices. As a developer it's difficult to create any piece of code from scratch; especially a contract. Through the use of OpenZeppelin's inheritable contracts, you have a base to start from and build complex features with little to, or no effort.

OpenZeppelin vs ZeppelinOS

Zeppelin solutions provides two different frameworks that are often confused to be the same thing. OpenZeppelin is a series of open source contracts to inherit into your code. In contrast, ZeppelinOS is a platform of utilities to securely manage your smart contracts. Ideally you use them together. In this tutorial series, we focus on OpenZeppelin.

Types of Contracts

OpenZeppelin has a variety of contracts to meet your needs divided into the following categories:

  1. Access: Roles and privileges.
  2. Crowdsale: Creating a smart contract for use in a crowdsale.
  3. Cryptography: Protecting your information.
  4. Drafts: Contracts that are currently in testing by the OpenZeppelin team.
  5. Introspection: Interface support.
  6. Lifecycle: Managing the behaviour of your contract.
  7. Math: Perform operations without overflow errors.
  8. Ownership: Manage ownership throughout your contract.
  9. Payment: How your contract releases tokens.
  10. Tokens: Creating tokens and protecting them.
  11. Utilities: Other contracts to assist you.

You inherit or combine OpenZeppelin contracts with your own contracts, serving as a base for you to build from. Later in the series, we will explore the uses of each of these contracts.

How To Download

To begin, you need to have Node.js and Truffle installed on your machine. To work with OpenZeppelin you should be familiar with Solidity, the programming language for smart contracts. The "Remix IDE - Your first smart contract" article is a good place to start.

In a directory of your choice make a new project folder and initialize Truffle in it.

mkdir myproject
cd myproject
truffle init

Now install the OpenZeppelin library into your projects root directory. Use the --save-exact option to ensure that all dependencies configure with an exact version, since breaking changes (change in software that can potentially make other components fail) might occur when versions are updated.

npm init -y
npm install --save-exact openzeppelin-solidity

OpenZeppelin is now installed. The library of contracts are stored in the nodemodules/openzeppelin-solidity/contracts_ folder path within your project.

To use the library, add an import statement at the beginning of the contract specifying which one you want to use.

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";


OpenZeppelin allows you to write more complex and secure contracts using their variety of base contracts. Less time spent building the foundation and more time to optimize details.

Documentation and Next Steps:

Created with Sketch.Content is"CC-BY-SA 4.0" licensed
Article On-chain
Article Author

Juliette Rocco

Intern @Kauri




Related Articles
OpenZeppelin Part 2: Access Control

Access Control What is It? The first category of contracts is access control. Access control allows a developer to regulate who can use certain features of the contract. Examples are: minting tokens, voting on proposals, ownership, etc. This feature is useful for creating a restrictive contract. How to Use OpenZeppelin provides two contracts: Ownable.sol and Roles.sol for access control. Both methods are useful in different scenarios depending on how restrictive you want the contract to be. Owne

OpenZeppelin Part 4: Crowdsales

Crowdsales What is a Crowdsale? In Blockchain, crowdsales are fundraisers to assist in the development of a project. Backers use the tokens sold during the crowdsale to participate in the project once its launched. The tokens are usable only within this project. OpenZeppelin & Crowdsales OpenZeppelin created four categories of contracts to assist in the creation of a crowdsale contract based on the most important properties of a crowdsale. Price & Rate Configuration Before creating a crowdsale i