Giter Site home page Giter Site logo

fairdrop-backend's Introduction

fairdrop-backend

Database

Backend expects a mongodb. Connection parameters are read from /config.js

unique constraint

There should never be multiple claims for one address. This can be enforced on database level by creating a unique index on the address field. Execute the following command in the mongo shell:

db.claiminfos.createIndex({"address": 1}, {unique: true})

Endpoints

RegistrationInfo

Returns timestamps for registration and claim phases

GET /registrationInfo

ClaimInfo

Returns the leaf of the merkletree for the provided address.

GET /claimInfo/<address>

This returns a string that should be parsed into a JSON object.

Example:

{"leaf":"{\"index\":0,\"address\":\"0x107D1198854fbbcB2E1014c3FFAb166b2595586a\",\"amount\":{\"type\":\"BigNumber\",\"hex\":\"0xe91a7cd19fa3b00000\"},\"proof\":[\"0x2f9f7c38292f1225434f3997a71bf792d09f6d8ddf8e7d999e1ed06a1131d7e1\",\"0xe7226ab75194ec5d59c88bea0b119eef9602cdba6751944076d3fcceb4fd8fd1\",\"0xd352978a87a93a8c60ae9b2fbb092dcdb709a8a83d4c9267347deeb1dc459d46\",\"0x0aaeacaad59bdd4028a97315da2815ceb9b6359abdd746555ad884134dd5a731\"]}"}

"leaf" contents parsed into JSON:

{
    "index": 0,
    "address": "0x107D1198854fbbcB2E1014c3FFAb166b2595586a",
    "amount": {
      "type": "BigNumber",
      "hex": "0xe91a7cd19fa3b00000"
    },
    "proof": [
      "0x2f9f7c38292f1225434f3997a71bf792d09f6d8ddf8e7d999e1ed06a1131d7e1",
      "0xe7226ab75194ec5d59c88bea0b119eef9602cdba6751944076d3fcceb4fd8fd1",
      "0xd352978a87a93a8c60ae9b2fbb092dcdb709a8a83d4c9267347deeb1dc459d46",
      "0x0aaeacaad59bdd4028a97315da2815ceb9b6359abdd746555ad884134dd5a731"
    ]
}

Address

Get info about an address:

  • What is preferred chainId for payouts
  • What amount is expected to be available in the next claimperiod

GET /address/<address>

Change preferred chainId:

Requires a signed message to proof ownershop of address.

POST /address/<address>

Expected post payload:

{
  "chainId": 123,
  "signature": "signature string"
}

Utility scripts

/scripts folder contains two scripts:

setRegistrationInfo.ts

Use this to set the timestamps for

  • end of current registration
  • start of next claim phase
  • start of next registration phase

setNextAmount.ts

Use this to set the expected amount claimable for an an address in the next claim period.

To run the scripts use ts-node.

Example: ts-node scripts/setNextAmount.ts 0xc44E4c49Ffa5Db98CA52770dff3e371ECB01f2D9 16000000000000000000

fairdrop-backend's People

Contributors

adamstallard avatar rnbwd avatar triplespeeder avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.