File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,12 +3,21 @@ const niceList = require('../utils/niceList.json');
33const MerkleTree = require ( '../utils/MerkleTree' ) ;
44
55const 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
715async 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 } ) ;
Original file line number Diff line number Diff 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
1313app . 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 }
Original file line number Diff line number Diff line change 134134 " Sandra Heller" ,
135135 " James Schuster" ,
136136 " Rodolfo Kessler" ,
137+ " okoedo trust daniel" ,
137138 " Troy Weber" ,
138139 " Edna Raynor I" ,
139140 " Guadalupe Waelchi" ,
You can’t perform that action at this time.
0 commit comments