I tried to switch to timeStamp based voting by overriding token contract and adding following
// To Enable TimeStamp based clock instead of block based (default)
function clock() public view virtual returns (uint48) {
return SafeCast.toUint48(block.timestamp);
}
function CLOCK_MODE() public view virtual returns (string memory) {
return "mode=timestamp";
}
But Still on proposal creation i am getting block number for voting start and voting end.
What i am missing?
Note: I have verified contract in bsc Testnet if anyone want to check contract
Well, you've used virtual instead of override, but I'm guessing that's just a technical nuance.
Can you please describe what the actual problem is (i.e., what's not working for you)?
BTW, in the ethereum blockchain, the timestamp remains constant throughout all transactions within the same block, and overall increases in a relatively constant manner between blocks (~12 seconds per block at the time of writing this, ~13 seconds per block at the time of writing this minus one year, etc).
So unless your votes are expected to span over relatively long periods of time, I'd say that using timestamp is pretty synonymous to using block number.
I see you're using contracts from apparently the 4.8.0 version of our library, while the EIP-6372 and EIP-5805 (clock and CLOCK_MODE) were enabled in 4.9.0, this is why you didn't need to specify the override keyword in the functions you added, which means the functions are neither overriding nor used anywhere in the contract, so they have no effect.
I'd recommend you install the most recent version (4.9.2 at the moment of writing) and then override the same way you're doing in your token. This way the override keyword will be required and then the token's clock will be used by the governor.
Thank you @ernestognw I have updated openzepplin/contracts version to 4.9.2,correct token solidity code and its working now.
// To Enable TimeStamp based clock instead of block based (default)
function clock() public view override returns (uint48) {
return SafeCast.toUint48(block.timestamp);
}
function CLOCK_MODE() public pure override returns (string memory) {
return "mode=timestamp";
}