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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址