Skip to main content
All CollectionsStreams API
How to monitor for ERC20 token burns or mints?
How to monitor for ERC20 token burns or mints?

Receive webhooks when a token is minted or burnt

Jonathan Blackburn avatar
Written by Jonathan Blackburn
Updated over a year ago

Via Web UI

Let's check all USDC transfers but filter transactions where the recipient or the sender is the zero address and if the amount is greater or equal to 10000 USDC.

  1. Create a new Stream


  2. Fill out the Stream settings:

    - Add the USDC contract address



    - Input the event ABI and select the Transfer topic




    - Set the filter for Mints & Burns by adding below values (0x0000000000000000000000000000000000000000)

    Programmatically

    const transferUsdcAbi = [
    {
    anonymous: false,
    inputs: [
    {
    indexed: true,
    internalType: "address",
    name: "from",
    type: "address",
    },
    {
    indexed: true,
    internalType: "address",
    name: "to",
    type: "address",
    },
    {
    indexed: false,
    internalType: "uint256",
    name: "value",
    type: "uint256",
    },
    ],
    name: "Transfer",
    type: "event",
    },
    ];

    const filter = {
    or: [
    {
    and: [
    { eq: ["sender", "0x00000...00000"] },
    { gte: ["amount", "10000000000"] },
    ],
    },
    {
    and: [
    { eq: ["receiver", "0x00000...00000"] },
    { gte: ["amount", "10000000000"] },
    ],
    },
    ],
    }; // we will only receive events when the transfer recipent or the sender is the zero address meaning we are filtering mints and burn

    const options = {
    chains: [EvmChain.ETHEREUM], // Monitor USDC on ethereum
    description: "Token burns and mints", // your description
    tag: "mintsAndBurns", // give it a tag
    abi: transferUsdcAbi,
    includeContractLogs: true,
    topic0: ["Transfer(address,address,uint256)"],
    advancedOptions: [
    {
    topic0: "Transfer(address,address,uint256)",
    filter,
    includeNativeTxs: true,
    },
    ],
    webhookUrl: "https://YOUR_WEBHOOK_URL", // webhook url to receive events,
    };

    const stream = await Moralis.Streams.add(options);

    const { id } = stream.toJSON(); // { id: 'YOUR_STREAM_ID', ...stream }

    // Attach the contract address to the stream
    await Moralis.Streams.addAddress({
    id,
    address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC address
    });


Did this answer your question?