Why was this library created
- there are some common patterns when interacting with EVM smart contracts from the IC via the EVM RPC canister that can be abstracted away from developers, this helps reduce writing boilerplate code and makes it easier to interact with the EVM RPC canister
- the library provides a set of types and functions that can be used to interact with the EVM
evm_signer: a module that provides a way to sign messages using the t-ECDSA and get the public key and EVM address of the signerfees: a module that provides a way to calculate the fees for a given transactionconversions: some helpful functions to convert between different types commonly used by the ethers crateeth_call: a module that provides a way to call a smart contract function without modifying the state of the EVM, this is useful for reading data from the EVM and achieved by calling therequestEVM RPC function- includes
erc20_balance_ofbuilt on top ofeth_callto get the balance of an ERC20 token eth_send_raw_transaction: a module that provides a way to send a signed transaction to the EVM, this is useful for modifying the state of the EVM and achieved by calling thesend_raw_transactionEVM RPC function- includes
transfer_ethandcontract_interactionfunctions built on top ofeth_send_raw_transactionto send ETH and interact with smart contracts request: a module that provides a way to make arbitrary RPC requests, includes determening the cycles costs of the requestrequest_costs: a module that provides a way to calculate the cycles costs of a given RPC request
How to use this library?
- the methods in this crate rely on the
EvmRpcCanisterstruct to make inter canister calls to the EVM RPC canister, this struct is used to initiate calls to the EVM RPC Canister- you can use the
evm-rpc-canister-typescrate to create this struct
- you can use the
- import the libary in your rust project
[] = 0.1 - import the crate where needed and pass the
EvmRpcCanisterstruct to the functions if necessaryuse ; // ... let status = contract_interaction .await;