0

I'm trying to subscribe to my events from the first block. I'm using a WebSocketProvider with web3js 1.0.0-beta.34.

This is my code:

var options = {     
    "address": "0x43D3da5b4632A4dF523eEf17A327Bcd3051801Cd",
    "topics": ["0xb33b8a3028508f89632292a6f161ad643a276e5bc43d32c4fbb80e895811c2f9"],
    "fromBlock": 1
}

web3.eth.subscribe('logs', options, (error, result) => {
    if (!error) {
        const eventObj = web3.eth.abi.decodeLog(eventJsonInterface.inputs, result.data, result.topics.slice(1));
        callback(eventObj);
    }
});

Only new events are being received. Any clue about what I'm doing wrong?

  • It worked when I passed the number of block in hex like this: web3.utils.numberToHex(0) – klautern Apr 4 at 9:27

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.