# @nomiclabs/buidler-ethers

> Buidler plugin for ethers

Latest version **2.0.2** (published 2020-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nomiclabs/buidler-ethers
pnpm add @nomiclabs/buidler-ethers
yarn add @nomiclabs/buidler-ethers
bun add @nomiclabs/buidler-ethers
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-10-03 |
| First published | 2019-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8505 |
| Author | Nomic Labs LLC |
| Maintainers | fvictorio, alcuadrado, fzeoli |
| Keywords | ethereum, smart-contracts, buidler, buidler-plugin, ethers.js |

## Links

- npm: https://www.npmjs.com/package/@nomiclabs/buidler-ethers
- Repository: https://github.com/nomiclabs/buidler
- Homepage: https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ethers
- Issues: https://github.com/nomiclabs/buidler/issues
- npm.io page: https://npm.io/package/@nomiclabs/buidler-ethers

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2020-10-03
- 1.3.4-rc.0 (rc) — 2020-06-11
- 2.0.0-alpha.1 (next) — 2020-05-10
- 2.0.1 — 2020-10-03
- 2.0.0 — 2020-06-24
- 1.3.4 — 2020-06-18
- 1.3.3 — 2020-05-10
- 1.3.3-rc.0 — 2020-05-05
- 1.3.2 — 2020-05-02
- 2.0.0-alpha.0 — 2020-04-28
- 1.3.1 — 2020-04-28
- 1.3.0 — 2020-04-18
- 1.3.0-rc.1 — 2020-04-10
- 1.3.0-rc.0 — 2020-04-06
- 1.2.0 — 2020-02-27
- … 25 more at https://npm.io/package/@nomiclabs/buidler-ethers/versions

## README

[![npm](https://img.shields.io/npm/v/@nomiclabs/buidler-ethers.svg)](https://www.npmjs.com/package/@nomiclabs/buidler-ethers)
[![buidler](https://buidler.dev/buidler-plugin-badge.svg?1)](https://buidler.dev)

# buidler-ethers

[Buidler](http://getbuidler.com) plugin for integration with [ethers.js](https://github.com/ethers-io/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

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

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

```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:

```typescript
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 `Contract`s and `ContractFactory`s 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`:

```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](https://buidler.dev/advanced/buidler-runtime-environment.html) 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"`

---
_Source: https://npm.io/package/@nomiclabs/buidler-ethers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
