# Local lab

> Run the example AI SDK agent against a local chain and see its transactions in Jaeger, with no API key.

Source: https://hashspan.dev/docs/local-lab

The repository ships an example agent built with the Vercel AI SDK. It pays a vendor, then tries a withdrawal that reverts, and both transactions show up in its trace. It runs against a local Anvil chain and a scripted model, so it needs no API key.

## Run it

You need Node.js 22.18 or later, pnpm and Docker. With nvm, `nvm install` reads the repository's `.nvmrc` (Node.js 24), installs it if needed and switches to it. The packages themselves only need Node.js 22.3; the higher version is for the repository's build tools.

```sh
git clone https://github.com/selimaytac/hashspan && cd hashspan
nvm install && corepack enable pnpm && pnpm install
make lab-up   # Jaeger UI on http://localhost:16686, OTLP on :4317/:4318
make demo     # runs the agent against a fresh local chain
```

For the metrics, `make lab-metrics` also starts Prometheus and Grafana with a dashboard for the send, confirmation and fee histograms, on http://localhost:3000; run `make demo` after it. The [backends page](https://hashspan.dev/docs/backends#grafana-dashboard-for-the-metrics) explains the dashboard and how to use it elsewhere.

Open Jaeger, pick the `treasury-agent` service and expand `withdraw_from_vault`. The second `confirm 31337` span is marked as an error and carries `blockchain.tx.revert.reason`. [This post](https://hashspan.dev/blog/agent-trace-stops-at-the-tool-call) walks through the same trace, span by span.

## Run it on a testnet

The same agent also runs on Base Sepolia with a test account of your own: `make demo-base-sepolia`. Its spans are named `send 84532` and `confirm 84532`, and each transaction gets a Basescan link. How to set up and fund the account, and keep its key out of the repository, is in the [example's README](https://github.com/selimaytac/hashspan/tree/main/examples/ai-sdk-agent#run-it-on-base-sepolia).

## A real run on Base Sepolia

This is one run of `make demo-base-sepolia` with hashspan 0.8.0, on 2026-10-02. The values come from the confirm spans and match the receipts on chain:

| Transaction | Status | Gas used | Execution fee | L1 data fee | Total fee (`blockchain.tx.fee`) |
|---|---|---|---|---|---|
| [Payment](https://sepolia.basescan.org/tx/0x39ee471a316220689a37d7c1eb41a09add1d24a14c1d49d2eedeadfabcb55820) | success | 21,000 | 126,000,000,000 wei | 7,351,065,046 wei | 133,351,065,046 wei |
| [Withdrawal](https://sepolia.basescan.org/tx/0x580fcb5b0a2493aecc5217226677ae44c50abecabfcb677abb4c63b1782cf68a) | reverted | 21,630 | 129,780,000,000 wei | 7,351,065,046 wei | 137,131,065,046 wei |

The withdrawal's confirm span carries `blockchain.tx.revert.reason` `WithdrawalLimitExceeded(10000000000000, 20000000000000)`. On the local chain there is no L1 data fee; on Base Sepolia it is about 5.5% of the payment's total fee. Every setup run so far is listed on [Tested setups](https://hashspan.dev/docs/tested).

## Clean up

```sh
make lab-pause   # stop, keep state
make lab-nuke    # remove containers, images, tools and build output
```

The example's code is in [`examples/ai-sdk-agent`](https://github.com/selimaytac/hashspan/tree/main/examples/ai-sdk-agent).
