Go Ethereum Block By Date
Get Ethereum block number by a given date.
Works with any Ethereum based mainnet or testnet networks.
Works with go-ethereum
This package is inspired and ported from ethereum-block-by-date.js
Installation
go get github.com/Tech-engine/goethblockbydate
Usage
package main
import (
"github.com/Tech-engine/goethblockbydate"
"log"
"fmt"
)
func main() {
// get node url
goethblockbydate.SetNode("YOUR_INFURA_OR_ANY_OTHER_NODE_URL")
// ISO 8601 datestring. Ex: 2021-03-01T05:30:00+05:30, 2021-03-01T00:00:00Z
block, err := goethblockbydate.GetDate("2021-02-05T00:00:00Z", true)
if err != nil {
log.Fatal(err)
}
fmt.Println(block.BlockNumber)
}