Coder Social home page Coder Social logo

stevewu1234 / merkle-distributor-array Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 273 KB

add a new data format to generate merkle-tree based on uniswap merkle-distributor logic

License: GNU General Public License v3.0

TypeScript 100.00%
array merkle-tree uniswap

merkle-distributor-array's Introduction

@stevewu/merkle-distributor-array

you can find the npm on https://www.npmjs.com/package/merkle-distributor-array

the new merkle tree distributor generator supports three format of original data

  1. ["address"]: string, like the following case:

    {
        "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f": "100"
    }
  2. ["address"]: number, like the following case:

    {
        "0xC7AA922f0823DeE2eD721E61ebCCF2F9596017Fb": 100
    }
  3. ["address"]: string["uint"], like the following case:

    {
        "0x57E7c6B647C004CFB7A38E08fDDef09Af5Ea55eD":
            [
                "1",
                "3463",
                "34527",
                "34252"
            ],
        "0x7C262baf13794f54e3514539c411f92716996C38":
            [
                "1",
                "2456",
                "4"
            ],
    }
  4. ["address"]: string["string"], like the following case:

    {
        "0xF3c6F5F265F503f53EAD8aae90FC257A5aa49AC1":
            [
                "hello world",
                "I'm find, thanks"
            ],
        "0xB9CcDD7Bedb7157798e10Ff06C7F10e0F37C6BdD":
            [
                "how old are u",
                "I'm 9999 years old",
                "666"
            ]
    }

How to user?

After import from merkle-distributor-array, only one function to use:

import { merkletree_generator, MerkleDistributorInfo } from 'merkle-distributor-array';

const generator: MerkleDistributorInfo = merkletree_generator(originalpath: string, generatedpath: string);

originalpath is your target file path, generatedPath is which the generated merkle tree file to save on. The result will return a MerkleDistributorInfo obejct.

the result of the merkle tree generation is the same of uniswap:

{
  "merkleRoot": "0xdefa96435aec82d201dbd2e5f050fb4e1fef5edac90ce1e03953f916a5e1132d",
  "tokenTotal": "0x64",
  "numDrops": 1,
  "claims": { "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f": { "index": 0, "amount": "0x64", "proof": [] } }
}

merkle-distributor-array's People

Contributors

stevewu1234 avatar

Watchers

 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.