evm_rpc_client

Crates.ioevm_rpc_client
lib.rsevm_rpc_client
version0.3.0
created_at2025-10-21 11:39:45.792289+00
updated_at2025-11-25 08:40:20.416317+00
descriptionRust client for interacting with the EVM RPC canister
homepage
repositoryhttps://github.com/dfinity/evm-rpc-canister
max_upload_size
id1893707
size195,480
defi-team (github:dfinity:defi-team)

documentation

https://docs.rs/evm_rpc_client

README

Internet Computer portal DFinity Forum GitHub license

Crate evm_rpc_client

Library to interact with the EVM RPC canister from a canister running on the Internet Computer. The alloy feature flag allows using Alloy types in requests and responses.

See the Rust documentation for more details.

Example

Fetching the latest transaction count for a given address using the eth_getTransactionCount JSON-RPC method.

use alloy_primitives::{Adress, U256};
use alloy_rpc_types::BlockNumberOrTag;
use evm_rpc_client::EvmRpcClient;
use evm_rpc_types::RpcResult;

fn get_latest_transaction_count (address: Address) -> RpcResult<U256> {
    let client = EvmRpcClient::builder_for_ic()
        .with_alloy()
        .build();

    client
        .get_transaction_count((address, BlockNumberOrTag::Latest))
        .send()
        .await
        .expect_consistent()
}
Commit count: 844

cargo fmt