1

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

1 Answer 1

1

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 and acknowledge you have read our privacy policy.

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