From 48b5b4f8162de570055a35cdbfd28b6daee82346 Mon Sep 17 00:00:00 2001 From: skyfile Date: Fri, 17 Jul 2020 23:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=8E=B7=E5=8F=96gas=5Fpr?= =?UTF-8?q?ice=20=E5=92=8C=20block=5Fnumber?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geth.go | 25 +++++++++++++++++++++++++ response.go | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 geth.go diff --git a/geth.go b/geth.go new file mode 100644 index 0000000..80c8169 --- /dev/null +++ b/geth.go @@ -0,0 +1,25 @@ +package etherscan + +type geth struct { + Cli *Client + Module string +} + +func (c *Client) Geth() *geth { + return &geth{ + Cli: c, + Module: "proxy", + } +} + +// Returns the current price per gas in wei +func (g *geth) GasPrice() (price GasPrice, err error) { + err = g.Cli.call(g.Module, "eth_gasPrice", M{}, &price) + return +} + +// Returns the number of most recent block +func (g *geth) BlockNumber() (number BlockNumber, err error) { + err = g.Cli.call(g.Module, "eth_gasPrice", M{}, &number) + return +} diff --git a/response.go b/response.go index b1338d3..88dabef 100644 --- a/response.go +++ b/response.go @@ -136,3 +136,19 @@ type LatestPrice struct { ETHUSD float64 `json:"ethusd,string"` ETHUSDTimestamp Time `json:"ethusd_timestamp"` } + +type Geth struct { + Jsonrpc string `json:"jsonrpc"` + Id int64 `json:"id"` + Result interface{} `json:"result"` +} + +type GasPrice struct { + Geth + Result string `json:"result"` +} + +type BlockNumber struct { + Geth + Result string `json:"result"` +}