Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@api3/merkle-funder

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@api3/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

latest
npmnpm
Version
0.6.0
Version published
Maintainers
5
Created
Source

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

Prerequisites

  • Node.js >= 18.x
  • Yarn

Installation

yarn install --frozen-lockfile

Building

yarn build

Adding a new chain

Deploy contracts

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

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

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

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

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

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

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

  • Deploy MerkleFunder by running:

    NETWORK=<chainAlias> yarn deploy:merkle-funder
    

    chainAlias must match one from @api3/chains

  • 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

  • Configure your AWS credentials

  • 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:

    • yarn sls:local (uses serverless-offline plugin and this is the closest to actually deploying the function to AWS)

    • 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

FAQs

Package last updated on 01 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts