2.0.2 • Published 4 years ago

@nomiclabs/buidler-ethers v2.0.2

Weekly downloads
893
License
MIT
Repository
github
Last release
4 years ago

npm buidler

buidler-ethers

Buidler plugin for integration with ethers.js.

What

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

Installation

npm install --save-dev @nomiclabs/buidler-ethers 'ethers@^5.0.0'

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

usePlugin("@nomiclabs/buidler-ethers");

Tasks

This plugin creates no additional tasks.

Environment extensions

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

This object has the same API than ethers.js, with some extra Buidler-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): Promise<ethers.ContractFactory>;


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

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

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 Buidler Runtime Environment anywhere you need it (tasks, scripts, tests, etc). For example, in your buidler.config.js:

usePlugin("@nomiclabs/buidler-ethers");

// task action function receives the Buidler Runtime Environment as second argument
task(
  "blockNumber",
  "Prints the current block number",
  async (_, { ethers }) => {
    await ethers.provider.getBlockNumber().then((blockNumber) => {
      console.log("Current block number: " + blockNumber);
    });
  }
);

module.exports = {};

And then run npx buidler blockNumber to try it.

Read the documentation on the Buidler Runtime Environment to learn how to access the BRE in different ways to use ethers.js from anywhere the BRE is accessible.

TypeScript support

You need to add this to your tsconfig.json's files array: "node_modules/@nomiclabs/buidler-ethers/src/type-extensions.d.ts"

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

5 years ago

1.3.4

5 years ago

1.3.4-rc.0

5 years ago

1.3.3

5 years ago

2.0.0-alpha.1

5 years ago

1.3.3-rc.0

5 years ago

1.3.2

5 years ago

2.0.0-alpha.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.3.0-rc.1

5 years ago

1.3.0-rc.0

5 years ago

1.2.0

5 years ago

1.2.0-rc.4

5 years ago

1.2.0-rc.3

5 years ago

1.2.0-rc.2

5 years ago

1.2.0-rc.1

5 years ago

1.2.0-rc.0

5 years ago

1.1.3-rc.0

5 years ago

1.1.1

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.1.0-rc.1

5 years ago

1.1.0-rc.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-rc.2

5 years ago

1.0.0-beta.13

5 years ago

1.0.0-beta.12

5 years ago

1.0.0-beta.11

5 years ago

1.0.0-beta.10

5 years ago

1.0.0-beta.9

5 years ago

1.0.0-beta.8

6 years ago

1.0.0-beta.7

6 years ago

1.0.0-beta.6

6 years ago

1.0.0-beta.4

6 years ago

1.0.0-beta.3

6 years ago

1.0.0-beta.1

6 years ago

1.0.0-alpha.2

6 years ago

1.0.0-alpha.1

6 years ago