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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adisakboonmark/hardhat-task-gen

v0.1.9-beta

Published

Create Tasks from ABI in Hardhat

Downloads

44

Readme

hardhat-task-gen

Overview

hardhat-task-gen is a Hardhat plugin that automatically generates tasks from ABI files. This allows you to easily interact with smart contracts without manually defining Hardhat tasks.

Features

  • Auto-generates Hardhat tasks from contract ABIs
  • Supports overloaded functions with numbered suffixes
  • Allows configurable task prefixes
  • Handles payable functions with optional parameters
  • Provides clear CLI commands for contract interactions

Installation

npm install --save-dev @adisakboonmark/hardhat-task-gen

Usage

  1. Add the plugin to your Hardhat config (hardhat.config.ts or hardhat.config.js):
import "@adisakboonmark/hardhat-task-gen";

// or

require("@adisakboonmark/hardhat-task-gen");
  1. Run the task generation command:
$ npx hardhat task-gen
  1. Use the generated tasks to interact with your contracts:
$ npx hardhat task-gen:MyERC20:transfer --contract-address 0x123...456 --to 0xabc...123 --amount 1000

$ npx hardhat task-gen:MyERC721:name --contract-address 0x123...456

$ npx hardhat task-gen:MyERC1155:balanceOfBatch --contract-address 0x123...456 --accounts '["0xabc...123","0xabc...456"]' --ids '[0,1]'
  1. Run the helper command:
$ npx hardhat task-gen:MyERC1155:balanceOfBatch --help
Hardhat version 2.22.18

Usage: hardhat [GLOBAL OPTIONS] task-gen:MyERC1155:balanceOfBatch --accounts <STRING> [--contract-address <STRING>] --ids <STRING>

OPTIONS:

  --accounts            Parameter of type address[] (for tuple and array, provide a JSON string)
  --contract-address    The contract address
  --ids                 Parameter of type uint256[] (for tuple and array, provide a JSON string)

task-gen:MyERC1155:balanceOfBatch: Calls balanceOfBatch function on MyERC1155

For global options help run: hardhat help

Environment Variables

ABI Directory

The plugin reads ABI files from the directory specified by the environment variable:

process.env.ABI_DIRECTORY || "./artifacts/contracts/"

If ABI_DIRECTORY is not set, it defaults to ./artifacts/contracts/.

Default Contract Address

When executing a generated task, the contract address is determined using:

const contract = new hre.ethers.Contract(
  taskArgs.contractAddress || process.env.TASK_GEN_CONTRACT_ADDRESS,
  contractABI,
  signer
);

If TASK_GEN_CONTRACT_ADDRESS is not set, you must provide the contract address explicitly using --contract-address.

Configuration

You can customize the task generation by modifying your Hardhat config:

module.exports = {
  taskGen: {
    outPath: "./tasks-generated", // Specify the output path for generated tasks.
    clear: true, // Clear existing artifacts before generating the tasks, and it will force-run compilation. 
    runOnCompile: false, // Generate tasks automatically on each compile.
    prefix: "task-gen", // Set a custom task prefix.
  },
};

Example Overloaded Commands

For a contract named MyERC1155 with overloaded functions totalSupply() and totalSupply(uint256):

npx hardhat task-gen:MyERC1155:transfer:1         # Calls the totalSupply() function
npx hardhat task-gen:MyERC1155:transfer:2 --id 0  # Calls the totalSupply(uint256) function

Example Commands Document

Full Version Example Document

📜 Hardhat Contract Commands

AwesomeCat

| Function Name | Parameters | Outputs | Command | |---------------|------------|---------|---------| | breed | catA tuple[id (uint256),gender (uint8)], catB tuple[id (uint256),gender (uint8)] | newCat tuple[id (uint256),gender (uint8)] | npx hardhat task-gen:AwesomeCat:breed:1 --contract-address <contractAddress:optional> --cat-a <catA> --cat-b <catB> | | breed | catIdA (uint256), catIdB (uint256) | newCat tuple[id (uint256),gender (uint8)] | npx hardhat task-gen:AwesomeCat:breed:2 --contract-address <contractAddress:optional> --cat-id-a <catIdA> --cat-id-b <catIdB> | | breedBatch | catIdsA (uint256[]), catIdsB (uint256[]) | newCats tuple[[id (uint256),gender (uint8)]] | npx hardhat task-gen:AwesomeCat:breedBatch:1 --contract-address <contractAddress:optional> --cat-ids-a <catIdsA> --cat-ids-b <catIdsB> | | breedBatch | catsA tuple[[id (uint256),gender (uint8)]], catsB tuple[[id (uint256),gender (uint8)]] | newCats tuple[[id (uint256),gender (uint8)]] | npx hardhat task-gen:AwesomeCat:breedBatch:2 --contract-address <contractAddress:optional> --cats-a <catsA> --cats-b <catsB> | | cats | catId (uint256) | id (uint256), gender (uint8) | npx hardhat task-gen:AwesomeCat:cats --contract-address <contractAddress:optional> --cat-id <catId> | | craftGender | | output1 (uint8) | npx hardhat task-gen:AwesomeCat:craftGender --contract-address <contractAddress:optional> | | exists | catId (uint256) | output1 (bool) | npx hardhat task-gen:AwesomeCat:exists --contract-address <contractAddress:optional> --cat-id <catId> | | mintCat | | output1 tuple[id (uint256),gender (uint8)] | npx hardhat task-gen:AwesomeCat:mintCat --contract-address <contractAddress:optional> | | owners | owner (address) | id (uint256), gender (uint8) | npx hardhat task-gen:AwesomeCat:owners --contract-address <contractAddress:optional> --owner <owner> | | parents | catId (uint256) | father tuple[id (uint256),gender (uint8)], mother tuple[id (uint256),gender (uint8)] | npx hardhat task-gen:AwesomeCat:parents --contract-address <contractAddress:optional> --cat-id <catId> |

IMPORTANT

Invalid Casing in Parameter Names (#HH208)

Problem:

Parameters like _type, _amount use underscores, which violate camelCase formatting.

Solution:

Fix this issue by removing underscores from all parameter names to ensure camelCase compliance.