Code Monkey home page Code Monkey logo

club-backend's Introduction

Seed Club Merkle Vesting Backend

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.

Requirements

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.

Usage

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.

Endpoints

Owner-only

  • [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.

General

  • [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.

club-backend's People

Contributors

tomiohl avatar dependabot[bot] avatar d3vl0per avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.