Use Rust
In this two-part tutorial we'll use Rust and the ethers-rs library to:
- Send a legacy transaction
("type":"0x0") - Send an EIP-1559 transaction
("type":"0x2")
This tutorial uses the Sepolia testnet. Also see Transaction types.
Prerequisites
- Make sure that you have test ETH in your MetaMask wallet. You can obtain test ETH for the Sepolia network using the Infura Sepolia faucet.
- Install Rust from The Cargo Book.
Send a legacy transaction
1. Create a new project
Open a terminal and create a new project:
cargo new infura_rs
This creates the infura_rs directory with the following structure:
infura_rs
├── Cargo.toml
└── src
└── main.rs
info
Refer to the Cargo documentation for more information about getting started with Cargo.
2. Edit the dependencies
Open Cargo.toml with your preferred editor and add the following dependencies to it:
[dependencies]
ethers = "2.0"
eyre = "0.6.8"
hex = "0.4.3"
tokio = { version = "1.28.2", features = ["full"] }
serde_json = "1.0.96"