Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@foundry-rs/hardhat-anvil

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foundry-rs/hardhat-anvil

Hardhat plugin for managing Anvil

  • 0.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

hardhat-anvil

This Hardhat plugin automatically starts and stops Anvil when running tests or scripts.

What

This plugin creates a network named anvil. When this network is used, it can either connect to a running anvil instance or launch a new server automatically before running tests and scripts.

Installation

Anvil binary

See anvil installation

Plugin

npm install --save-dev @foundry-rs/hardhat-anvil

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

require("@foundry-rs/hardhat-anvil");

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

import "@foundry-rs/hardhat-anvil";

Tasks

This plugin hooks into the test.

Environment extensions

This plugin adds a waffle object to the Hardhat Runtime Environment. This object has all the Waffle functionality, already adapted to work with Hardhat.

This is a slightly modified, anvil compatible version of @nomiclabs/hardhat-waffle.

Usage

Once anvil is installed you can simply run it and configure it via the CLI.

Once installed, you can build your tests almost like in Waffle.

Instead of importing things from ethereum-waffle, you access them from the waffle property of the Hardhat Runtime Environment.

Configuration

You can set any of the Anvil's options (or anvil --help) through the anvil network config.

Note: currently only default settings are used if launch: true. All other configs are currently ignored

It's recommend to spawn anvil manually in a separate shell, see also Foundry repo

This example sets a larger block gas limit and the default balance of Anvil's accounts.

module.exports = {
  defaultNetwork: "anvil",
    anvil: {
      url: "http://127.0.0.1:8545/",
      launch: false, // if set to `true`, it will spawn a new instance if the plugin is initialized, if set to `false` it expects an already running anvil instance
    }
  }
};

By default, the anvil object will be configured as

{
  hdPath: "m/44'/60'/0'/0/",
  mnemonic: 'test test test test test test test test test test test junk',
  url: 'http://127.0.0.1:8545/',
  launch: true,
  accounts: {
    mnemonic: 'test test test test test test test test test test test junk',
    path: "m/44'/60'/0'/0/"
  }
}

LICENSE

Keywords

FAQs

Package last updated on 02 Oct 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc