Skip to content
Deterministic Ethereum integration testing for TypeScript and viem
Statecraft

Ethereum integration tests without setup glue code.

Statecraft turns brittle hooks and helper stacks into explicit, typed scenario fixtures with isolated chains per file, so setup stays deterministic and suites run in parallel.

Why teams switch

  • Hidden setup order becomes explicit fixture order in scenario(...).
  • Ad hoc fork setup becomes pinned, deterministic chain state.
  • Independent files can run in parallel on separate runtimes for faster suites.
  • Helper sprawl becomes one readable test pipeline.
import { expect, test } from "vitest";
import { erc20Abi, parseEther } from "viem";
import {
  scenario,
  withChain,
  withFundedWallet,
  withErc20Balance,
} from "@st8craft/core";
 
test(
  "fork + funded wallet + USDC balance",
  scenario(
    withChain(),
    withFundedWallet({ balance: parseEther("1") }),
    withErc20Balance({
      token: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
      amount: parseUnits("1_000_000", 6),
    }),
    async ({ publicClient, walletClient }) => {
      // walletClient now has both 1 ETH and seeded USDC
      const balance = await publicClient.getBalance({ address: walletClient.account.address });
      expect(balance).toBe(parseEther("1"));
    },
  ),
);