Skip to main content

Execute

Example: Execute the Transaction

import Web3 from 'web3';
import 'dotenv/config';

const web3 = new Web3('https://base.llamarpc.com');

const tx = assembled.transaction;
const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_KEY);
const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);

console.log('Transaction hash:', receipt.transactionHash);

Example Response

{
"blockNumber": 23619524,
"gasEstimate": 214504,
"gasEstimateValue": 1.12,
"transaction": {
"to": "0x221a4c9e54baebd678ff1823e4fca2ac3685ca64",
"from": "0x5AD89031aAfFe2F82dF3b98Fa4181E08B5dCFF9C",
"data": "0x12ab34cd...",
"chainId": 8453,
"gas": 235000,
"gasPrice": "1000000000",
"value": "0",
"nonce": 112
},
"simulation": {
"isSuccess": true,
"amountsOut": ["1833893"],
"simGasUsed": 203421,
"gasEstimate": 214504,
"simulationError": null
}
}