Reference
ethers-rs has been deprecated in favor of Alloy and Foundry.
The following is a reference guide for finding the migration path for your specific crate, dependency or information source.
Documentation
- Book:
ethers-rs/book
->
alloy-rs/book
Examples
- Examples:
ethers-rs/examples
->
alloy-rs/examples
Crates
-
Address book:
ethers::addressbook
->
Not planned -
Compilers:
ethers::solc
->
foundry-compilers
-
Contract:
ethers::contract
->
alloy::contract
-
Core:
ethers::core
->
alloy::core
- Types:
ethers::core::types::*
->
See Types section
- Types:
-
Etherscan:
ethers::etherscan
->
foundry-block-explorers
-
Middleware:
ethers::middleware
->
Fillersalloy::provider::{fillers, layers}
- Gas oracle:
ethers::middleware::GasOracleMiddleware
->
Gas filleralloy::provider::GasFiller
- Gas escalator:
ethers::middleware::GasEscalatorMiddleware
->
Not planned - Transformer:
ethers::middleware::TransformerMiddleware
->
Not planned - Policy:
ethers::middleware::policy::*
->
Not planned - Timelag:
ethers::middleware::timelag::*
->
Not planned - Nonce manager:
ethers::middleware::NonceManagerMiddleware
->
Nonce filleralloy::provider::NonceFiller
- Signer:
ethers::middleware::Signer
->
Wallet filleralloy::provider::WalletFiller
- Gas oracle:
-
Providers:
ethers::providers
->
Provideralloy::providers
-
Transports:
ethers::providers::transports
->
alloy::transports
-
Signers:
ethers::signers
->
Signeralloy::signers
- AWS:
ethers::signers::aws::*
->
alloy::signers::aws
- Ledger:
ethers::signers::ledger::*
->
alloy::signers::ledger
- Trezor:
ethers::signers::trezor::*
->
alloy::signer::trezor
- Wallet:
ethers::signers::wallet::*
->
alloy::signer::local
- AWS:
Types
Primitives
- Address:
ethers::types::Address
->
alloy::primitives::Address
- U64:
ethers::types::U64
->
alloy::primitives::U64
- U128:
ethers::types::U128
->
alloy::primitives::U128
- U256:
ethers::types::U256
->
alloy::primitives::U256
- U512:
ethers::types::U512
->
alloy::primitives::U512
- H32:
ethers::types::H32
->
alloy::primitives::aliases::B32
- H64:
ethers::types::H64
->
alloy::primitives::B64
- H128:
ethers::types::H128
->
alloy::primitives::B128
- H160:
ethers::types::H160
->
alloy::primitives::B160
- H256:
ethers::types::H256
->
alloy::primitives::B256
- H512:
ethers::types::H512
->
alloy::primitives::B512
- Bloom:
ethers::types::Bloom
->
alloy::primitives::Bloom
- TxHash:
ethers::types::TxHash
->
alloy::primitives::TxHash
Due to a limitation in ruint
, BigEndianHash
ethers::types::BigEndianHash
can be expressed as follows:
// `U256` => `B256`
let x = B256::from(u256);
// `B256` => `U256`
let x: U256 = b256.into();
let x = U256::from_be_bytes(b256.into())
Due to Rust issue #50133, the native TryFrom
trait is not supported for Uint
s. Instead, use
UintTryFrom
as follows:
use alloy_primitives::ruint::UintTryFrom;
let x: U512 = uint!(1234_U512);
let y: U256 = U256::uint_try_from(x).unwrap();
RPC
- Bytes:
ethers::types::bytes::*
->
alloy::primitives::Bytes
- Chains:
ethers::types::Chain
->
alloy-rs/chains
- ENS:
ethers::types::ens
->
foundry-common
- Trace:
ethers::types::trace::*
->
alloy::rpc::types::trace
- {Block, Fee, Filter, Log, Syncing, Transaction, TxPool}:
ethers::types::*
->
alloy::rpc::types::eth::*
- Proof:
ethers::types::proof::*
->
Accountalloy::rpc::types::eth::account::*
- Signature:
ethers::types::signature::*
->
alloy::rpc::types::eth::transaction::signature::*
- Withdrawal
ethers::types::withdrawal::*
->
EIP4895alloy::eips::eip4895
- Opcode:
ethers::types::opcode::*
->
syn-solidity
ABI
- Bindings:
abigen!
->
sol!
, available onalloy::sol
.