From 7f9e154a6a196fed5b167ffb4f32e5858589da21 Mon Sep 17 00:00:00 2001 From: chrisx9z <287960381+chrisx9z@users.noreply.github.com> Date: Sat, 6 Jun 2026 19:19:33 +0700 Subject: [PATCH] Add viem test client example Comment: Shows how to point viem's Anvil test client at a prool-managed instance endpoint. --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b018d80..9beb70e 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,31 @@ await server.start() // "http://localhost:8545/n" ``` +#### Viem Test Client + +```ts +import { Instance, Server } from 'prool' +import { createTestClient, http } from 'viem' +import { foundry } from 'viem/chains' + +const server = Server.create({ + instance: Instance.anvil(), +}) +await server.start() + +const client = createTestClient({ + chain: foundry, + mode: 'anvil', + transport: http('http://localhost:8545/1'), +}) + +await client.mine({ blocks: 1 }) +``` + +The server lazily starts the Anvil instance for `/1` when the test client sends +its first request. To start it eagerly, request `http://localhost:8545/1/start` +before creating the client. + ### Tempo (Execution Node) #### Requirements @@ -264,4 +289,4 @@ const instance_3 = await pool.start(3) ## License -[MIT](/LICENSE) License \ No newline at end of file +[MIT](/LICENSE) License