StarkNet/Cairo development toolbelt
Project description
OpenZeppelin Nile ⛵
Navigate your StarkNet projects written in Cairo.
Getting started
Create a folder for your project and cd into it:
mkdir myproject
cd myproject
Create a virtualenv and activate it:
python3 -m venv env
source env/bin/activate
Install nile:
pip install cairo-nile
Use nile to quickly set up your development environment:
nile init
...
✨ Cairo successfully installed!
...
✅ Dependencies successfully installed
🗄 Creating project directory tree
⛵️ Nile project ready! Try running:
This command creates the project directory structure and installs cairo-lang, starknet-devnet, pytest, and pytest-asyncio for you. The template includes a makefile to build the project (make build) and run tests (make test).
Usage
node
Run a local starknet-devnet node:
nile node
* Serving Flask app 'starknet_devnet.server' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://localhost:5000/ (Press CTRL+C to quit)
compile
Compile Cairo contracts. Compilation articacts are written into the artifacts/ directory.
nile compile # compiles all contracts under contracts/
nile compile contracts/MyContract.cairo # compiles single contract
Example output:
$ nile compile
Creating artifacts/abis/ to store compilation artifacts
🤖 Compiling all Cairo contracts in the contracts/ directory
🔨 Compiling contracts/Account.cairo
🔨 Compiling contracts/Initializable.cairo
🔨 Compiling contracts/Ownable.cairo
✅ Done
deploy
nile deploy contract --alias my_contract
🚀 Deploying contract
🌕 artifacts/contract.json successfully deployed to 0x07ec10eb0758f7b1bc5aed0d5b4d30db0ab3c087eba85d60858be46c1a5e4680
📦 Registering deployment as my_contract in localhost.deployments.txt
A few things to notice here:
nile deploy <contract_name>looks for an artifact with the same name- This created a
localhost.deployments.txtfile storing all data related to my deployment - The
--aliasparameter lets me create an unique identifier for future interactions, if no alias is set then the contract's address can be used as identifier - By default Nile works on local, but you can pass
--network mainnetto deploy directly to a public chain! Notice thatmainnetrefers to StarkNet main chain, that's settled on Goerli testnet of Ethereum (mainnet deployment this month!)
call and invoke
Using call and invoke, we can perform read and write operations against our local node (or public one using the --network mainnet parameter). The syntax is:
nile <command> <contract_identifier> <contract_method> [PARAM_1, PARAM2...]
Where <command> is either call or invoke and <contract_identifier> is either our contract address or alias, as defined on deploy.
nile invoke my_contract increase_balance 1
Invoke transaction was sent.
Contract address: 0x07ec10eb0758f7b1bc5aed0d5b4d30db0ab3c087eba85d60858be46c1a5e4680
Transaction hash: 0x1
nile call my_contract get_balance
1
clean
Deletes the artifacts/ directory for a fresh start ❄️
nile clean
🚮 Deleting localhost.deployments.txt
🚮 Deleting artifacts directory
✨ Workspace clean, keep going!
install
Install the latest version of the Cairo language and the starknet-devnet local node.
nile install
version
Print out the Nile version
nile version
Hacking on Nile
Nile uses tox to manage development tasks, you can get a list of
available task with tox -av.
- Install a development version of the package with
python -m pip install . - Run tests with
tox - Build the package with
tox -e build - Format all files with
tox -e format - Check files formatting with
tox -e lint
License
Nile is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cairo-nile-0.2.1.tar.gz.
File metadata
- Download URL: cairo-nile-0.2.1.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c1a6008794cab9b980c3553d7e690883d4ea5f271544a4b89766a4eb092475a
|
|
| MD5 |
ab0315de80b1afbf1a42a75f5b23a3b7
|
|
| BLAKE2b-256 |
1fdeb8c4ab3b121b3ddec50518103c1d576668efded34c9e638fd280ec314487
|
File details
Details for the file cairo_nile-0.2.1-py3-none-any.whl.
File metadata
- Download URL: cairo_nile-0.2.1-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f075c25f32a91a056fbef2e7ffb7bdeb8d7289523d02cf9208d5b1b37a38d73a
|
|
| MD5 |
13bbb901c53353d1183d6ce51a56d597
|
|
| BLAKE2b-256 |
dc189daf3af0014669e11ddb224e391752b6622d9527bf4c3a5b5e6b6f99ee01
|