A implementation of Chiru Labs' ERC721A written in Cairo for StarkNet, a decentralized ZK Rollup.
This repository contains highly experimental code. Expect rapid iteration. Use at your own risk.
The following steps are tested by me in both Windows/WSL (Intel x64 CPU) and Ubuntu (ARMv8 CPU) environments.
I am not sure these steps should work in the Apple M1 computer.
- Clone the repo and enter the directory.
- Create a python virtual environment
python3 -m venv env
source env/bin/activate
- Install
libgmp3-dev
or follow the instructions at StarkNet webpage (Setting up the environment).
sudo apt install -y libgmp3-dev
- Install Cairo language SDK or
pip3 install cairo-lang
- Install OpenZeppelin Nile and Cairo library
pip3 install cairo-nile
pip3 install openzeppelin-cairo-contracts
- At this time, you will at least have successfully installed 3 packages.
(env) ERC721A-cairo$ pip3 list
Package Version
---------------------------- ---------
cairo-lang x.x.x
cairo-nile x.x.x
openzeppelin-cairo-contracts x.x.x
- Cairo: https://www.cairo-lang.org/docs/
- OpenZeppelin Nile: https://github.com/OpenZeppelin/nile
- Cairo library
- Create a
.env
file with the following content under the root directory./
.
PriKey=<random_number>
- Deploy an StarkNet account contract associated with a given private key.
nile setup --network <network_name> <private_key_alias>
- Nile will look for an environment variable with the name of <private_key_alias> in the file
.env
. Therefore, it would be something likenile setup PriKey
. <network_name>
could begoerli
ormainnet
.
nile compile <path_to_contract>
- If the
<path_to_contract>
is an empty string, Nile will automatically compile all contracts under the directory./contracts
.
nile deploy --network <network_name> <cairo_file_name>
<network_name>
could begoerli
ormainnet
<cairo_file_name>
should be the name of*.cairo
contract file which is placed under the directory./contracts
.
starknet call \
--address <contract_address> \
--abi <contract_ABI_json> \
--function <function_name> \
--network <network_name>
<network_name>
could bealpha-goerli
oralpha-mainnet
Chiru Labs' ERC721A-v3.1.0 solidity contracts inspire me for developing most of the contract execution logic.