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

@api3/merkle-funder

v0.6.0

Published

This repo contains contracts, scripts and a serverless function that can be used to send funds to addresses based on values from a configuration file

Downloads

19

Readme

merkle-funder

This repo contains contracts, scripts and a serverless function that can be used to send funds to addresses based on values from a configuration file

  • contracts - Smart contracts written in Solidity to manage funds sent to pre-defined addresses using a Merkle tree
  • deploy - Deployment scripts for the hardhat-deploy plugin. Currently there is a single script that deploys the MerkleFunder contract
  • deployments - Parent directory for the hardhat-deploy script output. When MerkleFunder.sol is deployed to a new chain using this script, a new directory with the chain name will be added
  • scripts - Utility scripts to interact with the MerkleFunder contract
  • src - Shared source code and the handler implementation for the serverless function

Prerequisites

  • Node.js >= 18.x
  • Yarn

Installation

yarn install --frozen-lockfile

Building

yarn build

Adding a new chain

Deploy contracts

  1. Run the following script to generate the example.env file:

    yarn env-example:write
  2. Copy example.env to .env

  3. In .env, delete the lines that are related to chains that you will not use. Refer to @api3/chains for more information about the chains.

  4. In .env, populate the MNEMONIC value. This will be used by hardhat-deploy to deploy contracts and by the app you deploy to send transactions to execute fundings.

  5. In .env, populate the FUNDER_RPC_URL_ values. These will be used by the app you deploy.

  6. In .env, populate the ETHERSCAN_API_KEY_ values. These will be used by hardhat-etherscan to verify the contracts you deploy.

  7. Copy config.example.json to config.json and add a new entry using the chain ID as key for the object

  8. Deploy MerkleFunder by running:

    NETWORK=<chainAlias> yarn deploy:merkle-funder

    chainAlias must match one from @api3/chains

  9. Deploy all MerkleFunderDepository contracts by running:

    NETWORK=<chainAlias> yarn deploy:merkle-funder-depositories

Send funds to recipients

After following all steps in previous section, and funding your MerkleFunderDepository contracts, run the following command:

yarn fund <chainName>

This command will trigger funds to be sent to recipients defined in config.json

Deploy serverless function

Another way to trigger funds to be sent from a MerkleFunderDepository to a recipient address is to run the scheduled lambda function on a 1 minute interval

  1. Configure your AWS credentials

  2. Deploy the function by running:

    yarn sls:deploy --stage <stageName>

    Make sure that your environment variables are defined in your .env file.

Remove serverless function

If you want to remove the function from AWS then run the following command:

yarn sls:remove --stage <stageName>

Local development

  • Start a local ethereum node by running yarn hh:node

  • The scripts can be then run using localhost as chainName For example:

    yarn deploy:merkle-funder localhost
    yarn deploy:merkle-funder-depositories localhost
    yarn fund:merkle-funder-depositories localhost
    yarn fund localhost
  • There are 2 ways to test the lambda function locally:

    1. yarn sls:local (uses serverless-offline plugin and this is the closest to actually deploying the function to AWS)
    2. yarn sls:invoke:fundHandler

    In case you want to use different environment variables when testing this function locally then the easiest is to create a .env.dev file which will have precedence over .env when executing either of the two commands. Another alternative is to create a .env.local (or .env.development, etc) and set the stage to local. For example: yarn sls:local --stage local