StarkNet API

In StarkNet v0.13.0, old command line interface will be removed, and you could use Starkli instead.

For full documentation, see the Starkli Book.

1 Installation

If you're on Linux/macOS/WSL, you can install stakrliup by running the following command:

curl | sh

You might need to restart your shell session for the starkliup command to become available. Once it's available, run the starkliup command:


Running the commands installs starkli for you, and upgrades it to the latest release if it's already installed.

starkliup detects your device's platform and automatically downloads the right prebuilt binary. It also sets up shell completions. You might need to restart your shell session for the completions to start working.

2 Use Starkli

Starkli is centric around JSON-RPC, and the JSON-RPC provider is considered canonical. Users are strongly recommended to use JSON-RPC. There are a few options to obtain access to a JSON-RPC endpoint:

  • hosting your own node with pathfinder; or
  • using a third-party JSON-RPC API provider like Infstones

Once you have a URL to a JSON-RPC endpoint, you can use it via the --rpc option for commands that expect it. For example:

starkli block-number --rpc http://localhost:9545/

Alternatively, you can set the STARKNET_RPC environment variable to make command invocations easier:

export STARKNET_RPC="http://localhost:9545/"

and then, simply run:

starkli block-number

which is the same as the running with the --rpc option.

3 Commands

Starkli offers the following commands:

  • account
  • balance
  • block
  • block-hash
  • block-number
  • block-time
  • call
  • chain-id
  • class-at
  • class-by-hash
  • class-hash
  • class-hash-at
  • completions
  • declare
  • deploy
  • invoke
  • mont
  • nonce
  • parse-cairo-string
  • selector
  • signer
  • state-update
  • storage
  • syncing
  • to-cairo-string
  • transaction
  • transaction-receipt

To check usage of each command, run with the --help option.