7 releases (3 major breaking)

3.0.0 Sep 17, 2024
2.0.0 Sep 16, 2024
1.0.0 Jul 16, 2024
0.1.3 Jul 15, 2024
0.1.2 Jun 26, 2024

#30 in #dfinity

Download history 23/week @ 2024-06-28 21/week @ 2024-07-05 260/week @ 2024-07-12 72/week @ 2024-07-19 48/week @ 2024-07-26 33/week @ 2024-08-02 62/week @ 2024-08-09 112/week @ 2024-08-16 110/week @ 2024-08-23 266/week @ 2024-08-30 141/week @ 2024-09-06 539/week @ 2024-09-13 292/week @ 2024-09-20 245/week @ 2024-09-27 140/week @ 2024-10-04 137/week @ 2024-10-11

833 downloads per month
Used in 2 crates

Apache-2.0

21KB
519 lines

How was this library created?

  • used didc to generate the rust bindings from the evm rpc canister did file
  • 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 { nodesInSubnet = 28 })"
    }
    
  • 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–21MB
~293K SLoC