JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 137080
  • Score
    100M100P100Q170049F
  • License MIT

Hardhat plugin for ethers that plays well with hardhat-deploy

Package Exports

  • hardhat-deploy-ethers

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hardhat-deploy-ethers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hardhat

hardhat-deploy-ethers

Hardhat plugin for integration with ethers.js.

What

This plugin brings to Hardhat the Ethereum library ethers.js, which allows you to interact with the Ethereum blockchain in a simple way.

it is in based on the existing effort by @nomiclabs : @nomiclabs/hardhat-ethers And add extra functionality and the ability to get signer from address string

Installation

npm install --save-dev hardhat-deploy-ethers ethers

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

import "hardhat-deploy-ethers"

Tasks

This plugin creates no additional tasks.

Environment extensions

This plugins adds an ethers object to the Hardhat Runtime Environment.

This object has add some extra hardhat-deploy specific functionality.

Provider object

A provider field is added to ethers, which is an ethers.providers.Provider automatically connected to the selected network.

Helpers

These helpers are added to the ethers object:

function getContractFactory(name: string, signer?: ethers.Signer | string): Promise<ethers.ContractFactory>;

function getContractFactory(abi: any[], bytecode: ethers.BytesLike, | string, signer?: ethers.Signer | string): Promise<ethers.ContractFactory>;

function getContractAt(nameOrAbi: string | any[], address: string, signer?: ethers.Signer | string): Promise<ethers.Contract>;

function getSigners() => Promise<ethers.Signer[]>;

function getSigner(address: string) => Promise<ethers.Signer>;

function getContract(deploymentName: string, signer?: ethers.Signer | string): Promise<ethers.Contract>;
function getContractOrNull(deploymentName: string, signer?: ethers.Signer | string): Promise<ethers.Contract | null>;

The Contracts and ContractFactorys returned by these helpers are connected to the first signer returned by getSigners be default.

Usage

There are no additional steps you need to take for this plugin to work.

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

It also automatically integrate with the hardhat-deploy plugin if detected

const contract = await hre.ethers.getContract('<deploymentName>');