⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_sendRawTransaction

Submits a pre-signed transaction to the network for execution.

When to Use This Method#

Use eth_sendRawTransaction to:

  • Send ZETA Transfers - Transfer native ZETA tokens
  • Execute Smart Contracts - Call contract functions
  • Deploy Contracts - Deploy new smart contracts
  • Cross-Chain Operations - Initiate omnichain transactions
  • Batch Transactions - Send multiple pre-signed transactions

Parameters#

  1. Signed Transaction Data - DATA
    • The signed transaction data as hexadecimal
{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": [
"0xf86c0185046110c9e382520894d46e8dd67c5d32be8058bb8eb970870f072445678..."
],
"id": 1
}

Returns#

DATA, 32 Bytes - The transaction hash, or error if transaction invalid.

Implementation Examples#

curl -X POST https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": [
"0xf86c0185046110c9e382520894d46e8dd67c5d32be8058bb8eb970870f072445678..."
],
"id": 1
}'

Example Response#

{
"jsonrpc": "2.0",
"id": 1,
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

Transaction Building Guide#

Standard ZETA Transfer#

const tx = {
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb8',
value: ethers.parseEther('1.0'),
gasLimit: 21000,
gasPrice: await provider.getGasPrice(),
nonce: await provider.getTransactionCount(from),
chainId: 7000
};

Smart Contract Interaction#

const tx = {
to: contractAddress,
data: contractInterface.encodeFunctionData('transfer', [recipient, amount]),
gasLimit: await provider.estimateGas(tx),
gasPrice: await provider.getGasPrice(),
nonce: await provider.getTransactionCount(from),
chainId: 7000
};

Contract Deployment#

const tx = {
data: bytecode + constructorArgs,
gasLimit: 3000000,
gasPrice: await provider.getGasPrice(),
nonce: await provider.getTransactionCount(from),
chainId: 7000
};

Error Handling#

Common Errors#

ErrorCauseSolution
nonce too lowNonce already usedGet current nonce
insufficient fundsNot enough ZETAAdd funds to account
gas too lowInsufficient gas limitIncrease gas limit
invalid signatureWrong chain ID or keyCheck chain ID (7000)
transaction underpricedGas price too lowIncrease gas price

Error Handling Example#

async function safeSendTransaction(signedTx) {
try {
const txHash = await provider.send('eth_sendRawTransaction', [signedTx]);
return { success: true, hash: txHash };
} catch (error) {
if (error.message.includes('nonce too low')) {
return { success: false, error: 'Transaction already sent' };
}
if (error.message.includes('insufficient funds')) {
return { success: false, error: 'Insufficient ZETA balance' };
}
throw error;
}
}

Best Practices#

  1. Always estimate gas before sending
  2. Implement nonce management for batch transactions
  3. Add gas price buffer for network congestion
  4. Wait for confirmations for important transactions
  5. Implement retry logic with exponential backoff
  6. Validate transaction parameters before signing

Security Considerations#

  • Never expose private keys in code
  • Use hardware wallets for production
  • Validate recipient addresses
  • Implement transaction limits
  • Monitor for transaction success