Prool

0.2.4 · active · verified Wed Apr 22

Prool is a TypeScript-first library designed to provide programmatic HTTP testing instances for various Ethereum components. It enables developers to spin up local execution nodes (like Anvil and Tempo) and ERC-4337 bundler nodes (like Alto) within testing environments such as Vitest. The library is currently at version `0.2.4` and maintains an active release cadence with frequent patch and minor updates. A key differentiator is its focus on streamlining the setup and teardown of these instances for reliable, isolated tests, abstracting away the complexities of managing external processes or Docker containers. Users can utilize pre-configured instances or define custom ones to suit specific testing needs, requiring Node.js >=22. It integrates with `testcontainers` for containerized instances.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to create and manage an Anvil execution node instance using Prool, including starting and stopping the server, and noting required external dependencies.

import { Instance, Server } from 'prool';

// NOTE: Requires Foundry to be installed globally:
// `curl -L https://foundry.paradigm.xyz | bash`

async function runAnvilServer() {
  const server = Server.create({
    instance: Instance.anvil(),
    port: 8545 // Optional, default is 8545
  });

  try {
    console.log('Starting Anvil server...');
    await server.start();
    console.log('Anvil server started successfully!');
    console.log('Instances accessible at:');
    // Access the base URL for instances, e.g., for direct RPC calls
    // `server.url` returns 'http://localhost:8545/'
    // The specific instances are accessed via paths, e.g., 'http://localhost:8545/1'
    console.log(`  Base URL: ${server.url}`);
    console.log('  Example instance URL: http://localhost:8545/1');

    // Simulate some work or keep it running for a test suite
    await new Promise(resolve => setTimeout(resolve, 5000)); // Keep alive for 5 seconds

  } catch (error) {
    console.error('Failed to start Anvil server:', error);
  } finally {
    console.log('Stopping Anvil server...');
    await server.stop();
    console.log('Anvil server stopped.');
  }
}

runAnvilServer();

view raw JSON →