hardhat-container

This project provides a Docker image for running Hardhat in a container for toolchain isolation.

MPL-2.0 License

Downloads
767
Stars
1

Hardhat Container

This library provides a Docker image for running Hardhat in a container for toolchain isolation. This is particularly useful for language-agnostic development and parallelization of systems.

Initially created for use in fuxingloh/chainfile.

hardhat-testcontainers

This is a standalone testcontainers-node package for running Hardhat in a container for testing purposes. You don't need to use the Chainfile ecosystem to use this package.

npm i -D hardhat-testcontainers viem
import { HardhatContainer, StartedHardhatContainer } from 'hardhat-testcontainers';
import { createPublicClient, http, PublicClient } from 'viem';
import { hardhat } from 'viem/chains';

let container: StartedHardhatContainer;

beforeAll(async () => {
  container = await new HardhatContainer().start();
});

afterAll(async () => {
  await container.stop();
});

it('should rpc(eth_blockNumber) via viem', async () => {
  const client = createPublicClient({ chain: hardhat, transport: http(container.getHostRpcEndpoint()) });

  const blockNumber = await client.getBlockNumber();
  expect(blockNumber).toStrictEqual(BigInt(0));
});

License

MPL-2.0

Package Rankings
Top 39.64% on Npmjs.org