In your contract, if you have method that receives an Enum type, how would you pass the arguments from hardhat script?
contract SomeContract {
enum WinStatus {
PENDING,
LOST,
WON
}
WinStatus status;
function updateWinStatus(WinStatus _status) public {
status = _status;
}
}
// in your hardhat script
...
await someContract.updateWinStatus() // how should i call it. bare in mind hardhat is setup using javascript not typescript in my case.
i tried passing a number, hoping it will get it by order(index). But I am getting 'invalid BigNumber value'. Also, I tried passing a string like "PENDING" or "WinType.PENDING" :thinking:
Javascript natively doesn't support very large numbers (up to the uint256
type supported in Solidity), so Ethers.js (included in Hardhat) accepts a BigNumber instance instead.
const myNumber = ethers.BigNumber.from("0") // pass the numeric value as a string
await someContract.updateWinStatus(myNumber) // pass the BigNumber instance