I am currently attempting to collect data on token transfers. In order to accomplish this, I am collecting data using getPastEvents() and I am passing a filter object as an argument to collect transfers between specific ethereum accounts:

let depositing_events = await contract.interface.getPastEvents('Transfer', 
                    filter: {
                        from: from_address, 
                        to: to_address
                    fromBlock: first_block, 

This has successfully worked for me for most tokens like USDT, however, it appears that I cannot use filtered events with the BUSD token. I suspect it has something to do with BUSD choosing to fire events in a non traditional manner. Considering that I cannot use filter, I instead want to use the topic option.

Here is an example of a transaction of BUSD that led to topics of the event being exposed. What is the correct way to pass in the topic option into getPastEvents to filter for transactions between specific addresses.

1 Answer 1


getPastEvents('Transfer', ...)

There is no event Transfer in the contract that you've linked.

So this attempt will obviously not retrieve any information from the blockchain.

BUSD choosing to fire events in a non traditional manner.

There is no such thing as "fire events in a non traditional manner".

Perhaps you meant to say "BUSD does not fire Transfer events".

Here is an example of a transaction of BUSD that led to topics of the event being exposed.

First of all, every event has at least one topic, which is the hash of the event-signature itself.

Additional topics may follow, one for each indexed parameter in the event.

However, the event that you've linked is not a Transfer event.

How do I know?

Because its first topic is 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925,

while the first topic in a Transfer event would be:

const Web3 = require("Web3");
const topic0 = Web3.utils.keccak256("Transfer(address,address,uint256)");
console.log(topic0); // 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

If you want to fetch events of the type that you've linked, then you can use getPastLogs, which is a "raw version" of getPastEvents (the latter simply takes the event-signature from the contract's ABI, and passes its hash to the former):

const depositing_events = await web3.eth.getPastLogs({
    address: "0x4fabb145d64652a948d72533023f6e7a623c7c53",
    topics: ["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"],
    fromBlock: first_block,
    toBlock: "latest"

As a side-note, when calling either getPastLogs or getPastEvents, I prefer to do it "in parts", because the node may fail to retrieve all events when there are too many of them.

For example:

async function getPastLogs(web3, address, topic0, fromBlock, toBlock) {
    if (fromBlock <= toBlock) {
        try {
            return await web3.eth.getPastLogs({
                address: address,
                topics: [topic0],
                fromBlock: fromBlock,
                toBlock: toBlock
        catch (error) {
            const midBlock = (fromBlock + toBlock) >> 1;
            const arr1 = await getPastLogs(web3, address, topic0, fromBlock, midBlock);
            const arr2 = await getPastLogs(web3, address, topic0, midBlock + 1, toBlock);
            return [...arr1, ...arr2];
    return [];


async function someFunc() {
    const depositing_events = await getPastLogs(
        await web3.eth.getBlockNumber()
  • I would hazard a guess that non-traditional means not ERC20 compliant...
    – Rambatino
    Jun 5, 2021 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.