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

hardhat-deal

v3.0.3

Published

🎩🪄 Easily deal any amount of any ERC20 tokens to any account on the hardhat network

Downloads

299

Readme

hardhat-deal

npm package Build Status Downloads Issues Commitizen Friendly Semantic Release

This plugin allows the developer to deal arbitrary amount of ERC20 tokens to any account on the hardhat network, to ease test development. The storage value of the mapping balanceOf is manipulated in order to manipulate the balance of the given user.

The plugin is shipped with a list of storage slots, which enable faster deals. Additionnally, the developer can provide a mapping of storage slots on custom ERC20s or edit the hardhat configuration on-the-fly (for example when deploying custom ERC20s during tests). If the ERC20 is not found in the configuration, the plugin automatically tries to brute-force the storage slot of the mapping balanceOf, and throws an error if it cannot.

Installation

npm install hardhat-deal
yarn add hardhat-deal

Import the plugin in your hardhat.config.js:

require("hardhat-deal");

Or if you are using TypeScript, in your hardhat.config.ts:

import "hardhat-deal";

Usage

Testing

import { deal } from "hardhat-deal";

const lusd = "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0";
const user = "0x7Ef4174aFdF4514F556439fa2822212278151Db6";
const amount = "10000000000000000000"; // 10 LUSD

// Deal 10 LUSD to the user
await deal(lusd, user, amount);

// Optionnally provide a last parameter specifying how far to brute-force the storage slot (default: 12)
await deal(lusd, user, amount, 15);

Standalone task

This plugin also provides a task deal that can be called with hardhat to deal ERC20 tokens on a separate hardhat node:

npx hardhat deal <recipient> <ERC20 symbol or address> <amount> --network localhost

For example:

npx hardhat deal <recipient> WETH 2000000000000000000 --network localhost

Run npx hardhat deal --help to see the list of supported ERC20 symbols.

Configuration

This plugin extends HardhatUserConfig object with an optional dealSlots field, allowing one to customize the default storage slots used to deal ERC20 tokens, for faster usage (because the plugin no longer needs to brute-force the ERC20 storage slot).

This is an example of how to set it:

module.exports = {
  networks: {
    // If using an external network, you can optionnally provide a custom rpc endpoint to manipulate the network's storage.
    tenderly: {
      rpcEndpoints: {
        setStorageAt: "tenderly_setStorageAt",
      },
    },
  },
  dealSlots: {
    "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0": 2, // LUSD
  },
};