From 094c3054bf0843b93d199d2f416d574fc1d0b5e6 Mon Sep 17 00:00:00 2001 From: lisen Date: Sat, 2 Apr 2022 10:48:50 +0800 Subject: [PATCH] support tokens --- response.go | 2 +- tokens.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tokens.go diff --git a/response.go b/response.go index 692867d..d61b9da 100644 --- a/response.go +++ b/response.go @@ -126,6 +126,7 @@ type ContractSource struct { CompilerVersion string `json:"CompilerVersion"` OptimizationUsed int `json:"OptimizationUsed,string"` Runs int `json:"Runs,string"` + Proxy int `json:"Proxy,string"` ConstructorArguments string `json:"ConstructorArguments"` Library string `json:"Library"` SwarmSource string `json:"SwarmSource"` @@ -170,4 +171,3 @@ type Log struct { LogIndex string `json:"logIndex"` Removed bool `json:"removed"` } - diff --git a/tokens.go b/tokens.go new file mode 100644 index 0000000..b5074ba --- /dev/null +++ b/tokens.go @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018 LI Zhennan + * + * Use of this work is governed by a MIT License. + * You may find a license copy in project root. + */ + +package etherscan + +// TokenSupply gets token supply +func (c *Client) TokenSupply(address string) (balance *BigInt, err error) { + param := M{ + "contractaddress": address, + } + balance = new(BigInt) + err = c.call("stats", "tokensupply", param, &balance) + return +} + +// TokenCSupply gets token circulating supply +func (c *Client) TokenCSupply(address string) (balance *BigInt, err error) { + param := M{ + "contractaddress": address, + } + balance = new(BigInt) + err = c.call("stats", "tokenCsupply", param, &balance) + return +}