robertoschler
over 1 year ago  Karma: 50
Web3.js function(s) to help determine the block numbers inside a date range?

I'm working through Lesson 6, Chapter 9. In that lesson it talks about subscribing to events and also querying for events within a certain block range:

We can even query past events using getPastEvents, and use the filters fromBlock and toBlock to give Solidity a time range for the event logs ("block" in this case referring to the Ethereum block number):
``
cryptoZombies.getPastEvents("NewZombie", { fromBlock: 0, toBlock: "latest" })
.then(function(events) {
//
eventsis an array ofevent` objects that we can iterate, like we did above
// This code will get us a list of every zombie that was ever created
});


Are there functions in Web3.js that can help convert a date range to *from* and *to* block numbers needed to cover that date range when calling *getPastEvents()*?  Or is there another method/technique that works directly with dates instead of block numbers?
web3.js
solidity
events
robertoschler
over 1 year ago  Karma: 50
Web3.js function(s) to help determine the block numbers inside a date range?

I'm working through Lesson 6, Chapter 9. In that lesson it talks about subscribing to events and also querying for events within a certain block range:

We can even query past events using getPastEvents, and use the filters fromBlock and toBlock to give Solidity a time range for the event logs ("block" in this case referring to the Ethereum block number):
``
cryptoZombies.getPastEvents("NewZombie", { fromBlock: 0, toBlock: "latest" })
.then(function(events) {
//
eventsis an array ofevent` objects that we can iterate, like we did above
// This code will get us a list of every zombie that was ever created
});


Are there functions in Web3.js that can help convert a date range to *from* and *to* block numbers needed to cover that date range when calling *getPastEvents()*?  Or is there another method/technique that works directly with dates instead of block numbers?
web3.js
solidity
events

Earn tokens by posting and answering questions about blockchain!
Karma to eth
BE THE FIRST TO ANSWER