Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Aliases

When you use commands like sncast call, sncast invoke, etc. you typically need to specify some felt values, for example --contract-address:

$ sncast call --contract-address 0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008 --function get --calldata 0x0 --block-id latest

Instead, you can define aliases for felt values (contract addresses, class hashes, etc.) in snfoundry.toml.

Then, you can pass them on CLI using the @alias syntax:

$ sncast call --contract-address @map --function get --calldata 0x0 --block-id latest

Defining aliases

  1. Open your preferred snfoundry.toml configuration file. For details on snfoundry.toml configuration, see Configuration.

    💡 Tip If you want your aliases globally available, you'll likely want to edit global config file, and add aliases to the default profile.

  2. Add an [aliases] table under your sncast profile:
    [sncast.default]
    network = "sepolia"
    
    [sncast.default.aliases]
    map = "0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008"
    map-class = "0x2a09379665a749e609b4a8459c86fe954566a6beeaddd0950e43f6c700ed321"
    
    Values are felts in hex or decimal form.

💡 Tip

Aliases follow the same rules as other snfoundry.toml settings. That means you can define aliases in the global and local config files, and create the per-profile aliases, for example:

[sncast.myprofile]
network = "devnet"

[sncast.myprofile.aliases]
predeployed-account = "0x691a61b12a7105b1372cc377f135213c11e8400a546f6b0e7ea0296046690ce"

Same as other snfoundry.toml settings, aliases defined in higher-precedence config override lower-precedence ones.

Using aliases in CLI

Where a command accepts a felt argument that supports aliases, you can pass @alias instead of felt literal:

$ sncast call --contract-address @map --function get --calldata 0x0 --block-id latest

Listing aliases

Run sncast alias list to list aliases from the current effective config:

$ sncast alias list
Output:
map:       0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008
map-class: 0x2a09379665a749e609b4a8459c86fe954566a6beeaddd0950e43f6c700ed321

@alias interaction with multicall @id

See alias interaction with id.

Supported commands

Currently, aliases are supported for:

  • sncast call: --contract-address, --calldata
  • sncast invoke: --contract-address, --calldata
  • sncast deploy: --class-hash, --constructor-calldata
  • sncast declare-from: --class-hash
  • sncast account create: --class-hash
  • sncast account import: --address, --class-hash
  • sncast get balance: --token-address
  • sncast get nonce: <CONTRACT_ADDRESS>
  • sncast get class-hash-at: <CONTRACT_ADDRESS>
  • sncast verify: --class-hash, --contract-address
  • sncast utils serialize: --class-hash, --contract-address
  • sncast utils contract-address: --class-hash, --deployer-address, --constructor-calldata
  • sncast multicall execute: --class-hash, --contract-address, and @<name> in --calldata (see multicall)
  • sncast multicall run: class_hash, contract_address, and @<name> in inputs (see multicall)