Demo repo showing a basic OpenZeppelin Defender "fast-pause" setup for automated incident response.
Defender lets you configure Sentinels for monitoring transactions on your contracts, which you can configure to automatically fire a script you load into an Autotask. As part of that script, you can send a pause transaction to your contracts via a Relayer, which is a private key assigned to your team and managed by Defender in a secure keyvault, with some goodies built in like EIP1559 support, nonce management, gas price estimation, and automatic retries.
Link to Guide on OpenZeppelin Docs
contracts
: Standard pausable ERC20 contract implementing role-based access control, generated using Wizard apiscripts
: Custom scripts for Relayer creation, ERC20 contract generation and deployment, uploading the Autotask and creating the Sentinelsrc/autotasks
: Theindex.js
file to be loaded into Defender as an Autotask. When triggered by the Sentinel, the Autotask runs the pause function on the contract using the Relayer
generate
: Generates a pausable ERC20 contract with role-based access control using OpenZeppelin Contracts Wizard APIdeploy
: Deploys the ERC20 contract and adds it to Defender Admin dashboardrelay
: Creates a Relayer, used to run blockchain transactions via APIautotask
: Creates an Autotask that runspause
on the deployed ERC20 contract using the Relayersentinel
: Creates a Sentinel that triggers the Autotask if a high volume token transfer is detected
Expected .env
in project root:
PRIVATE_KEY
: For contract deployment on Goerli networkAPI_KEY
: Defender team API keyAPI_SECRET
: Defender team API secret
The following additional values will be appended to .env
after running the relevant creation/deployment scripts:
AUTOTASK_ID
CONTRACT_NAME
CONTRACT_ADDRESS
RELAYER_ID
-
Sign up for Defender
-
Ensure your deployment account is funded with Goerli ETH (via a faucet)
-
Fork the repo
-
Clone your fork and install dependencies:
$ git clone https://github.com/[GitHub username]/pause-guardian.git
$ cd pause-guardian
$ npm install
-
Supply the necessary api keys in your local
.env
file. -
Generate a pausable ERC20 contract with role-based access control using OpenZeppelin Contracts Wizard API:
$ npm run generate
-
Deploy the ERC20 contract and add it to Defender Admin dashboard:
$ npm run deploy
-
Create a Relayer to run blockchain transactions via API:
$ npm run relay
-
Assign the pauser role to the Relay via Defender UI. From the Admin dashboard, select the contract, then New Proposal --> Modify Access. On the next screen, select the PAUSER role from the dropdown, and supply the address of the Relayer just created. Select EOA as the execution strategy and select the address of the accout used to deploy the contract. Give the access proposal a title and execute it.
-
Create an Autotask that runs
pause
on the deployed ERC20 contract using the Relayer.$ npm run autotask
-
Create a Sentinel that triggers the Autotask if a high volume token transfer is detected
$ npm run sentinel