eth_getTransactionByHash - Boba Network RPC Method
Retrieve transaction details by hash on Boba Network. Essential for AI dApp developers, enterprise integration teams, and builders requiring offchain compute access tracking transactions on the Hybrid Compute L2 enabling smart contracts to access AI models and Web2 APIs natively.
Returns the information about a transaction by transaction hash on Boba Network.
Why Boba Network? Build on the Hybrid Compute L2 enabling smart contracts to access AI models and Web2 APIs natively with HybridCompute 2.0 for native AI/API access, $70M ecosystem funding, OP Stack compatibility, and two-way offchain integration.
When to Use This Method
eth_getTransactionByHash is essential for AI dApp developers, enterprise integration teams, and builders requiring offchain compute access:
- Track pending and confirmed transaction status: Monitor the full lifecycle of a transaction from submission through finalization on Boba Network
- Verify transaction parameters: Confirm the value, gas, and input data match your intent for AI-powered dApps, Web2 API integration, enterprise blockchain solutions, and offchain computation
- Wallet transaction history display: Show detailed transaction records with sender, receiver, value, and status for end users
- Debug failed transactions: Inspect raw transaction data to diagnose reverted calls and unexpected behavior on the Hybrid Compute L2 enabling smart contracts to access AI models and Web2 APIs natively
Common Use Cases
1. Wait for Transaction Confirmation with Polling
Poll eth_getTransactionByHash until the transaction's blockNumber becomes non-null, indicating it has been mined on Boba Network. This is the standard pattern for tracking transaction finality.
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-boba-mainnet.n.dwellir.com/YOUR_API_KEY');
async function waitForConfirmation(txHash, interval = 2000) {
while (true) {
const tx = await provider.getTransaction(txHash);
if (tx && tx.blockNumber) {
console.log(`Transaction confirmed in block #${tx.blockNumber}`);
return tx;
}
console.log('Transaction pending, waiting...');
await new Promise(r => setTimeout(r, interval));
}
}
waitForConfirmation('0x5d01c1b5655ee1315a49968be5bf94b730e8ea3854e88b3ee4ef7624f3b15565');2. Display Transaction Details in a Wallet UI
Fetch and format transaction data for display in a wallet or explorer on Boba Network. Extract the key fields: sender, recipient, value, gas, and confirmation status.
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-boba-mainnet.n.dwellir.com/YOUR_API_KEY'))
def get_transaction_details(tx_hash):
tx = w3.eth.get_transaction(tx_hash)
if not tx:
return {'status': 'not found'}
return {
'hash': tx['hash'].hex(),
'from': tx['from'],
'to': tx['to'],
'value_ether': w3.from_wei(tx['value'], 'ether'),
'gas': tx['gas'],
'gas_price_gwei': w3.from_wei(tx['gasPrice'], 'gwei'),
'block': tx.get('blockNumber'),
'confirmed': tx.get('blockNumber') is not None,
}
details = get_transaction_details('0x5d01c1b5655ee1315a49968be5bf94b730e8ea3854e88b3ee4ef7624f3b15565')
for key, value in details.items():
print(f'{key}: {value}')3. Decode Transaction Input Data for Contract Interaction Analysis
When a transaction's input field contains encoded function calls, decode it using a contract ABI to understand what action was performed on the Hybrid Compute L2 enabling smart contracts to access AI models and Web2 APIs natively.
package main
import (
"context"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
client, _ := ethclient.Dial("https://api-boba-mainnet.n.dwellir.com/YOUR_API_KEY")
txHash := common.HexToHash("0x5d01c1b5655ee1315a49968be5bf94b730e8ea3854e88b3ee4ef7624f3b15565")
tx, isPending, _ := client.TransactionByHash(context.Background(), txHash)
fmt.Printf("Pending: %v\n", isPending)
fmt.Printf("From: %s\n", tx.From().Hex())
fmt.Printf("Value: %s wei\n", tx.Value().String())
fmt.Printf("Gas limit: %d\n", tx.Gas())
if len(tx.Data()) > 0 {
// First 4 bytes are the function selector
selector := tx.Data()[:4]
fmt.Printf("Function selector: 0x%x\n", selector)
fmt.Printf("Input data length: %d bytes\n", len(tx.Data()))
}
}Best Practices
- Check if
blockNumberis null to detect pending transactions: A nullblockNumberindicates the transaction has been submitted but not yet mined; use this to drive polling or loading states in your UI - For mined transactions, cross-reference with receipt for confirmation count: Once a block number is available, use
eth_getTransactionReceiptto get the final status, gas used, and emitted logs - Cache confirmed transaction data indefinitely: Transaction data is immutable once mined; cache it permanently to avoid redundant RPC calls for historical lookups
- Use
eth_getTransactionReceiptfor post-confirmation data: After a transaction is confirmed, calleth_getTransactionReceiptto get gas used, logs, status code, and effective gas price
Code Examples
Error Handling
| Error Code | Message | Description |
|---|---|---|
| -32602 | Invalid params | Invalid transaction hash format |
Related Methods
eth_getTransactionReceipt- Get transaction receipteth_sendRawTransaction- Send transaction
eth_sendRawTransaction
Submit signed transactions to Boba Network. Essential for broadcasting transactions for AI-powered dApps, Web2 API integration, enterprise blockchain solutions, and offchain computation.
eth_getTransactionReceipt
Get transaction receipt with status and logs on Boba Network. Essential for verifying transaction execution for AI-powered dApps, Web2 API integration, enterprise blockchain solutions, and offchain computation.