Submit state-changing contract transactions via eth_sendTransaction and poll for receipts.
contract.write.<fn>(...args, options?) encodes calldata for nonpayable and payable functions, submits the transaction via eth_sendTransaction, and returns a 32-byte HashType transaction hash immediately upon submission.
eth_sendTransaction resolves once the node accepts the transaction into its mempool. Execution happens asynchronously and may revert on-chain. Always wait for a receipt before treating state changes as final.
Transaction Options
Pass a trailing WriteCallOptions object after the ABI arguments to set sender, fees, gas limit, ETH value, or nonce:
Option
Type
RPC Field
Use
from
`0x${string}`
from
Sender account (required by nodes with multiple accounts)
gas
bigint
gas
Gas limit override
maxFeePerGas
bigint
maxFeePerGas
EIP-1559 max total fee per gas (wei)
maxPriorityFeePerGas
bigint
maxPriorityFeePerGas
EIP-1559 priority tip per gas (wei)
gasPrice
bigint
gasPrice
Legacy transaction gas price (wei)
value
bigint
value
ETH attached to payable calls (wei)
nonce
bigint
nonce
Explicit sender nonce
// EIP-1559 transfer with explicit gas limit and fee capsconst txHash = await usdc.write.transfer(recipient, 1_000_000n, { from: sender, gas: 65_000n, maxFeePerGas: 30_000_000_000n, maxPriorityFeePerGas: 2_000_000_000n,});// Payable call (zero ABI inputs, options as sole argument)const depositHash = await weth.write.deposit({ from: sender, value: 1_000_000_000_000_000_000n, // 1 ETH});
Simulate Before Sending
Call estimateGas first to catch reverts before broadcasting and add a 20% headroom buffer:
write throws ContractFunctionNotFoundError if the function is absent or is view/pure. Wallet rejections, insufficient funds, invalid nonces, and simulation reverts are wrapped in ContractWriteError with error.cause holding the underlying RpcError.