Skip to content

Commit 95939a0

Browse files
committed
Balance as string
Signed-off-by: Lap Ngo <[email protected]>
1 parent 5adb18a commit 95939a0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

account.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
package etherscan
99

1010
// AccountBalance gets ether balance for a single address
11-
func (c *Client) AccountBalance(address string) (balance *BigInt, err error) {
11+
func (c *Client) AccountBalance(address string) (balance string, err error) {
1212
param := M{
1313
"tag": "latest",
1414
"address": address,
1515
}
16-
balance = new(BigInt)
1716
err = c.call("account", "balance", param, balance)
1817
return
1918
}
@@ -29,6 +28,17 @@ func (c *Client) MultiAccountBalance(addresses ...string) (balances []AccountBal
2928
return
3029
}
3130

31+
// MultiAccountBalance gets ether balance for multiple addresses at specific block in a single call
32+
func (c *Client) MultiAccountBalanceAt(blockNo int, addresses []string) (balances []AccountBalance, err error) {
33+
param := M{
34+
"tag": blockNo,
35+
"address": addresses,
36+
}
37+
balances = make([]AccountBalance, 0, len(addresses))
38+
err = c.call("account", "balancemulti", param, &balances)
39+
return
40+
}
41+
3242
// NormalTxByAddress gets a list of "normal" transactions by address
3343
//
3444
// startBlock and endBlock can be nil
@@ -120,7 +130,7 @@ func (c *Client) UnclesMinedByAddress(address string, page int, offset int) (min
120130
}
121131

122132
// TokenBalance get erc20-token account balance of address for contractAddress
123-
func (c *Client) TokenBalance(contractAddress, address string) (balance *BigInt, err error) {
133+
func (c *Client) TokenBalance(contractAddress, address string) (balance string, err error) {
124134
param := M{
125135
"contractaddress": contractAddress,
126136
"address": address,

response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ type Envelope struct {
2121

2222
// AccountBalance account and its balance in pair
2323
type AccountBalance struct {
24-
Account string `json:"account"`
25-
Balance *BigInt `json:"balance"`
24+
Account string `json:"account"`
25+
Balance string `json:"balance"`
2626
}
2727

2828
// NormalTx holds info from normal tx query

0 commit comments

Comments
 (0)