Skip to content

Announcing OpenZeppelin Contracts for Cairo

cairo-1

OpenZeppelin Contracts, the standard for smart contract development in Solidity, is now expanding to the Cairo language. With the new OpenZeppelin Contracts for Cairo version 0.1.0, developers can leverage standard smart contracts written in Cairo to build their own applications on top of StarkNet, a Zero Knowledge Rollup.

What are OpenZeppelin Contracts?

OpenZeppelin Contracts have been a pillar of Solidity smart contract development since their initial release in 2016. This library of community-vetted and battle-tested open-source software is used by the top projects in the Web3 space and has been downloaded millions of times. Building on this success, OpenZeppelin is now branching out to include support for the Cairo language developed for StarkNet

It is important to note that, although the new library is heavily inspired by its Solidity counterpart, this initial release does not aim for feature parity. OpenZeppelin will take developer requests and ecosystem requirements into account as it continues to develop OpenZeppelin Contracts for Cairo.

Why Cairo?

It is no secret that Ethereum’s future is rollup-centric as rollups provide secure infrastructure on top of Layer 1 while reducing fees across the board. Although OpenZeppelin Contracts for Solidity already work on any EVM-compatible rollup (e.g., Optimism or Arbitrum), some other networks, like StarkNet, require different languages to match their computing models. This is why we are building a library of OpenZeppelin Contracts for Cairo.

Cairo is a language for writing programs whose execution can be proved, which is ideal in the context of a Zero Knowledge or Validity Rollup, where computation is offloaded from one layer (L1, Ethereum) to another (L2, StarkNet in this case). In short, the Layer 2 network executes all the transactions and periodically sends state transitions along with proofs of valid execution supporting each state transition to Layer 1. In this way, execution happens entirely on L2 while L1 is used to secure the data and validate that L2 is working correctly.

What’s in the library?

To support the quickly growing StarkNet ecosystem, the library comes with some basic contracts such as the account abstraction, which implements the standard interface we developed in collaboration with Argent.

Other contracts include the ERC20 and ERC721 token standards for fungible and non-fungible tokens, respectively, as well as basic security modules such as Ownable, Pausable, SafeMath, and other utilities. This version of the library also includes a Proxy contract and a module to easily implement an upgradeability mechanism.

Following our Extensibility Pattern, the package comes with both “library” and “preset” modules. You can learn more about this in the extensibility documentation. In short, the library’s modules provide building blocks—such as functions and storage variables—to streamline contract development, while the presets are ready-to-use contracts which also serve as examples of how to use the libraries.

Featured presets include the Account and Proxy contracts, ERC20 implementations (Basic, Mintable, Pausable, and Upgradeable), and ERC721 implementations (Mintable Burnable, Mintable Pausable, and Enumerable Mintable Burnable).

To get started with OpenZeppelin Contracts for Cairo, check out the tutorial  and the documentation.

A Disclaimer and the Future

Although the repository has been public since day one, until now there was no official release of the library due to its highly experimental nature. Note that this release does not change that: these contracts and the Cairo language itself are still under development, and therefore stability is not guaranteed. Moreover, these contracts are not audited. For these reasons, use them at your own risk.

Based on ecosystem growth and user demand, future work may include more tokens (e.g., ERC1155 or additional ERC20/ERC721 presets), a more granular access control module, security modules such as a timelock or reentrancy guard, governance modules, and/or bridges. Tell us what you need!

Check out our repository to follow the development of the library, leave feedback, report issues, or—even better—open a pull request and become a contributor!