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

Important: If you're encountering any problem declaring contracts, please read the Blake Hash Support information.

Predeployed contracts

snforge provides a set of predeployed contracts for use in testing. To support this functionality, we maintain CASM of these contracts directly within our codebase. Because these contracts are subject to periodic updates, these files need to be updated. The list below details all predeployed contracts and the information required to keep them current.

Adding new predeployed contract

To add a new predeployed contract, you need to add a new subdirectory with the name of the contract to the crates/cheatnet/src/data/predeployed_contracts directory. Then, you need to add artifact files to this subdirectory. CASM files should be renamed to casm.json.

📝 Note

When adding a new predeployed contract, make sure the class matches the one deployed on mainnet.

Structure of predeployed_contracts directory should be as follows:

$ tree
.
├── ERC20Lockable
│   └── casm.json
├── ERC20Mintable
│   └── casm.json
└── <Other contract>
    └── casm.json

Updating existing predeployed contracts

STRK and ETH

These contracts are sourced from the starkgate-contracts repository.

Current Build Configuration:

  • Version: v3.0.0
  • Commit Hash: 07e11c3
TokenContract NameSource Code (Cairo)Class on Mainnet
STRKERC20LockableView Source0x02e7...98fc
ETHERC20MintableView Source0x00b4...4ec

Steps to update STRK and ETH predeployed contracts:

  1. Clone starkgate-contracts repository and checkout v3.0.0 tag.

    git clone https://github.com/starknet-io/starkgate-contracts
    cd starkgate-contracts
    git checkout v3.0.0
    
  2. Enable CASM generation by adding the following lines to Scarb.toml. This should be done in sg_token and strk packages.

    ...
    
    [[target.starknet-contract]]
    casm = true
    
    ...
    
  3. Adjust compiler configuration in workspace Scarb.toml:

    ...
    
    [profile.release.cairo]
    add-statements-code-locations-debug-info = true
    add-statements-functions-debug-info = true
    panic-backtrace = true
    
    ...
    
  4. Compile contracts with scarb

    scarb --release build
    
  5. Visit target/release directory and copy relevant artifacts into relevant predeployed_contracts subdirectories in cheatnet codebase.