Etherscan Tools: Contract & Transaction Data
Access Ethereum smart contract ABIs, source code, transaction status, block data, and token transfers through our Etherscan V2 integration.
Overview
The Etherscan endpoints provide:
- Contract Module - ABIs, source code, creation info
- Transaction Module - Execution status, receipt verification
- Block Module - Rewards, countdown, timestamp lookups
- Stats Module - ETH supply, price, node count
- Token Module - ERC20/721/1155 transfers and balances
All endpoints are prefixed with /api/etherscan/.
Prerequisites
npm install @atv-eth/x402-sdk
# or use curl/fetch directly
Contract Information
Get Contract ABI
Essential for interacting with verified contracts:
const address = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'; // WETH
const response = await fetch(`https://api.web3identity.com/api/etherscan/contract/abi/${address}`);
const data = await response.json();
console.log(`Contract: ${data.address}`);
console.log(`Verified: ${data.verified}`);
console.log(`Functions: ${data.abi.filter(i => i.type === 'function').length}`);
console.log(`Events: ${data.abi.filter(i => i.type === 'event').length}`);
Response:
{
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"abi": [
{
"type": "function",
"name": "deposit",
"inputs": [],
"outputs": []
},
{
"type": "function",
"name": "withdraw",
"inputs": [{"name": "wad", "type": "uint256"}],
"outputs": []
}
],
"verified": true,
"source": "etherscan",
"timestamp": "2026-02-09T08:30:00.000Z"
}
Get Contract Source Code
const source = await fetch(`https://api.web3identity.com/api/etherscan/contract/source/${address}`);
const data = await source.json();
console.log(`Contract Name: ${data.contractName}`);
console.log(`Compiler: ${data.compilerVersion}`);
console.log(`Optimization: ${data.optimizationUsed ? `Yes (${data.runs} runs)` : 'No'}`);
console.log(`License: ${data.licenseType}`);
console.log(`Is Proxy: ${data.proxy}`);
if (data.proxy) {
console.log(`Implementation: ${data.implementation}`);
}
Response:
{
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"contractName": "WETH9",
"compilerVersion": "v0.4.19+commit.c4cbbb05",
"optimizationUsed": false,
"runs": 0,
"sourceCode": "pragma solidity ^0.4.18;\n\ncontract WETH9 {...}...[truncated]",
"abi": "available",
"constructorArguments": "",
"evmVersion": "Default",
"library": "",
"licenseType": "None",
"proxy": false,
"implementation": null,
"source": "etherscan",
"timestamp": "2026-02-09T08:30:00.000Z"
}
Get Contract Creation Info
Find who deployed a contract and the deployment transaction:
// Supports up to 5 addresses comma-separated
const addresses = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,0xdAC17F958D2ee523a2206206994597C13D831ec7';
const creation = await fetch(`https://api.web3identity.com/api/etherscan/contract/creation/${addresses}`);
const data = await creation.json();
data.contracts.forEach(c => {
console.log(`${c.address}`);
console.log(` Creator: ${c.creator}`);
console.log(` Deploy TX: ${c.txHash}`);
});
Transaction Verification
Check Execution Status
Verify if a transaction executed successfully:
const txHash = '0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a';
const status = await fetch(`https://api.web3identity.com/api/etherscan/tx/status/${txHash}`);
const data = await status.json();
if (data.isError) {
console.log(`❌ Transaction failed: ${data.errDescription}`);
} else {
console.log('✅ Transaction executed successfully');
}
Response:
{
"txHash": "0x15f8e5ea...",
"isError": false,
"errDescription": null,
"source": "etherscan",
"timestamp": "2026-02-09T08:30:00.000Z"
}
Get Receipt Status
const receipt = await fetch(`https://api.web3identity.com/api/etherscan/tx/receipt/${txHash}`);
const data = await receipt.json();
console.log(`Status: ${data.status}`); // "success" or "failed"
Block Information
Get Block Reward
const blockNo = 19000000;
const reward = await fetch(`https://api.web3identity.com/api/etherscan/block/reward/${blockNo}`);
const data = await reward.json();
console.log(`Block #${data.blockNumber}`);
console.log(`Miner: ${data.blockMiner}`);
console.log(`Block Reward: ${data.blockReward} wei`);
console.log(`Uncle Inclusion Reward: ${data.uncleInclusionReward}`);
console.log(`Uncles: ${data.uncles?.length || 0}`);
Block Countdown
Estimate time until a future block:
const targetBlock = 20000000;
const countdown = await fetch(`https://api.web3identity.com/api/etherscan/block/countdown/${targetBlock}`);
const data = await countdown.json();
console.log(`Target Block: ${data.targetBlock}`);
console.log(`Current Block: ${data.currentBlock}`);
console.log(`Remaining Blocks: ${data.remainingBlocks}`);
console.log(`Estimated Time: ${Math.round(data.estimatedTimeInSec / 3600)} hours`);
Block by Timestamp
Find the block number at a specific time:
const timestamp = Math.floor(Date.now() / 1000) - 86400; // 24 hours ago
const block = await fetch(`https://api.web3identity.com/api/etherscan/block/by-time/${timestamp}`);
// Or get block after timestamp: ?closest=after
const data = await block.json();
console.log(`Block at timestamp ${data.timestamp}: #${data.blockNumber}`);
Network Statistics
ETH Supply
// Total ETH supply
const supply = await fetch('https://api.web3identity.com/api/etherscan/stats/ethsupply');
const data = await supply.json();
console.log(`Total ETH: ${data.ethSupplyFormatted} ETH`);
// ETH2 staking info
const eth2 = await fetch('https://api.web3identity.com/api/etherscan/stats/eth2supply');
const eth2Data = await eth2.json();
console.log(`ETH Supply: ${eth2Data.ethSupply}`);
console.log(`ETH2 Staked: ${eth2Data.eth2Staking}`);
console.log(`Burnt Fees: ${eth2Data.burntFees}`);
console.log(`Withdrawals: ${eth2Data.withdrawalTotal}`);
ETH Price
const price = await fetch('https://api.web3identity.com/api/etherscan/stats/ethprice');
const data = await price.json();
console.log(`ETH/USD: $${data.ethusd}`);
console.log(`ETH/BTC: ${data.ethbtc}`);
Node Count
const nodes = await fetch('https://api.web3identity.com/api/etherscan/stats/nodecount');
const data = await nodes.json();
console.log(`Total Nodes: ${data.totalNodeCount.toLocaleString()}`);
console.log(`Date: ${data.utcDate}`);
Token Transfers
ERC20 Token Transfers
const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // vitalik.eth
const transfers = await fetch(`https://api.web3identity.com/api/etherscan/token/transfers/${address}?offset=20`);
const data = await transfers.json();
console.log(`Recent token transfers for ${data.address}:`);
data.transfers.forEach(tx => {
const direction = tx.to.toLowerCase() === address.toLowerCase() ? '←' : '→';
console.log(` ${direction} ${tx.tokenSymbol}: ${tx.value} (${tx.tokenName})`);
});
Parameters:
offset- Number of results (default: 20, max: 100)page- Page numbercontractaddress- Filter by specific token
ERC20 Token Balance
const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
const token = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; // USDC
const balance = await fetch(`https://api.web3identity.com/api/etherscan/token/balance/${address}/${token}`);
const data = await balance.json();
// USDC has 6 decimals
const usdcBalance = parseInt(data.balance) / 1e6;
console.log(`USDC Balance: ${usdcBalance.toLocaleString()}`);
NFT (ERC721) Transfers
const nfts = await fetch(`https://api.web3identity.com/api/etherscan/nft/transfers/${address}`);
const data = await nfts.json();
console.log(`Recent NFT transfers:`);
data.transfers.forEach(tx => {
console.log(` ${tx.tokenName} #${tx.tokenID}`);
console.log(` ${tx.from.slice(0, 10)}... → ${tx.to.slice(0, 10)}...`);
});
ERC1155 Transfers
const erc1155 = await fetch(`https://api.web3identity.com/api/etherscan/erc1155/transfers/${address}`);
const data = await erc1155.json();
data.transfers.forEach(tx => {
console.log(`${tx.tokenName} #${tx.tokenID} x${tx.tokenValue}`);
});
Building a Contract Analyzer
Complete example combining multiple endpoints:
async function analyzeContract(address) {
const [abi, source, creation] = await Promise.all([
fetch(`https://api.web3identity.com/api/etherscan/contract/abi/${address}`).then(r => r.json()).catch(() => null),
fetch(`https://api.web3identity.com/api/etherscan/contract/source/${address}`).then(r => r.json()),
fetch(`https://api.web3identity.com/api/etherscan/contract/creation/${address}`).then(r => r.json())
]);
const analysis = {
address,
verified: abi?.verified || false,
name: source.contractName,
compiler: source.compilerVersion,
optimization: source.optimizationUsed,
proxy: source.proxy,
implementation: source.implementation,
license: source.licenseType,
creator: creation.contracts?.[0]?.creator,
deployTx: creation.contracts?.[0]?.txHash
};
if (abi?.abi) {
analysis.interface = {
functions: abi.abi.filter(i => i.type === 'function').map(f => f.name),
events: abi.abi.filter(i => i.type === 'event').map(e => e.name),
readFunctions: abi.abi.filter(i => i.type === 'function' && (i.stateMutability === 'view' || i.stateMutability === 'pure')).length,
writeFunctions: abi.abi.filter(i => i.type === 'function' && i.stateMutability !== 'view' && i.stateMutability !== 'pure').length
};
}
return analysis;
}
// Usage
const analysis = await analyzeContract('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2');
console.log(JSON.stringify(analysis, null, 2));
Building a Transaction Verifier
async function verifyTransaction(txHash) {
const [status, receipt] = await Promise.all([
fetch(`https://api.web3identity.com/api/etherscan/tx/status/${txHash}`).then(r => r.json()),
fetch(`https://api.web3identity.com/api/etherscan/tx/receipt/${txHash}`).then(r => r.json())
]);
return {
txHash,
executionSuccess: !status.isError,
receiptStatus: receipt.status,
error: status.errDescription,
verified: !status.isError && receipt.status === 'success'
};
}
// Usage
const verification = await verifyTransaction('0x15f8e5ea...');
if (verification.verified) {
console.log('✅ Transaction confirmed and successful');
} else {
console.log(`❌ Transaction issue: ${verification.error || 'Failed receipt'}`);
}
Endpoint Reference
| Endpoint | Description | Price |
|---|---|---|
/api/etherscan/contract/abi/:address | Contract ABI | $0.02 |
/api/etherscan/contract/source/:address | Source code | $0.02 |
/api/etherscan/contract/creation/:address | Creation info | $0.01 |
/api/etherscan/tx/status/:txhash | TX execution status | $0.01 |
/api/etherscan/tx/receipt/:txhash | TX receipt status | $0.01 |
/api/etherscan/block/reward/:blockno | Block reward | $0.01 |
/api/etherscan/block/countdown/:blockno | Block countdown | $0.01 |
/api/etherscan/block/by-time/:timestamp | Block by time | $0.01 |
/api/etherscan/stats/ethsupply | ETH supply | $0.005 |
/api/etherscan/stats/eth2supply | ETH2 staking stats | $0.005 |
/api/etherscan/stats/ethprice | ETH price | $0.005 |
/api/etherscan/stats/nodecount | Node count | $0.005 |
/api/etherscan/token/transfers/:address | ERC20 transfers | $0.02 |
/api/etherscan/token/balance/:address/:contract | Token balance | $0.01 |
/api/etherscan/nft/transfers/:address | ERC721 transfers | $0.02 |
/api/etherscan/erc1155/transfers/:address | ERC1155 transfers | $0.02 |
Error Handling
try {
const response = await fetch(`https://api.web3identity.com/api/etherscan/contract/abi/${address}`);
const data = await response.json();
if (data.error) {
if (data.code === 'NOT_VERIFIED') {
console.log('Contract is not verified on Etherscan');
} else {
console.log(`Error: ${data.message}`);
}
}
} catch (e) {
console.error('Network error:', e.message);
}
Rate Limits
- Free tier: 100 calls/day
- Caching: 30 seconds for stats, 1 hour for ABIs/source
- Contract ABI/source has longer cache due to static nature
Next Steps
- Bitcoin Deep Dive - Bitcoin blockchain data
- The Graph Queries - DeFi protocol data
- Farcaster Channels - Social discovery