From 4d96adaec3844840fb61c16a0811a4779af7d0b7 Mon Sep 17 00:00:00 2001 From: farukuzun Date: Mon, 22 Nov 2021 14:59:11 +0300 Subject: [PATCH 1/3] Adds `Get Address BEP20 Token Holding` for bscscan --- account.go | 12 ++++++++++++ response.go | 6 ++++++ 2 files changed, 18 insertions(+) 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/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"` From 46b72dcb6a2b35b4231c949f57a525c3573881c9 Mon Sep 17 00:00:00 2001 From: farukuzun Date: Mon, 22 Nov 2021 15:02:30 +0300 Subject: [PATCH 2/3] Update module --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0a30134..3d0d198 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/nanmu42/etherscan-api +module github.com/farukuzun/etherscan-api go 1.13 From ce9216d6bcddcaca022876cda848f259b74609f3 Mon Sep 17 00:00:00 2001 From: farukuzun Date: Mon, 22 Nov 2021 15:09:54 +0300 Subject: [PATCH 3/3] Update module --- go.mod | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go.mod b/go.mod index 3d0d198..ea9b52a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,9 @@ 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