OpenZeppelin Contracts for Cairo

repository·main·Indexed 21 days ago

https://github.com/openzeppelin/cairo-contracts

A library of secure, audited smart contract components written in Cairo for the Starknet ecosystem. It provides standardized building blocks including access control (Ownable, AccessControl), account contracts (STARK and Secp256k1 curves), governance primitives, financial tools like VestingComponent, and token standards (ERC20, ERC721, ERC1155, ERC4626). The library also includes a macros package (openzeppelin_macros 4.0.0-alpha.1), Merkle Tree proof verification, and ready-to-deploy upgradeable contract presets.

Tokens
39.4K
Snippets
115
Records
195
Agent score
74%

What's inside openzeppelin-cairo-contracts

  1. Overview of OpenZeppelin Utils

    main
    The utils crate provides a collection of miscellaneous components and libraries designed to support common tasks in Cairo smart contract development. It is organized into several functional modules including core utilities (math, execution, deployments, etc.) and specialized cryptography components.
  2. Implement account contracts for network interaction

    main

    The account crate provides components to build account contracts capable of interacting with the network. It supports different cryptographic curves depending on the required validation logic:

    • Use standard Account components to validate transactions using signatures over the STARK Curve.
    • Use EthAccount components to validate transactions using signatures over the Secp256k1 curve (Ethereum compatibility).
  3. Standardized Interfaces and ABI Traits in OpenZeppelin Cairo

    main

    The interfaces package provides a comprehensive list of standardized interfaces, ABI traits, and dispatchers used across the OpenZeppelin Cairo contracts ecosystem. These interfaces ensure interoperability between different contracts (e.g., ERC20, ERC721, Governance) and provide a consistent way to interact with contract functionality via ABI traits.

    Standardized Interfaces

    These interfaces define the expected behavior for various contract types, including access control, tokens, and governance. Common categories include:

    • Access Control: IAccessControl, IOwnable, IOwnableTwoStep.
    • Tokens: IERC20, IERC721, IERC1155, IERC4626 (Vaults), IERC2981 (Royalties).
    • Governance: IGovernor, IMultisig, ITimelock, IVotes.
    • Upgrades: IUpgradeable, IUpgradeAndCall.

    ABI Traits

    ABI traits are used to facilitate cross-contract calls and interaction with the contract's application binary interface. Available traits include:

    • AccessControlABI
    • OwnableABI
    • ERC20ABI
    • ERC721ABI
    • ERC1155ABI
    • ERC4626ABI
    • UniversalDeployerABI (and others listed in the package).
  4. Security components in OpenZeppelin Cairo Contracts

    main
    The security crate provides modular components designed to handle common security-related tasks in Cairo contracts. These components can be integrated into your contracts to implement standard security patterns like initialization control, pausing functionality, and reentrancy protection.
  5. Implement ERC1155 (Multi-Token) tokens

    main

    The token crate provides components for the ERC1155 standard:

    Interfaces

    • IERC1155: The core ERC1155 interface.
    • IERC1155MetadataURI: Interface for token metadata URI.
    • IERC1155Receiver: Interface for contracts that can receive ERC1155 tokens.

    Components

    • ERC1155Component: The base component for ERC1155 functionality.
    • ERC1155ReceiverComponent: Provides implementation for IERC1155Receiver.

    For detailed API references, visit the ERC1155 documentation.

  6. Review security audits for OpenZeppelin Cairo Contracts

    main
    Security audits for the OpenZeppelin Cairo Contracts library are conducted by Zellic. You can review the audit reports for specific versions to understand the security posture of the contracts you are using. Each audit covers a specific scope (e.g., specific packages or version changes) and is tied to a specific git commit.
  7. Use OpenZeppelin macros to streamline Cairo development

    main
    The openzeppelin_macros crate provides a collection of macros designed to simplify and automate common development tasks when using the OpenZeppelin Cairo library. These macros are implemented as attribute macros that can be applied to your Cairo code to reduce boilerplate and ensure consistency with OpenZeppelin standards.