Keep3r Network: OpenZeppelin | defender

Image for post
Image for post

The goal with Keep3r is simple, create an agnostic, easy to implement, incentivization layer for routine ecosystem maintenance.

Keepers, as described in the documentation, are technical users, capable of implementing bots and/or scripts and running these in some scheduled manner (cronjobs, tasks managers).

With OpenZeppelin | defender, this is no longer a requirement. We will walk through how to set up a keeper in a few simple steps, earning passive rewards, and not needing to worry about maintenance again.

Prerequisites

Step 1: Setup Relayer

Image for post
Image for post

Select fill in a and select , that simple.

Step 2: Setup Autotask

Image for post
Image for post

Select , choose a for your task, select how often you would like it to execute for , select your (created in the previous step, this is optional). And enter your code snippet. As example, lets look at UniswapV2Oracle;

Image for post
Image for post
const workableAbi = <contract ABI>;
const workableAddr = <contract address>;
const from = <from address>;
const { ethers } = require("ethers");
const { DefenderRelaySigner } = require('defender-relay-client/lib/ethers');
// Entrypoint for the Autotask
exports.handler = async function(credentials) {
const provider = ethers.getDefaultProvider('mainnet');
const signer = new DefenderRelaySigner(credentials, provider, { speed: 'fastest', from });
const contract = new ethers.Contract(workableAddr, workableAbi, signer);
// Run work if needed
if (await contract.updateable()) {
const tx = await contract.work();
console.log(tx.hash);
}
}

For UniswapV2Oracle, there are two important calls;

  1. returns a boolean if calling would be successful.
  2. which does the maintenance job and rewards KP3R

Below is an example transaction;

Image for post
Image for post

Save the Autotask, and we are done;

Image for post
Image for post

The task will execute every minute, call and if it can update, it will call

That simple.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store