Disclaimer: this project is deprecated and no longer maintained. Check out scarb instead.
Nile is a CLI tool to develop or interact with StarkNet projects written in Cairo. This is an ongoing effort to migrate the existing tool written in Python to Rust, for compatibility with the new Cairo1 compiler.
For the current status of the features migration from Python check this page.
Nile-rs is a rust binary application, and while we plan to improve the distribution mechanism, for the sake of simplicity, currently you need to manually build the package using cargo. Follow this guide to install rust on your machine if you haven't.
-
Clone the repository and build the binary file from the main branch.
cargo build --release
-
Copy the executable into a directory under your system PATH.
cp target/release/nile-rs /replace/with/dir/under/path
-
Open a terminal and run the help command to check the installation.
nile-rs --help
-
Change dir into an empty directory.
mkdir nile_project && cd nile_project
-
Quickly setup a new project using
init
.nile-rs init
🗄 Creating project directory tree ⛵️ Nile project ready! Try running: `nile-rs compile`
-
Update the project name in
./Scarb.toml
fromnile_project
totest
in line 2. -
Compile the HelloStarknet contract (cairo 1 version) under
src
, with thecompile
command (using scarb under the hood).nile-rs compile
Compiling test v0.1.0 (./Scarb.toml) Finished release target(s) in 0 seconds
-
Run a valid devnet node to test the interaction.
Currently, you need to use the version v0.5.0a1 starknet-devnet (a pre-release), passing the right compiler on initialization (v1.0.0-alpha.6). This will change very soon, so keep in mind you may need to tweak the setup a bit.
pip install starknet-devnet==v0.5.0a1
starknet-devnet --cairo-compiler-manifest /PATH/TO/COMPILER/CARGO/TOML/FILE
-
Declare the contract.
If this command fails with an unexpected error, you are probably using the wrong version of starknet-devnet and/or the compiler. We will work on improving the error feedback in the future.
nile-rs declare test_HelloStarknet -d 0
⏳ Declaration successfully sent! Transaction hash: 0x... Class hash: 0x...
Notice the
-d 0
argument, this makes nile use the first predeployed account from the devnet node. -
Check the status of the transaction with the
status
command. We could have used the--track
flag when declaring for waiting for the transaction to be confirmed.nile-rs status [tx_hash]
Querying the status... ✅ Transaction status: AcceptedOnL2
-
Deploy the contract.
nile-rs deploy test_HelloStarknet -d 0 -t
⏳ Deployment successfully sent! Transaction hash: 0x... Contract address: 0x... Querying the status... ✅ Transaction status: AcceptedOnL2
Notice the
-t
flag for tracking the status. -
Query the contract to get current the balance.
nile-rs raw-call [contract_address] get_balance
CallContractResult { result: [ FieldElement { inner: 0x0000000000000000000000000000000000000000000000000000000000000000, }, ], }
We will improve the output of the raw-call (and change the command to call), after implementing a deserializer from ABI types.
-
Send a transaction to increase the balance.
nile-rs send --address [contract_address] increase_balance 5 -d 0 -t
⏳ Transaction successfully sent! Transaction hash: 0x... Querying the status... ✅ Transaction status: AcceptedOnL2
-
Check the balance again.
nile-rs raw-call [contract_address] get_balance
CallContractResult { result: [ FieldElement { inner: 0x0000000000000000000000000000000000000000000000000000000000000005, }, ], }
Nile is released under the MIT License.