Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @nomiclabs/buidler-web3-legacy with all npm packages installed. Try it out:

require("@nomiclabs/buidler/package.json"); // @nomiclabs/buidler is a peer dependency. require("web3/package.json"); // web3 is a peer dependency. var buidlerWeb3Legacy = require("@nomiclabs/buidler-web3-legacy")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@nomiclabs/buidler-web3-legacy v1.3.3

Buidler plugin for using Web3 0.20.x

npm buidler

buidler-web3-legacy

This plugin integrates Web3.js 0.20x into Buidler.

What

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

Installation

npm install --save-dev @nomiclabs/buidler-web3-legacy web3@^0.20.7

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

usePlugin("@nomiclabs/buidler-web3-legacy");

Tasks

This plugin creates no additional tasks.

Environment extensions

This plugin adds the following elements to the BuidlerRuntimeEnvironment:

  • Web3: The Web3.js module.
  • web3: An instantiated Web3.js object connected to the selected network.
  • pweb3: A promisified version of web3.

Usage

In Web3 0.20x some features are synchronous and some are asynchronous. For example web3.eth.accounts and web3.eth.blockNumber are synchronous and not supported. You'll get a Synchronous requests are not supported, use pweb3 instead error when trying to access them. To use these you need to use the promisified web3 and call the getter version of the property instead: await pweb3.eth.getAccounts().

TypeScript support

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free