1.9 KiB
1.9 KiB
How was this library created?
- used
didcto generate the rust bindings from the evm rpc canister did file - added
call_with_payment128to functions that expect cycles - derive
DebugandClonetrait 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
EvmRpcCanisterstruct to initiate the canister with your own canister idpub 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_RPCstruct exposes the EVM RPC canisters interface and is used to make inter canister calls to itlet (result,) = EVM_RPC .eth_get_block_by_number(rpc_providers, None, block_tag, cycles) .await .expect("Call failed");