Skip to content

Latest commit

 

History

History

README.md

Contracts Tests soldeer.xyz License

ERC20Forwarder Contract

The ERC20 forwarder contract written in Solidity enabling ERC20 token wrapping and unwrapping on the Anoma EVM protocol adapter.

Prerequisites

  1. Get an up-to-date version of Foundry with

    curl -L https://foundry.paradigm.xyz | sh
    foundryup
  2. Optionally, to lint the contracts, install solhint using a JS package manager such as Bun with

    curl -fsSL https://bun.sh/install | sh
    bun install
  3. Optionally, for static analysis, install Slither with

    python3 -m pip install slither-analyzer

    or brew

    brew install slither-analyzer

Usage

Installation

Change the directory to the contracts folder with cd contracts and run

forge soldeer install

Build

To compile the contracts, run

forge build

Tests & Coverage

To run the tests, run

forge test

To show the coverage report, run

forge coverage

Append the

  • --no-match-coverage "(script|test)" to exclude scripts, tests, and drafts,
  • --report lcov to generate the lcov.info file that can be used by code review tooling.

Linting & Static Analysis

As a prerequisite, install the

To run the linter and static analyzer, run

bunx solhint --config .solhint.json 'src/**/*.sol' && \
bunx solhint --config .solhint.other.json 'script/**/*.sol' 'test/**/*.sol' && \
slither .

Rust Bindings

To regenerate the Rust bindings (see the forge bind documentation), run

forge bind \
  --select '^(ERC20Forwarder|ERC20ForwarderV2|ERC20ForwarderV3|IProtocolAdapterSpecific|ILogicRefSpecific|IEmergencyMigratable)$' \
  --bindings-path ../bindings/src/generated/ \
  --module \
  --overwrite

Documentation

Run

forge doc

Deployment

To simulate deployment on sepolia, run

forge script script/DeployERC20Forwarder.s.sol:DeployERC20Forwarder \
  --sig "run(bool,address,bytes32,address)" <IS_TEST_DEPLOYMENT> <PROTOCOL_ADAPTER> <CARRIER_LOGIC_REF> <EMERGENCY_COMMITTEE> \
  --rpc-url sepolia

Append the

  • --broadcast flag to deploy to the network
  • --verify flag for subsequent contract verification (Sourcify by default; set ETHERSCAN_API_KEY to also verify on Etherscan)
  • --slow flag to add 15 seconds of waiting time between verification attempts
  • --account <ACCOUNT_NAME> flag to use a previously imported keystore (see cast wallet --help for more info)

Block Explorer Verification

For post-deployment verification on Sourcify run

forge verify-contract \
   <ADDRESS> \
   src/ERC20Forwarder.sol:ERC20Forwarder \
   --chain sepolia \
   --verifier sourcify

For Etherscan (requires ETHERSCAN_API_KEY) run

forge verify-contract \
   <ADDRESS> \
   src/ERC20Forwarder.sol:ERC20Forwarder \
   --chain sepolia \
   --verifier etherscan