evm-rpc-canister-types

Crates.ioevm-rpc-canister-types
lib.rsevm-rpc-canister-types
version
sourcesrc
created_at2024-06-21 13:57:15.942736
updated_at2025-01-23 15:49:01.267503
descriptionTypes for interacting with the EVM RPC canister.
homepagehttps://github.com/letmejustputthishere/chain-fusion-starter
repositoryhttps://github.com/letmejustputthishere/chain-fusion-starter
max_upload_size
id1279570
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Moritz Fuller (letmejustputthishere)

documentation

https://internetcomputer.org/docs/current/developer-docs/multi-chain/ethereum/evm-rpc/evm-rpc-canister

README

How was this library created?

  • used didc to generate the rust bindings from the evm rpc canister did file
  • didc bind --target rs evm_rpc.did > interface.rs
  • added call_with_payment128 to functions that expect cycles
  • derive Debug and Clone trait for types for convenience

How to use this library?

  • make sure you deploy the evm rpc canister to its mainnet id locally (7hfb6-caaaa-aaaar-qadga-cai)
    "evm_rpc": {
      "type": "custom",
      "candid": "https://github.com/internet-computer-protocol/evm-rpc-canister/releases/latest/download/evm_rpc.did",
      "wasm": "https://github.com/internet-computer-protocol/evm-rpc-canister/releases/latest/download/evm_rpc.wasm.gz",
      "remote": {
        "id": {
          "ic": "7hfb6-caaaa-aaaar-qadga-cai"
        }
      },
      "specified_id": "7hfb6-caaaa-aaaar-qadga-cai",
      "init_arg": "(record { logFilter = opt variant { HideAll }})"
    }
    
  • if you deploy your own evm rpc canister, you can use the EvmRpcCanister struct to initiate the canister with your own canister id
    pub const CANISTER_ID: Principal =
      Principal::from_slice(b"\x00\x00\x00\x00\x02\x30\x00\xCC\x01\x01"); // 7hfb6-caaaa-aaaar-qadga-cai
    pub const EVM_RPC: EvmRpcCanister = EvmRpcCanister(CANISTER_ID);
    
  • import the libary in your rust project
    [dependencies]
    evm_rpc_canister_types = 0.1
    
  • import the crate where needed, e.g.
    use evm_rpc_canister_types::{
      BlockTag, GetBlockByNumberResult, GetLogsArgs, GetLogsResult, HttpOutcallError,
      MultiGetBlockByNumberResult, MultiGetLogsResult, RejectionCode, RpcError, EVM_RPC,
    };
    
  • the EVM_RPC struct exposes the EVM RPC canisters interface and is used to make inter canister calls to it
    let (result,) = EVM_RPC
      .eth_get_block_by_number(rpc_providers, None, block_tag, cycles)
      .await
      .expect("Call failed");
    
Commit count: 173

cargo fmt