Skip to content

Smart contracts built on top of Avalanche Interchain Messaging (ICM) to facilitate EVM cross-chain application development.

License

Notifications You must be signed in to change notification settings

DERACHAIN/icm-contracts

 
 

Repository files navigation

ICM Contracts

ICM smart contracts for DERA chain, including:

  • ValidatorManager
  • Teleporter
  • ICTT (unused)

The repository is forked from Avalanche

Structure

  • contracts/
    • governance/ includes contracts related to L1 governance.
    • ictt/ Interchain Token Transfer contracts. Facilitates the transfer of tokens among L1s.
    • teleporter/ includes TeleporterMessenger, which serves as the interface for most contracts to use ICM.
      • registry/ includes a registry contract for managing different versions of TeleporterMessenger.
    • validator-manager/ includes contracts for managing the validator set of an L1.
  • abi-bindings/ includes Go ABI bindings for the contracts in contracts/.
  • audits/ includes all audits conducted on contracts in this repository.
  • tests/ includes integration tests for the contracts in contracts/, written using the Ginkgo testing framework.
  • utils/ includes Go utility functions for interacting with the contracts in contracts/. Included are Golang scripts to derive the expected EVM contract address deployed from a given EOA at a specific nonce, and also construct a transaction to deploy provided byte code to the same address on any EVM chain using Nick's method.
  • scripts/ includes bash scripts for interacting with TeleporterMessenger in various environments, as well as utility scripts.
    • abi_bindings.sh generates ABI bindings for the contracts in contracts/ and outputs them to abi-bindings/.
    • lint.sh performs Solidity and Golang linting.

Prerequisites

  • Foundry Use ./scripts/install_foundry.sh to install the Ava Labs fork for building contracts.

Setup

  • Determine the SUBNETID_HEX using the ICM relayer tools (command mode)
$ ./bin/cli convertID --source-id=SUBNETID_CB58

prepend the result with 0x to get the final SUBNETID_HEX

*Note: the SUBNETID_CB58 is retrieved using avalanche blockchain describe command.

  • Create .env file from template and fill in necessary information.

  • Get all submodules: git submodule update --init --recursive

Compile

$ forge build

Test

$ forge test

Deploy

  • The ValidatorManager and Teleporter smart contracts are deployed during L1 deployment process, thus initial deployment is not necessary.

Upgrade

  • Increase monotonically the VERSION_NUMBER in contracts/validator-manager/NativeTokenStakingManager.sol
function initialize(
        PoSValidatorManagerSettings calldata settings
    ) external reinitializer(<VERSION_NUMBER>) {
        __NativeTokenStakingManager_init(settings);
    }
  • Compile
$ forge clean && forge build
  • Upgrade ValidatorManager implementation
$ forge script contracts/validator-manager/scripts/UpgradeScript.s.sol \
--rpc-url RPC_URL --broadcast -vvvv

Note: Should dry-run before actual deployment by omitting the --broadcast argument from the command

  • Confirm the new implementation using utils/validator-manager-rs command
$ cd utils/validator-manager-rs
$ cargo run -p cli -- admin proxy-info

ValidatorManager CLI tools

ValidatorManager CLI is proprietary tools developed by DERA team to interact with ValidatorManager and Teleporter smart contracts. See the CLI documentation for more details.

Docs

About

Smart contracts built on top of Avalanche Interchain Messaging (ICM) to facilitate EVM cross-chain application development.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 66.3%
  • Go 28.2%
  • Rust 3.1%
  • Shell 2.4%