New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hardhat-cli-utils

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hardhat-cli-utils

Hardhat command line utilities

  • 0.0.2
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Hardhat CLI Utils

This package contains many predefined hardhat tasks to help you play with smart contracts by CLI.

TaskDescription
deployDeploy contract.
readCall (read) the method of contract on given address
writeCall (write) the method of contract on given address
nonceGet the nonce of given account
bytecodeGet the runtime byte code on given contract address
initcodeGet the creation byte code (excluding constructor parameters part)
digResolve given ENS domain name

Installation

npm install --save-dev hardhat-cli-utils

And add the following statement to your hardhat.config.js:

require("hardhat-cli-utils");

Or, if you are using TypeScript, add this to your hardhat.config.ts:

import "hardhat-cli-utils";

Usage by Examples

Let's suppose you have Box contract in your hardhat project.

contract Box {
    uint private value;
    constructor(uint initValue)  {
        value  = initValue;
    }
    function getValue() public view returns(uint) {
        return value;
    }
    function setValue(uint newValue) public {
        value = newValue;
    }
}

And you have set up a test-net environment, in our example, Goerli.

// hardhat.config.js or hardhat.config.js
const config = {
    networks: {
        goerli: {
            url: "REPLACE_THIS_WITH_YOUR_RPC_URL",
            accounts: ["REPLACE_THIS_WITH_YOUR_PRIVATE_KEY"]
        },
}
  • deploy

    Run with npx hardhat --network <network> deploy <class> [...params].

    On success, the address of contract created is outputted.

    $ npx hardhat --network goerli deploy Box 123
    0xb62208Cf91f8654D1Baa7Af12d1C6f7ad655dcd8
    
  • read

    Run with npx hardhat --network <network> read <class> <address> <method> [...params].

    On success, the returned result is showed.

    $ npx hardhat --network goerli read Box 0xb62208Cf91f8654D1Baa7Af12d1C6f7ad655dcd8 getValue
    Return:  BigNumber { value: "123" }
    
  • write

    Run with npx hardhat --network <network> write <class> <address> <method> [...params].

    On success, it output the link to view this transaction on Etherscan . If there are events emitted during this transaction, then the events are showed.

    $ npx hardhat --network goerli write Box 0xb62208Cf91f8654D1Baa7Af12d1C6f7ad655dcd8 setValue 456
    View this tx at https://goerli.etherscan.io/tx/0x32e051dc4f3d20395b00b3715a23e908d5eaa4010ba237214f385676ff3c80bd
    No event emitted.
    Done!
    
  • nonce

    Run with npx hardhat --network <network> nonce <address>.

    Output the nonce of given account.

    $ npx hardhat --network goerli nonce 0xb62208Cf91f8654D1Baa7Af12d1C6f7ad655dcd8
    1
    
  • etc.

    For usage of other more tasks, run npx hardhat <task> --help.

    $ npx hardhat bytecode --help
    $ npx hardhat initcode --help
    $ npx hardhat dig --help
    

Looking for other features?

Keywords

FAQs

Package last updated on 24 Aug 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc