diff --git a/account.go b/account.go index 48c149b..823f018 100644 --- a/account.go +++ b/account.go @@ -144,3 +144,15 @@ func (c *Client) TokenBalance(contractAddress, address string) (balance *BigInt, err = c.call("account", "tokenbalance", param, &balance) return } + +// AddressTokenBalance gets the BEP-20 tokens and amount held by an address. +func (c *Client) AddressTokenBalance(address string, page int, offset int) (balance []TokenBalance, err error) { + param := M{ + "address": address, + "page": page, + "offset": offset, + } + + err = c.call("account", "addresstokenbalance", param, &balance) + return +} diff --git a/go.mod b/go.mod index 0a30134..ea9b52a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,9 @@ -module github.com/nanmu42/etherscan-api +module github.com/farukuzun/etherscan-api go 1.13 + +require ( + github.com/nanmu42/etherscan-api v1.5.0 +) + +replace github.com/nanmu42/etherscan-api => github.com/farukuzun/etherscan-api v1.5.0 \ No newline at end of file diff --git a/response.go b/response.go index b1338d3..518d0ef 100644 --- a/response.go +++ b/response.go @@ -25,6 +25,12 @@ type AccountBalance struct { Balance *BigInt `json:"balance"` } +// TokenBalance token and its balance in pair +type TokenBalance struct { + TokenContractAddress string `json:"token_contract_address"` + Balance *BigInt `json:"balance"` +} + // NormalTx holds info from normal tx query type NormalTx struct { BlockNumber int `json:"blockNumber,string"`