0

I have an ERC20Votes contracts on Sepolia Arbitrum testnet.

https://sepolia.arbiscan.io/address/0xc5A117C14F6117CB3870a628e02D2827B5E69471#readContract

Why does the clock() function return the Sepolia Ethereum testnet block number, instead of the Sepolia Arbitrum testnet block number? You can test it for yourself in the link above.

This is breaking the Openzeppelin governor contracts on Arbitrum, as the clock function is returning a block number in the past, making any new voting proposals end at a block number before the proposal start block.

1 Answer 1

0

To get these Governance contracts to work for rollup blockchains (Arbitrum, Optimism etc) you have to override the clock in your ERC20Votes.sol to use time-based milestones instead of block-based milestones. More information here:

https://docs.openzeppelin.com/contracts/4.x/governance#token_2

Here is the code change to override the clock correctly:


    // Overrides IERC6372 functions to make the token & governor timestamp-based

    function clock() public view override returns (uint48) {
        return uint48(block.timestamp);
    }

    // solhint-disable-next-line func-name-mixedcase
    function CLOCK_MODE() public pure override returns (string memory) {
        return "mode=timestamp";
    }

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.