📤 eth_sendRawTransaction - Base Chain
What This Method Does
The eth_sendRawTransaction
method broadcasts a signed transaction to the Base network. This is how you submit transactions that have already been signed offline, allowing you to maintain custody of your private keys while interacting with the network.
🔑 Security Benefit: By signing transactions offline and only sending the signed result, your private keys never need to be exposed to the internet.
Parameters
Parameter | What to Provide |
---|---|
Transaction data | The signed transaction data as a hex string (starts with "0x") |
What You'll Get Back
Transaction hash
- The 32-byte hash of the submitted transaction, which you can use to track its status
Need RPC API keys?
Get 12.5M archival requests for free today.
Request Format
POST https://base-mainnet.chainnodes.org/YOUR-API-KEY
Example
- HTTPS POST Request with a JSON RPC call in the body
- Replace YOUR-API-KEY with the API key from your Chainnodes.org Dashboard
- You can use a different supported network by replacing
base-mainnet
curl https://base-mainnet.chainnodes.org/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0x02f8b30121847735940085093a1ca031833030d094a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480b844a9059cbb000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000005f5e100c080a0ed4be6417e56f9692aec11f846b8e37345f1d7ab7468b49f7bd9fe5a44f0cdfda01d52afeac47a51fef92c27c304667241b27b7056f68aa8b92b7e7e8ed4869514"],"id":1}'
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
}
The result
contains the transaction hash, which you can use to track the status of your transaction.
💡 Confusing?
Ask our experienced blockchain developers in Telegram
Creating Transactions for Base Chain
When creating transactions to send on Base, you need to be aware of several Base-specific parameters:
1. Base Chain ID
Base mainnet uses chain ID 8453 (0x2105 in hex), and Base Goerli testnet uses 84531 (0x14a33 in hex). This must be included in your transaction signing process.
2. Gas Parameters for Base
Base uses EIP-1559 style gas pricing with typically lower fees than Ethereum mainnet:
// Get recommended values for Base
const maxPriorityFeePerGas = await provider.send("eth_maxPriorityFeePerGas", []);
const block = await provider.getBlock("latest");
const baseFee = block.baseFeePerGas;
// Add a small buffer to the base fee for safety
const maxFeePerGas = baseFee.mul(2).add(maxPriorityFeePerGas);
3. Transaction Types
Base supports the same transaction types as Ethereum:
- Type 0: Legacy transactions
- Type 1: EIP-2930 transactions with access lists
- Type 2: EIP-1559 transactions (recommended for Base)
Complete Example: Creating and Sending a Transaction
Here's a complete example using ethers.js to create, sign, and send a transaction on Base:
const { ethers } = require("ethers");
async function sendTransaction() {
// Connect to Base network
const provider = new ethers.providers.JsonRpcProvider("https://base-mainnet.chainnodes.org/YOUR-API-KEY");
// Create a wallet (in production, use a safer method to handle private keys)
const privateKey = "0xYOUR_PRIVATE_KEY";
const wallet = new ethers.Wallet(privateKey, provider);
// Get the current recommended gas values
const maxPriorityFeePerGas = ethers.utils.parseUnits("0.1", "gwei"); // 0.1 Gwei is often sufficient on Base
const block = await provider.getBlock("latest");
const baseFee = block.baseFeePerGas;
const maxFeePerGas = baseFee.mul(2).add(maxPriorityFeePerGas); // 2x base fee + priority fee
// Create transaction object
const tx = {
to: "0xRecipientAddress",
value: ethers.utils.parseEther("0.01"), // Sending 0.01 ETH
maxPriorityFeePerGas,
maxFeePerGas,
gasLimit: 21000, // Standard transfer gas limit
chainId: 8453, // Base mainnet chain ID
type: 2 // EIP-1559 transaction
};
// Sign transaction
const signedTx = await wallet.signTransaction(tx);
// Send the raw transaction
const txHash = await provider.send("eth_sendRawTransaction", [signedTx]);
console.log(`Transaction sent: ${txHash}`);
return txHash;
}
Common Errors & Solutions
Error | Possible Cause | Solution |
---|---|---|
nonce too low | The account's nonce is higher than the one specified | Get the current nonce with eth_getTransactionCount |
insufficient funds | Account doesn't have enough ETH | Add more ETH to your account |
gas price too low | Base fee or priority fee is too low | Increase maxFeePerGas and/or maxPriorityFeePerGas |
already known | The same transaction was already submitted | This is normal if you resubmit; wait for confirmation |
replacement transaction underpriced | Trying to replace a pending tx with too low gas price | Increase gas price at least 10% over the pending tx |
Related Methods
- eth_getTransactionCount - Get the current nonce for your account
- eth_maxPriorityFeePerGas - Get a suggested priority fee
- eth_getTransactionReceipt - Check if your transaction was confirmed
- eth_estimateGas - Estimate gas needed for a transaction
JSON-RPC Base API Documentation by CHAINNODES is based on Reth node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or Erigon