MCPcopy Create free account
hub / github.com/DOSNetwork/core / GetBalance

Function GetBalance

onchain/eth_helpers.go:301–312  ·  view source on GitHub ↗

GetBalance returns the wei balance of the given account.

(client *ethclient.Client, key *keystore.Key)

Source from the content-addressed store, hash-verified

299
300// GetBalance returns the wei balance of the given account.
301func GetBalance(client *ethclient.Client, key *keystore.Key) (balance *big.Float, err error) {
302 wei, err := client.BalanceAt(context.Background(), key.Address, nil)
303 if err != nil {
304 return
305 }
306
307 balance = new(big.Float)
308 balance.SetString(wei.String())
309 balance = balance.Quo(balance, big.NewFloat(math.Pow10(18)))
310
311 return
312}

Callers 1

BalanceMethod · 0.85

Calls 2

SetStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected