Socket
Socket
Sign inDemoInstall

@nomiclabs/hardhat-web3

Package Overview
Dependencies
506
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nomiclabs/hardhat-web3

Hardhat plugin for using Web3 1.x


Version published
Weekly downloads
9.5K
decreased by-4.26%
Maintainers
3
Install size
412 kB
Created
Weekly downloads
 

Readme

Source

npm hardhat

hardhat-web3

This plugin integrates Web3.js 1.x into Hardhat.

What

This plugin brings to Hardhat the Web3 module and an initialized instance of Web3.

Installation

npm install --save-dev @nomiclabs/hardhat-web3 web3

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

require("@nomiclabs/hardhat-web3");

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

import "@nomiclabs/hardhat-web3";

Tasks

This plugin creates no additional tasks.

Environment extensions

This plugin adds the following elements to the HardhatRuntimeEnvironment:

  • Web3: The Web3.js module.
  • web3: An instantiated Web3.js object connected to the selected network.

Usage

Install it and access Web3.js through the Hardhat Runtime Environment anywhere you need it (tasks, scripts, tests, etc). For example, in your hardhat.config.js:

usePlugin("@nomiclabs/hardhat-web3");

// task action function receives the Hardhat Runtime Environment as second argument
task("accounts", "Prints accounts", async (_, { web3 }) => {
  
  console.log(await web3.eth.getAccounts());
  
});

module.exports = {};

And then run npx hardhat accounts to try it.

Read the documentation on the Hardhat Runtime Environment to learn how to access the HRE in different ways to use Web3.js from anywhere the HRE is accessible.

Keywords

FAQs

Last updated on 22 Oct 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc