Skip to content

Commit 5e1eb91

Browse files
committed
1 parent 89317e8 commit 5e1eb91

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

client/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ const niceList = require('../utils/niceList.json');
33
const MerkleTree = require('../utils/MerkleTree');
44

55
const serverUrl = 'http://localhost:1225';
6+
// create the merkle tree for the whole nice list
7+
const merkleTree = new MerkleTree(niceList);
8+
9+
// find the proof that norman block is in the list
10+
const name = "Darren Kunde";
11+
const index = niceList.findIndex(n => n === name);
12+
const proof = merkleTree.getProof(index);
13+
console.log({proof});
614

715
async function main() {
816
// TODO: how do we prove to the server we're on the nice list?
917

1018
const { data: gift } = await axios.post(`${serverUrl}/gift`, {
11-
// TODO: add request body parameters here!
19+
proof,
20+
name
1221
});
1322

1423
console.log({ gift });

server/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ app.use(express.json());
88

99
// TODO: hardcode a merkle root here representing the whole nice list
1010
// paste the hex string in here, without the 0x prefix
11-
const MERKLE_ROOT = '';
11+
const MERKLE_ROOT = '34d7d19b6b2babb3581b95741dd15b114dc6ebe70f03cdba3947d0d3955366cd';
1212

1313
app.post('/gift', (req, res) => {
1414
// grab the parameters from the front-end here
15-
const body = req.body;
15+
const {proof,name} = req.body;
16+
console.log({proof,name});
1617

17-
// TODO: prove that a name is in the list
18-
const isInTheList = false;
18+
// // TODO: prove that a name is in the list
19+
const isInTheList = verifyProof(
20+
proof,
21+
name,
22+
MERKLE_ROOT
23+
);
1924
if(isInTheList) {
2025
res.send("You got a toy robot!");
2126
}

utils/niceList.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"Sandra Heller",
135135
"James Schuster",
136136
"Rodolfo Kessler",
137+
"okoedo trust daniel",
137138
"Troy Weber",
138139
"Edna Raynor I",
139140
"Guadalupe Waelchi",

0 commit comments

Comments
 (0)