I use OpenZeppilin ERC20Mintable contract and add MaxSupply
parameter to contraint the ERC20 token amount allowed to issue.
what I want is only permit contract ower to view MaxSupply
info, my function is below:
uint256 MaxSupply;//contract static variable
...
// self defined function
function ViewMaxSupply() public view onlyMinter return(uint256) {
return ( MaxSupply* (10 ** uint256(decimals)) );
}
decimals
is equal to 18
.
I found when I use onlyMiner
modifier, the return value is a very strange number: 3963877391197344453575983046348115674221700746820753546331534351508065746944
.
when not use modifier onlyMinter
, the result is correct: 100000000000000000000
How to fix the error? Thanks.
ViewMaxSupply
? Since it is a view function it doesn't use from so it might be failing and the call doesn't detect it as an invalid answer. – Ismael Aug 13 '19 at 15:17var MaxIssueAmount = await contract.methods.ViewMaxSupply().call();
– Ntydrm Aug 14 '19 at 1:07>npm ls solc solc@0.5.9
, the compiler version in .sol file(pragma solidity ^0.5.0
) is lower, I make no modification. – Ntydrm Aug 14 '19 at 1:17var MaxIssueAmount = await contract.methods.ViewMaxSupply().call({ from: "0xVALID_ADDRESS" })
. – Ismael Aug 14 '19 at 12:28