goethblockbydate

package module
v0.0.0-...-6db9133 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 9 Imported by: 0

README

Go Ethereum Block By Date

Go Report Card

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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDate

func GetDate(dateStr string, after bool) (*newBlockWrapper, error)

GetDate takes in an ISO 8601 datestring and outputs a block number

func SetNode

func SetNode(url string)

SetNode sets node url

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL