The app in this repository is a backend for the Merkle Vesting contract found here. It allows creating Merkle trees from a supplied input and saves them in a database. All data is queryable and should make using the Merkle Vesting contract easier and more accessible.
To run the project you need:
- Node.js development environment, version 14.13.1 or newer.
- A file named
club-backend.env
. An example can be found in the project's root folder.
Pull the repository from GitHub, then install its dependencies by executing this command:
npm install
To start the project in production mode:
npm start
Or, to start the project in development mode:
npm run dev
This will start the app on localhost on the port configured in the club-backend.env file.
[POST]
save-list
: generates a Merkle tree based on an input file and saves the claim data mapped to the tree's root (cohortId). The generated root can be used to call the addCohort function of the contract[DELETE]
delete-cohort
: deletes a cohort from the database if it's not already added to the contract
Note: example input files for these endpoints can be found in the project's example directory. Notice they both need a signature (used to verify the caller's account). Signing example using ethers.js:
const message = JSON.stringify(input); // "input" is the data to be signed, i.e. the input list (in the case of save-list) or the cohort ID (in the case of delete-cohort).
const signature = await wallet.signMessage(message);
console.log(signature); // The signature we need.
console.log(ethers.utils.verifyMessage(message, signature)); // Should return the signer's address.
[GET]
hello?name=World
: a test endpoint with an optional parameter[GET]
cohort/:cohortId
: checks if a specific cohort with cohortId exists in the database or the contract. If both are true, returns it's data[GET]
cohort-ids/:account
: returns the IDs of the cohorts the account is in[GET]
claim-data/:cohortId/:account
: returns the claim data for a specific account in a specific cohort (cohortId)[GET]
all-claim-data/:account
: returns the claim data for a specific account from all the cohorts it is in
Note: the claim data are used to call the claim function in the contract.