Skip to main content

Getting Started

1. Clone the Task Template Repository

Begin by cloning the Task Template repository. Once cloned, navigate to the repository directory and execute the following commands to install the required dependencies:

yarn add web3

2. Set Environment Variables

Create a .env file in the root of the repository and populate it with the following environment variables and their respective values:

# Your Infura ID

# The contract address of the deployed token

# The address (public key) of the Ethereum address that deployed the contract

# The private key of the Ethereum address that deployed the contract

# The Ethereum address of the node runner that will execute the task
# Leave this blank; it will be injected before a node runner runs the task

3. Add Contract ABI

Create a new file named KToken.json in the root directory of the project. Copy and paste the contract's ABI (Application Binary Interface) into this file. You can obtain the ABI by following the arrow in the image below:


4. Helper Function

We'll need a helper function to retrieve data from CID, create a new file named helpers.js in the root of the task folder and paste the code below:

const axios = require("axios");
const { Web3Storage } = require("");
const storageClient = new Web3Storage({
token: process.env.SECRET_WEB3_STORAGE_KEY,

async function retrieveFromCid(cid) {
const res = await storageClient.get(cid.replace(/['"]/g, ""));

if (res?.ok) {
const file = await res.files();
const url = `https://${file[0].cid}${file[0].name}`;

try {
const output = await axios.get(url);
} catch (error) {
console.log("ERROR", error);
} else {
return false;
module.exports = { retrieveFromCid };