← Back to blog

OpenZeppelin Pausable: The Kill Switch for Your Smart Contract

Published on
•
1 mins read
•
--- views

In blockchain you must be able to stop the chaos. Sometimes you could not think of everything, and at some point the mechanisms you built in fail. One mechanism is still left then: a switch that turns things on and off.

Slide "Access Control Design Patterns: Pausable" with a token example built on OpenZeppelin, Devconnect 2025

This slide was shown at Devconnect 2025, held in Buenos Aires, Argentina.

Pausable in OpenZeppelin

That is what the Pausable mechanism and interface in the OpenZeppelin library are for. On the slide above it is added to an ERC20 token through ERC20Pausable. Only the holder of PAUSER_ROLE can pause and unpause the contract, and functions marked whenNotPaused do not run while it is paused:

function pause() public onlyRole(PAUSER_ROLE) {
    _pause();
}

function unpause() public onlyRole(PAUSER_ROLE) {
    _unpause();
}

function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) whenNotPaused {
    _mint(to, amount);
}

Never Forget the Switch

I strongly recommend Pausable to every smart contract developer. Never forget about it: when everything else has already failed, it is the one thing that lets you stop the contract.

Open for contract collaboration

I am available for contract-based collaboration. If you have an interesting project idea, schedule a call via Calendly.

Schedule a 30-min call