I need to store the IRR (internal rate of return) of a project in my smart contract.

Since Solidity can't store decimals it must be saved as an integer.

Which of these options would be better and why:

  1. Save only the return (in tokens) and calculate the rate/percentage outside the contract.
  2. Represent the percentage in the same way decimals on tokens are stored, i.e. by multiplying by 10 ** decimals().

Or is there a better way?


1 Answer 1


Just use fixed point maths, so option 2. Just use it to represent values between 0 and 1 with the accuracy you need (it's much easier than working with actual percentage). To get percentage, just pultiply that number by 100.

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.