0

I 'd like to get all past events of a ERC20 token contract using web3js getPastEvents method.

On my local testnet it worked but including some invalid values in response. Here is my JS code.

var newContract = new web3.eth.Contract(abi, address);
var events = await newContract.getPastEvents("allEvents", {fromBlock: 0,});
console.log(events);

Of course, this was done inside async funtion.

Here is the response.

[
 {
            "address": "0x827f5388892E4B7eA0e610a2812E8Afab0d4CadA",
            "blockNumber": 0,
            "transactionHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "transactionIndex": 0,
            "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "logIndex": 0,
            "removed": false,
            "id": "log_247b1779",
            "returnValues": {
                "0": "0x8734CB972d36a740Cc983d5515e160C373A4a016",
                "1": "0x9651819cfa16c8F3Ba927d5350Ca25417591166B",
                "2": "1000000000000",
                "from": "0x8734CB972d36a740Cc983d5515e160C373A4a016",
                "to": "0x9651819cfa16c8F3Ba927d5350Ca25417591166B",
                "value": "1000000000000"
            },
            "event": "Transfer",
            "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
            "raw": {
                "data": "0x000000000000000000000000000000000000000000000000000000e8d4a51000",
                "topics": [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                    "0x0000000000000000000000008734cb972d36a740cc983d5515e160c373a4a016",
                    "0x0000000000000000000000009651819cfa16c8f3ba927d5350ca25417591166b"
                ]
            }
        },
...(200 more objects)
]

All transactionHash , blockHash and transactionIndex returns "0x0000000000000000000000000000000000000000000000000000000000000000" or 0. Besides these, every other field seems to be ok.

My web3js version is "web3": "^3.0.0-rc.5",

I am not sure if this is actually related with web3js. Maybe it's my testnet engine side problem. Can anyone help me with this problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.