ethers-rs is a port of ethers-js in Rust.
Note: All examples using
await are assuming that they are called from inside an
function which is run in an async runtime. You are free to use any runtime and executor of
A prelude is provided which imports all the important data types and traits for you. Use this when you want to quickly bootstrap a new project.
Examples on how you can use the types imported by the prelude can be found in
examples directory of the repository
and in the
tests/ directories of each crate.
Contains all the necessary data structures for interacting
with Ethereum, along with cryptographic utilities for signing and verifying
ECDSA signatures on
secp256k1. Bindings to the solidity compiler and
are also provided as helpers. To simplify your imports, consider using the re-exported
modules described in the next subsection.
Ethereum nodes expose RPC endpoints (by default at
localhost:8545). You can connect
to them by using the
Provider. The provider instance
allows you to issue requests to the node which involve querying the state of Ethereum or
broadcasting transactions with unlocked accounts on the node.
For security reasons, you typically do not want your private keys to be stored on the nodes.
This module provides a
Wallet type for loading a private key which can be connected with a
Provider to produce a
Client type is the object via which we recommend
users with local private keys to use when interacting with Ethereum.
Interacting with Ethereum is not restricted to sending or receiving funds. It also involves using smart contracts, which can be thought of as programs with persistent storage.
Interacting with a smart contract requires broadcasting carefully crafted
transactions where the
data field contains
along with the arguments of the called function. This module provides the
ContractFactory abstractions so that you do not have to worry about that.
It also provides typesafe bindings via the
abigen macro and the