starknet-contract-verifier
is a contract class verification cli that allows you to verify your starknet classes on a block explorer.
- Cairo 1.1.0 & Scarb v0.4.0
- Cairo 1.1.1 & Scarb v0.4.1
- Cairo 2.0.1 & Scarb v0.5.1
- Cairo 2.0.2 & Scarb v0.5.2
- Cairo 2.1.0 & Scarb v0.6.1
- Cairo 2.1.1 & Scarb v0.6.2
- Cairo 2.2.0 & Scarb v0.7.0
- Cairo & Scarb 2.3.0
- Cairo & Scarb 2.3.1
- Cairo & Scarb 2.4.0
- Cairo & Scarb 2.4.1
- Cairo & Scarb 2.4.2
- Cairo & Scarb 2.4.3
- Cairo & Scarb 2.4.4
- Cairo & Scarb 2.5.0
- Cairo & Scarb 2.5.1
- Cairo & Scarb 2.5.2
- Cairo & Scarb 2.5.3
- Cairo & Scarb 2.5.4
- Cairo & Scarb 2.6.0
- Cairo & Scarb 2.6.1
- Cairo & Scarb 2.6.2
- Cairo & Scarb 2.6.3
- Cairo 2.6.3 & Scarb 2.6.4
- Cairo 2.6.4 & Scarb 2.6.5
- Cairo 2.7.0 & Scarb 2.7.0
- Cairo 2.7.1 & Scarb 2.7.1
- Cairo 2.8.0 & Scarb 2.8.0
- Cairo 2.8.0 & Scarb 2.8.1
- Cairo 2.8.2 & Scarb 2.8.2
- Cairo 2.8.2 & Scarb 2.8.3
- Cairo 2.8.4 & Scarb 2.8.4
The source code release for each version is available at their respective branch at release/2.<major_version>.<minor_version>
. For example, the release for 2.4.3
would live at release/2.4.3
.
This CLI relies upon Scarb for dependencies resolving during compilation and thus require you to have Scarb installed for it to work properly. You can install Scarb following the instruction on their documentation at https://docs.swmansion.com/scarb.
Note that CLI version that you install should follow the version of the Scarb you have installed for it to work as expected.
In order to start verification, you'll need to add a table in your Scarb.toml
as such:
[package]
name = "my_project"
version = "0.1.0"
[dependencies]
starknet = ">=2.4.0"
[[target.starknet-contract]]
sierra = true
# Add the following section
[tool.voyager]
my_contract = { path = "main.cairo" }
The path should be set to the path of whichever contract you would like to verify, relative to your src
directory. For the example above, the cairo contract is located at src/main.cairo
and as such the path should be set to main.cairo
.
Note that only one contract should be provided in this section as multi contract verification is not supported yet.
First do a clone of this repository.
git clone git@github.com:NethermindEth/starknet-contract-verifier.git
After cloning the repository, checkout to the release branch corresponding to the cairo version that your contract uses. For example, if you write your contract in cairo 2.5.4
, you would do the following:
cd starknet-contract-verifier
git checkout release/2.5.4
To start the verifier, you can do the following command, and a prompt should guide you through the verification process.
cargo run --bin starknet-contract-verifier
If you are using asdf
for the management of scarb binary on a project basis, you should make sure that the verifier runs in the directory of the project so that the verifier will detect and use the correct scarb
binary for that project.
You can build the binaries and add it to path to make it easier to use the verifier.
# build all binaries
cargo build --all --release
# then add build target directory to path
# depending on your shell this might be different.
# Add the following to the end of your shell configuration file
export PATH="$PATH:/path/to/starknet-contract-verifier/target/release"
# you should now be able to call the verifier directly if build succeeds.
starknet-contract-verifier
You should be greeted with prompts that asks for the details of your cairo project & contracts, and will be guided step by step through the verification process.
If you are developing and building the project from source, you will first need to install rust.
curl https://sh.rustup.rs -sSf | sh -s
Note: Builds for 2.4.3 and below only works with < Rust 1.77. As such please make sure that you have the correct rust version before building.
To build the project, simply do
cargo build
and the project should start building.
There's a few known issue with the current implementation of this verifier.
It's possible that your modules get re-arranged after verification as the verifier tries to resolve your dependencies from the main contract and re-generate them into a new project. This is known and we are working towards making the generated project look as closely as possible with the original module structure.
The verifier would usually work cairo compiler versions that are lower than its version given no breaking changes between compiler versions, meaning using a 2.4.3
verifier with a compiler version of less than 2.4.3 would work as long as you specify in your Scarb.toml
file the starknet version with a range including the verifier version (for example, >=2.4.0
& 2.2.0
usually works for verifier 2.4.3
) If you use strict versioning for your starknet version in form of =2.4.3
for example, it would stop working with verifier of other versions.
We welcome any form of contribution to this project!
To start, you can take a look at the issues that's available for taking and work on whichever you might be interested in. Do leave a comment so we can assign the issue to you!