npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@uma/merkle-distributor

v1.3.40

Published

Simple script for dealing with Merkle distribution contracts and proofs hosted on IPFS

Downloads

1,530

Readme

@uma/merkle-distributor

This package contains a number of scripts and helper functions for dealing with merkle token distribution.

Installing the package

yarn add @uma/merkle-distributor

Generating merkle proofs

There are two main scripts that need to be run in turn to build the merkle proofs and add the root on-chain.

First, ingest the payout information and recipients to build the merkle proofs by running:

ts-node ./scripts/1_CreateClaimsForWindow.ts -input ./scripts/example.json

To see the expected structure of this file see example.json within scripts. This script will add a file to the proof-files directory that contains amended information, including the merkle root and proofs for each recipient.

Next, this file is injected by the second script which will pin the claims to IPFS, upload to cloudflare KV and add the root of the merkle tree to the distributor smart contract. Note the following requirements before running the second script:

  1. the unlocked account running the script is the owner of the merkleDistributor OR an account with permissions to set merkle roots.
  2. the account running the script has sufficient rewards tokens to seed the merkleDistributor.
  3. you have set the CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_NAMESPACE_ID and CLOUDFLARE_TOKEN env variables.
  4. (optional) you have set the PINATA_SECRET_API_KEY and PINATA_API_KEY environment variables.

Once you have met these criteria you can upload your merkle proof information by running the following:

ts-node ./scripts/2_PublishClaimsForWindow.ts -input ./proof-files/chain-id-42-reward-window-0-claims-file.json --merkleDistributorAddress 0xAfCd2405298C2FABB2F7fCcEB919B4505A6bdDFC --network kovan_mnemonic

Using the merkle helpers

The main helper script is MerkleDistributorHelper.ts. This script provides two main methods that can be consumed when working with merkle proofs.

  1. createMerkleDistributionProofs(recipientsData, windowIndex: number) takes in an object mapped between recipient address, amount and metaData and returns the provided data with appended merkle proof and the merkleRoot of the merkle tree.
  2. getClaimsForAddress(merkleDistributorAddress, claimerAddress, chainId) takes in the address of the merkleDistributor, a claimerAddress and a chainID and returns a data structure containing all information for the claimer on the provided chainId, including the merkkleproofs, if the rewards has been claimed and additional information about the each claim window such as the IPFS hash for the claims file. This helper will require the associate Cloudflare environment variables.

Note that these methods are designed to run in node exclusively and will not run in the browser. To access the getClaimsForAddress in the browser, it is recommended to wrap this method in a serverless function, such as Vercel. This will protect your cloudflare API keys and enable some ingress verification.