OpenZeppelin Cairo Contracts
A library for secure smart contract development written in Cairo for StarkNet, a decentralized ZK Rollup.
⚠️ WARNING! ⚠️
This is repo contains highly experimental code. Expect rapid iteration. Do not use in production.
Installation
First time?
Before installing Cairo on your machine, you need to install gmp:
sudo apt install -y libgmp3-dev # linux
brew install gmp # mac
If you have any troubles installing gmp on your Apple M1 computer, here’s a list of potential solutions.
Set up the project
Clone the repository
git clone git@github.com:OpenZeppelin/cairo-contracts.git
cd into it and create a Python virtual environment:
cd cairo-contracts
python3 -m venv env
source env/bin/activate
Install the Nile dev environment and then run install to get the Cairo language, a local network, and a testing framework.
pip install cairo-nile
nile install
Usage
Compile the contracts
nile compile --directory openzeppelin
🤖 Compiling all Cairo contracts in the openzeppelin directory
🔨 Compiling openzeppelin/introspection/ERC165.cairo
🔨 Compiling openzeppelin/introspection/IERC165.cairo
🔨 Compiling openzeppelin/token/erc721/ERC721_Mintable_Burnable.cairo
🔨 Compiling openzeppelin/token/erc721/ERC721_Mintable_Pausable.cairo
🔨 Compiling openzeppelin/token/erc721/library.cairo
🔨 Compiling openzeppelin/token/erc721/interfaces/IERC721_Metadata.cairo
🔨 Compiling openzeppelin/token/erc721/interfaces/IERC721.cairo
🔨 Compiling openzeppelin/token/erc721/interfaces/IERC721_Receiver.cairo
🔨 Compiling openzeppelin/token/erc721/utils/ERC721_Holder.cairo
🔨 Compiling openzeppelin/token/erc20/ERC20_Mintable.cairo
🔨 Compiling openzeppelin/token/erc20/ERC20.cairo
🔨 Compiling openzeppelin/token/erc20/library.cairo
🔨 Compiling openzeppelin/token/erc20/ERC20_Pausable.cairo
🔨 Compiling openzeppelin/token/erc20/interfaces/IERC20.cairo
🔨 Compiling openzeppelin/token/erc721_enumerable/ERC721_Enumerable_Mintable_Burnable.cairo
🔨 Compiling openzeppelin/token/erc721_enumerable/library.cairo
🔨 Compiling openzeppelin/token/erc721_enumerable/interfaces/IERC721_Enumerable.cairo
🔨 Compiling openzeppelin/security/pausable.cairo
🔨 Compiling openzeppelin/security/safemath.cairo
🔨 Compiling openzeppelin/security/initializable.cairo
🔨 Compiling openzeppelin/access/ownable.cairo
🔨 Compiling openzeppelin/account/IAccount.cairo
🔨 Compiling openzeppelin/account/Account.cairo
🔨 Compiling openzeppelin/account/AddressRegistry.cairo
🔨 Compiling openzeppelin/utils/constants.cairo
✅ Done
Run tests
Run tests using tox, tox automatically creates an isolated testing environment:
tox
====================== test session starts ======================
platform linux -- Python 3.7.2, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/readme/cairo-contracts
plugins: asyncio-0.16.0, web3-5.24.0, typeguard-2.13.0
collected 19 items
tests/test_Account.py .... [ 21%]
tests/test_AddressRegistry.py .. [ 31%]
tests/test_ERC20.py .......... [ 84%]
tests/test_Initializable.py . [ 89%]
tests/test_Ownable.py .. [100%]
Learn
Contract documentation
Cairo
- StarkNet official documentation
- Cairo language documentation
- Perama's Cairo by example
- Cairo 101 workshops
Nile
Security
This project is still in a very early and experimental phase. It has never been audited nor thoroughly reviewed for security vulnerabilities. Do not use in production.
Please report any security issues you find to security@openzeppelin.org.
License
OpenZeppelin Cairo Contracts is released under the MIT License.
Metadata
Release files for openzeppelin-cairo-contracts-test 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openzeppelin-cairo-contracts-test-0.1.0.tar.gz | 57.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openzeppelin_cairo_contracts_test-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 89.9 kB
Release files / openzeppelin-cairo-contracts-test-0.1.0.tar.gz
| Download URL | openzeppelin-cairo-contracts-test-0.1.0.tar.gz |
|---|---|
| Size | 57.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f60335be4aa6f09eec3c24b201f996bed1f50ab067f421aa4c516b607c058790
|
|
BLAKE2b-256 checksum How to use checksums |
a2a2fa4fd7eabc779ad2a2137587eb8dcfd05ef3ad9ba0bdbb2b2e945a1af837
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
|
Release files / openzeppelin_cairo_contracts_test-0.1.0-py3-none-any.whl
| Download URL | openzeppelin_cairo_contracts_test-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8af7d629652efb50ef7381950c37b1cad73eec95a2041c305b320cf19b3d114e
|
|
BLAKE2b-256 checksum How to use checksums |
964bd94fbb78e099105c6fba43d61847e9ede9f550864370312221bcb745e40c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
|