Search code examples
ethereum

Is there an API for ethereum address monitoring? Or how to get notifications when an address is paided


Consider the simple scenario: some address transfers 100 usdt to address A; is there a method or api to watch on address A to get automated notifications? What is the best practice for these payin notifications of many (~100+) addresses?


Solution

  • You can subscribe to Transfer event logs emitted by the USDT contract. As defined in the ERC-20 standard, the second param of the event log is the recipient address.

    Example using web3js:

    const options = {
        address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT contract on Ethereum
        topics: [
            web3.utils.keccak256("Transfer(address,address,uint256)"), // hash of the event definition
            null, // any sender
            ["0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF"] // recipient addresses
        ]
    };
    
    web3.eth.subscribe("logs", options, (err, data) => {
        console.log(data);
    });