This tutorial shows you how to detect and stream ERC-20 contract deployments in real time using The Neighborhood’s indexing infrastructure. Basically we are going to track new token creations.Unlike event-based pipelines, this example scans the entire chain for contract creation transactions and identifies which of these deployments implement the ERC-20 interface.
Note: The output of this pipeline can be used to trigger another pipeline that filters only the token transfers for these deployed tokens, creating a complete token tracking system.
Detects contracts implementing the ERC-20 standard (using function selectors)
Streams structured deployment data to a destination of your choice
Delivery: Choose where the data should go: your database, a webhook, a Kafka topic - you name it! You can find the full list of supported destinations in our adapter directory.
This transformation inspects each transaction trace within a block. If a contract is deployed and its bytecode contains known ERC-20 method selectors, it emits a record with the deployment details.
Copy
function main(block) { const newContracts = []; const erc20InterfaceSignatures = [ '18160ddd', // totalSupply() '70a08231', // balanceOf(address) 'a9059cbb', // transfer(address,uint256) '23b872dd', // transferFrom(address,address,uint256) '095ea7b3', // approve(address,uint256) 'dd62ed3e', // allowance(address,address) ]; for (const tx of block.transactions) { if (!tx.receipt || !tx.traces?.length) continue; for (let ti = 0; ti < tx.traces.length; ti += 1) { const result = tx.traces[ti].result; if (result?.address && result.code) { if (!erc20InterfaceSignatures.find(fourByte => result.code.includes(fourByte))) { continue; } newContracts.push({ chain: block._network.toLowerCase(), timestamp: new Date(block.timestamp * 1000), transactionHash: tx.hash, traceIndex: ti, address: result.address.toLowerCase(), }); } } } return newContracts;}
You’ve now set up a real-time pipeline for detecting ERC-20 contract deployments on The Neighborhood.To go further, chain this output into a second pipeline that filters and streams token transfers for these newly deployed tokens.Need help or want to go further?