0

Im communicating with a smart contract trying to get the balances from a list of addresses. I then want to get the sum of all balances but I am stuck on actually creating the array to store all the balances.. I need a type of big.Int but have no idea how to create it for my array. so far my code is:

balances := make([]int, 0)

for _, address := range getAddresses {
    getAddressBalance, err := token.BalanceOf(&bind.CallOpts{Pending: true}, address)
    balances = append(balances, getAddressBalance)
}

and the error i get is

cannot use getAddressBalance (type *big.Int) as type int in append

0

Import the math/big native Go package and change the type from int to *big.Int:

balances := make([]*big.Int, 0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.