"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 addressesand converts to merkle tree and saves in `lambda-fn/object/quest/data` folder*/asyncfunctioncreate(filename:string) {console.log(`processing file`, filename);constcontent=fs.readFileSync(path.resolve(__dirname,`data/raw/${filename}`), { encoding:"utf-8" });constaddresses:Array<string> = [];content.split(/\r?\n/).forEach(line => {addresses.push(line); });conststrippedFilename=filename.split(".")[0];awaitcreateMerkleTree(addresses,path.resolve(__dirname,`data/upload/${strippedFilename}.merkle`));console.log(`${strippedFilename}.merkle saved`);}// create .merklecreate("SmoothieVoter.csv");
Using .merkle file, we verify requested address
consttree=awaitloadMerkleTreeFromS3(fileName);consthashedAddress=keccak256(address);constrootHash=tree.getRoot().toString("hex");constmerkleProof=tree.getHexProof(hashedAddress);// if result is true, user can get couponconstresult=tree.verify(merkleProof, hashedAddress, rootHash);
If the address is included in the markletree, it will be true and the object can be obtained.