Write Methods
Thewrite interface sends state-changing transactions via eth_sendTransaction. These calls modify blockchain state and require gas.
This uses the Contract pattern - a copyable implementation you add to your codebase.
Basic Usage
How It Works
When you call a write method:- Encode - Arguments are ABI-encoded with the function selector
- Send -
eth_sendTransactionis sent to the provider - Return - Transaction hash is returned immediately
Transaction Options
Override transaction parameters:Payable Functions
For functions that accept ETH, passvalue in options:
Error Handling
Write calls can fail at submission or execution:- Insufficient funds - Not enough ETH for gas
- User rejected - User rejected in wallet
- Nonce too low - Transaction already mined
- Gas estimation failed - Transaction would revert
Waiting for Confirmation
The write method returns immediately. To wait for confirmation:Simulating Before Sending
UseestimateGas to simulate the transaction first:
Related
- Contract Overview - Contract module introduction
- Read Methods - Calling view functions
- Gas Estimation - Estimating gas before sending
- Events - Watching for transaction events

