0

I am trying to get all the events that originate from zero (0x0) address in order to capture the mint activity for my ERC20 token.

Here is my code snippet:

var instance = web3.eth.contract(abi).at(tokenContractAddress);
var blockNo = web3.eth.blockNumber;
console.log('latest block', blockNo); //able to get blockNo successfully

var result = instance.Transfer({from: '0x0000000000000000000000000000000000000000'},
            {fromBlock:4361077, toBlock:'latest'}, 
           (err, res) => {
             console.log(res);
        });

However i never get anything in the res object and its always undefined.

stud91
  • 113
  • 9

1 Answers1

0

I believe that you should change this:

{from: '0x0000000000000000000000000000000000000000'},
        {fromBlock:4361077, toBlock:'latest'}

To this:

{from: '0x0000000000000000000000000000000000000000',
        fromBlock:4361077, toBlock:'latest'}

If it's still not working for you, then you can try this:

instance.allEvents().get(function(error, logs) {
    assert(error === null);
    for (let i = 0; i < logs.length; i++) {
        if (logs[i].event == 'Transfer' && logs[i].args.from == '0x0000000000000000000000000000000000000000') {
            console.log(logs[i]);
        }
    }
});
goodvibration
  • 26,003
  • 5
  • 46
  • 86
  • i assume you mean logs[i].event == 'Transfer'

    I tried both and the console statement is never executed

    – stud91 May 28 '19 at 08:37
  • @stud91: Yes, my mistake with that comma there, changed it to ==. Are you sure that such an event has been fired prior to your attempt? – goodvibration May 28 '19 at 08:42
  • yes, please refer to https://rinkeby.etherscan.io/address/0x777a2eae2dbabf08d50e822631c54e4304414b45#events – stud91 May 28 '19 at 08:47