Skip to content

A protocol adapter contract written in Solidity enabling Anoma Resource Machine transaction settlement on EVM-compatible chains.

License

Notifications You must be signed in to change notification settings

anoma/evm-protocol-adapter

Repository files navigation

CI

EVM Protocol Adapter

A protocol adapter contract written in Solidity enabling Anoma Resource Machine transaction settlement on EVM-compatible chains.

Project Structure

.
├── bindings
├── contracts
├── LICENSE
└── README.md

The contracts folder contains the contracts written in Solidity as well as Foundry forge tests and deploy scripts.

The bindings folder contains bindings in Rust to convert Rust and RISC Zero types into EVM types using the alloy-rs library.

Audits

Anoma smart contracts undergo regular audits:

  1. Informal Systems

    📄 Audit Report (pdf)

  2. Nethermind

    📄 Audit Report (pdf)

Security

If you believe you've found a security issue, we encourage you to notify us via Email at security@anoma.foundation.

Please do not use the issue tracker for security issues. We welcome working with you to resolve the issue promptly.

Solidity Contracts

Prerequisites

Get an up-to-date version of Foundry with

curl -L https://foundry.paradigm.xyz | sh
foundryup

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|draft)" 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

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

Documentation

Run

forge doc

Deployment

To simulate deployment on sepolia, run

forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter \
  --sig "run(bool,address)" <IS_TEST_DEPLOYMENT> <EMERGENCY_STOP_CALLER> \
  --rpc-url sepolia

Append the

  • --broadcast flag to deploy on sepolia
  • --verify --slow flags for subsequent contract verification on Etherscan (--slow adds 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 Etherscan run

forge verify-contract \
   <ADDRESS> \
   src/ProtocolAdapter.sol:ProtocolAdapter \
   --chain sepolia

after replacing <ADDRESS> with the respective contract address.

Benchmarks

The following benchmark shows the transaction execution costs without and with proof aggregation for the current protocol adapter implementation:

Protocol adapter benchmark.

Rust Bindings

Prerequisites

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

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Install RISC Zero rzup with

    curl -L https://risczero.com/install | sh
  3. Install the latest RISC Zero version with

    rzup install

    or a specific version (e.g., 3.0.3) with

    rzup install cargo-risczero <version>

Usage

Build

From the project root run

cargo build

Test

To test the build, run

cargo test

Example Transactions

To generate test transactions with aggregated and non-aggregated proofs, build the executable with

cargo build --package evm_protocol_adapter_bindings --example generate_trivial_transaction

and run it with, e.g.,

./target/debug/examples/generate_trivial_transaction true 1 1

from the project root, where

  • the first argument is whether to generate aggregate proofs or not,
  • the second argument is the number of actions to generate, and
  • the last argument is the number of compliance units per actions, each of which contains two resources.

Compliance units contain one ephemeral consumed resource and one created resource, both having a quantity of one and the trivial resource logic always returning true.

About

A protocol adapter contract written in Solidity enabling Anoma Resource Machine transaction settlement on EVM-compatible chains.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 9