starknet-contract-verifier 0.1.0

Contract class verification tool that allows you to verify your starknet classes on a block explorer.
Documentation

starknet-contract-verifier

Client for the Voyager Starknet block explorer, that allows you to verify your starknet classes.

Installation

cargo install starknet-contract-verifier

Quickstart guide

Scarb

Contract verifier works with Scarb based projects. The tool assumes that scarb command is available in the environment and project is building properly by executing scarb build.

Supported versions

Client is version agnostic, the Scarb/Cairo versions support is determined by the server availability. As of writing this (2024) Cairo up to 2.11.4 is supported with newer versions being added with a slight lag after release.

Project configuration

You no longer need to add a tool.voyager table in your Scarb.toml. The contract verifier now automatically detects your contract files.

For license information, you can specify it in your Scarb.toml:

[package]
name = "my_project"
version = "0.1.0"
license = "MIT"  # Optional: Define license here using a valid SPDX identifier

[dependencies]
starknet = ">=2.11.2"

[[target.starknet-contract]]
sierra = true

Alternatively, you can provide the license via the --license CLI argument when verifying your contract.

Important: For workspace projects with multiple packages, you must use the --package argument to specify which package to verify.

Verify your contract

Once you have the verifier installed, execute:

starknet-contract-verifier --network sepolia verify \
    --class-hash <YOUR_CONTRACT_CLASS_HASH> \
    --contract-name <YOUR_CONTRACT_NAME> \
    --path <PATH_TO_YOUR_SCARB_PROJECT> \
    --license <SPDX_LICENSE_ID> # if not provided in Scarb.toml
    --execute

For workspace projects (multiple packages), you'll need to specify the package:

starknet-contract-verifier --network sepolia verify \
  --class-hash <YOUR_CONTRACT_CLASS_HASH> \
  --contract-name <YOUR_CONTRACT_NAME> \
  --package <PACKAGE_ID> \
  --path <PATH_TO_YOUR_SCARB_PROJECT> \
  --execute

When successful you'll be given verification job id, which you can pass to:

starknet-contract-verifier --network sepolia status --job <JOB_ID>

to check the verification status. Afterwards visit Voyager website and search for your class hash to see the verified badge.

Detailed information

Verification

starknet-contract-verifier provides two subcommands: verify and status. For both cases user needs to select the network with which they want to interact via the --network argument. Possible cases are:

Verification process

In order to verify a contract, you need to provide several arguments:

  • --class-hash, class hash of the declared contract
  • --contract-name, name of the contract to verify
  • --path, path to directory containing scarb project (If omitted it will use current working directory)
  • --execute, flag to actually execute the verification (without this flag, it will only show what would be done)
  • --license, SPDX license identifier (optional, will use license from Scarb.toml if defined there, otherwise defaults to "All Rights Reserved")
  • --watch, wait indefinitely for verification result (optional)
  • --package, specify which package to verify (required for workspace projects with multiple packages)

There are more options, each of them is documented in the --help output.

If the verification submission is successful, client will output the verification job id.

Checking job status

User can query the verification job status using status command and providing job id as the --job argument value. The status check will poll the server with exponential backoff until the verification is complete or fails.