how does one go about storing the ERC20 balance value of a contract in a local variable, with the ultimate purpose of using this value for later calculations within the same function?

uint256 varName = ERC20Object.balanceOf(this);

if done locally within a function it will always return 0 regardless of the ERC20Object balance being e.g. 1k-100mil. How to fix this and have varName show the correct number instead of 0?

Your Answer

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

Browse other questions tagged or ask your own question.