We return the type long from the method GetBalance.
This means that we can't return a balance larger than 9223372036854775807 Wei which is equivalent to just above 9 Ether.
We should consider using a type that can hold larger numbers. There are some different options.
ulong
ulong can hold equivalent to just above 18 Ether which is better, but still just pushes the problem a tiny bit.
decimal
decimal can hold whole numbers equivalent to around 79228000000 Ether which is much better. The drawback is that decimal can also hold numbers that are not whole which might confuse people who use the project. decimal was created specifically for work with currencies, but the high precision in cryptocurrencies might not be suitable for this.
BigInteger
BigInteger can hold arbitrarily big whole numbers. The problem with BigInteger is that it does not play as nice with other types like decimal, float, etc. as it doesn't do implicit conversions when used in common operations like multiply, divide, add, subtract, etc.
Conclusion
I think the best option is BigInteger. Other libraries that work with cryptocurrencies also use this.
If you would like this change, then I can make a PR.
We return the type
long
from the methodGetBalance
.This means that we can't return a balance larger than
9223372036854775807
Wei which is equivalent to just above9
Ether.We should consider using a type that can hold larger numbers. There are some different options.
ulong
ulong
can hold equivalent to just above18
Ether which is better, but still just pushes the problem a tiny bit.decimal
decimal
can hold whole numbers equivalent to around79228000000
Ether which is much better. The drawback is thatdecimal
can also hold numbers that are not whole which might confuse people who use the project.decimal
was created specifically for work with currencies, but the high precision in cryptocurrencies might not be suitable for this.BigInteger
BigInteger
can hold arbitrarily big whole numbers. The problem withBigInteger
is that it does not play as nice with other types like decimal, float, etc. as it doesn't do implicit conversions when used in common operations like multiply, divide, add, subtract, etc.Conclusion
I think the best option is
BigInteger
. Other libraries that work with cryptocurrencies also use this.If you would like this change, then I can make a PR.