๐ŸฆทWhitelist

A simple and reliable way is whitelist address check

"Whitelist" is used to verify a list of specific addresses at a certain point.This is used for activities such as voting on SmoothieVoter/Gitcoin or using a our testnet demo app (These activities take place in the past).

- SmoothieVoter

We have created a quest of SmoothieVoters(csv) who voted for the PHI.

Using SmoothieVoter csv, we create Merkletree to speed up the verification process.

import * as fs from "fs";
import * as path from "path";
import { createMerkleTree } from "../lambda-fn/object/helpers/merkleTree";

/*
data is a list of addresses
and converts to merkle tree and saves in `lambda-fn/object/quest/data` folder
*/

async function create(filename: string) {
  console.log(`processing file`, filename);
  const content = fs.readFileSync(path.resolve(__dirname, `data/raw/${filename}`), { encoding: "utf-8" });

  const addresses: Array<string> = [];
  content.split(/\r?\n/).forEach(line => {
    addresses.push(line);
  });

  const strippedFilename = filename.split(".")[0];
  await createMerkleTree(addresses, path.resolve(__dirname, `data/upload/${strippedFilename}.merkle`));

  console.log(`${strippedFilename}.merkle saved`);
}

// create .merkle
create("SmoothieVoter.csv");

Using .merkle file, we verify requested address

const tree = await loadMerkleTreeFromS3(fileName);
const hashedAddress = keccak256(address);
const rootHash = tree.getRoot().toString("hex");
const merkleProof = tree.getHexProof(hashedAddress);

// if result is true, user can get coupon
const result = tree.verify(merkleProof, hashedAddress, rootHash);

If the address is included in the markletree, it will be true and the object can be obtained.

Last updated