9 releases (4 major breaking)

4.0.1 Jan 23, 2025
3.0.0 Sep 17, 2024
2.0.0 Sep 16, 2024
1.0.0 Jul 16, 2024
0.1.2 Jun 26, 2024

#35 in #dfinity

Download history 149/week @ 2024-10-24 218/week @ 2024-10-31 101/week @ 2024-11-07 76/week @ 2024-11-14 157/week @ 2024-11-21 181/week @ 2024-11-28 235/week @ 2024-12-05 509/week @ 2024-12-12 128/week @ 2024-12-19 27/week @ 2024-12-26 206/week @ 2025-01-02 262/week @ 2025-01-09 374/week @ 2025-01-16 436/week @ 2025-01-23 269/week @ 2025-01-30 360/week @ 2025-02-06

1,539 downloads per month
Used in 2 crates

Apache-2.0

23KB
531 lines

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

Dependencies

~9–22MB
~281K SLoC