Skip to content

Future Transaction Cancel#


An admin address can cancel a transaction before it exists using the timelock functionality in Governor.sol.

function _cancelTransaction(
    address target,
    uint256 value,
    bytes memory data,
    uint256 eta
) public {
        msg.sender == admin,
        "Governor::cancelTransaction: Call must come from admin"

    bytes32 txHash = keccak256(abi.encode(target, value, data, eta));
    queuedTransactions[txHash] = false;

    emit CancelTransaction(txHash, target, value, data, eta);

By calling _cancelTransaction on a nonexistent transaction hash, a CancelTransaction event is emitted which might confuse governance UIs.


Validate the transaction is actually queued before enabling cancel.

require(queuedTransactions[txHash], "Transaction not Queued")