eth_getTransactionByHash - Base
Example code for the eth_getTransactionByHash JSON-RPC method. Complete guide on how to use eth_getTransactionByHash JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x633982a26e0cfba940613c52b31c664fe977e05171e35f62da2426596007e249"],
"id": "getblock.io"
}'const axios = require('axios');
const txHash = '0x633982a26e0cfba940613c52b31c664fe977e05171e35f62da2426596007e249';
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_getTransactionByHash',
params: [txHash],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const tx = response.data.result;
if (tx) {
console.log('From:', tx.from);
console.log('To:', tx.to);
console.log('Value:', parseInt(tx.value, 16) / 1e18, 'ETH');
console.log('Block:', parseInt(tx.blockNumber, 16));
}Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"blockHash": "0x849a3ac8f0d81df1a645701cdb9f90e58500d2eabb80ff3b7f4e8c13f025eff2",
"blockNumber": "0x12d687f",
"from": "0x742d35Cc6634C0532925a3b844Bc9e7595f5bE21",
"gas": "0x5208",
"gasPrice": "0x5f5e100",
"maxFeePerGas": "0x77359400",
"maxPriorityFeePerGas": "0x3b9aca00",
"hash": "0x633982a26e0cfba940613c52b31c664fe977e05171e35f62da2426596007e249",
"input": "0x",
"nonce": "0x1a",
"to": "0x1234567890123456789012345678901234567890",
"transactionIndex": "0x0",
"value": "0xde0b6b3a7640000",
"type": "0x2",
"chainId": "0x2105",
"v": "0x0",
"r": "0x...",
"s": "0x..."
}
}Response Parameters
Parameter
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?