I use OpenZeppelin Clones library, method
cloneDeterministic, which accepts
bytes32 salt argument. There are some questions, I am uncertain.
- I use unsigned integer as salt, which is
numberin js. What is a proper way to convert js
const salt = 99; const saltByte32 = web3.eth.abi.encodeParameter('bytes32'', salt); // returns error
I can’t find any documentation where it is clearly stated which js types could be converted to corresponding solidity types, however the error is clear about the fact, that js
number is impossible to convert to
- I tried a workaround and converted my js
const salt = 99; const saltUint256 = web3.eth.abi.encodeParameter('uint256', salt);
Now contract, which requires
bytes32 argument works if I pass
saltUint256. However that’s kind of unexplicit and I am not sure, whether that is a proper way to convert things. Does solidity treat
uint256 numbers as
bytes32 and it is safe to to so?