# Introduction

> hashspan records every on-chain transaction an AI agent or service sends as OpenTelemetry spans, inside its own trace.

Source: https://hashspan.dev/docs

hashspan is an open-source TypeScript library that turns each transaction an AI agent sends into OpenTelemetry spans, keyed by the transaction hash, inside the agent's own trace. It works the same for a TypeScript service that sends EVM transactions through viem, the Coinbase CDP SDK, x402 or MPP (mppx), or through a [wallet service](https://hashspan.dev/docs/integrations#wallet-services), such as a payment or payout worker. Other libraries, such as ethers, have no adapter, and chains other than EVM are not supported.

Figure: Jaeger showing a reverted confirm 31337 span inside an agent trace, with blockchain.tx.status, the fee, gas used and the decoded revert reason WithdrawalLimitExceeded

An agent's reverted transaction, as a confirm span in its own trace (Jaeger, from the [local lab](https://hashspan.dev/docs/local-lab)).

Know OpenTelemetry but not blockchains? Start with [hashspan for OpenTelemetry engineers](https://hashspan.dev/docs/otel-engineers): the spans, the schema status, the Collector setup and seven words you'll meet. Not on TypeScript? The same page lists what you can reuse from any language.

## What you get

- A `send {chainId}` span when the hash comes back, and a linked `confirm {chainId}` span when the receipt arrives.
- Status (`success`, `reverted`, `replaced`; a wait that gives up ends with `error.type` `timeout`, and a transaction a chain reorganisation removed ends with `not_on_chain`), block, gas used and the fee, including the L1 data fee on OP-stack chains.
- The decoded revert reason for mined reverts.
- For x402 and MPP, a `payment {chainId}` span per paid request: what was paid, to whom and whether it settled. With a reader, a linked `confirm` span adds block, gas and fees of the settling transaction, and `blockchain.payment.verified` says whether that transaction carries the payment.
- The agent's identity (`gen_ai.agent.id`, `gen_ai.agent.name`) on every transaction span, when there is an agent.
- Optionally, a span per JSON-RPC request with `traceTransport()`, and send, confirmation and fee histograms when an OpenTelemetry metrics SDK is set up.

The spans nest under whatever span is active when the transaction is sent, usually your agent framework's `execute_tool` span, or the request or job span of a service. They go to the tracing backend you already use: Jaeger, Grafana Tempo, Langfuse, Honeycomb or any OTLP endpoint.

## Packages

| Package | Use it for |
|---|---|
| [`@hashspan/viem`](https://hashspan.dev/docs/adapters/viem) | Agents and services that send with viem wallet clients ([what the trace looks like](https://hashspan.dev/docs/viem-opentelemetry)) |
| [`@hashspan/cdp`](https://hashspan.dev/docs/adapters/cdp) | Agents and services that send with Coinbase CDP server accounts |
| [`@hashspan/x402`](https://hashspan.dev/docs/adapters/x402) | Agents that pay for API calls with x402 |
| [`@hashspan/mpp`](https://hashspan.dev/docs/adapters/mpp) | Agents that pay for API calls with MPP, through mppx (0.x, follows mppx's minor lines) |
| [`@hashspan/core`](https://hashspan.dev/docs/adapters/core) | Any other send path; the tracker every adapter uses |

## What it doesn't do

hashspan never signs or broadcasts transactions, and it doesn't alert. It records what happened so you can read it next to the agent's decisions.

It doesn't slow your calls much either: on a local chain it added about 0.25 ms per transaction at p50 and one JSON-RPC request, none when you pass the nonce ([tracing overhead benchmark](https://hashspan.dev/docs/benchmarks/tracing-overhead)).

## New to OpenTelemetry?

The [Learn](https://hashspan.dev/learn) pages explain spans, attributes, context and sampling in a few minutes each, every one on a real agent run. [Your agent's trace stops at the tool call](https://hashspan.dev/blog/agent-trace-stops-at-the-tool-call) shows the problem hashspan solves, end to end.

**Next:**
Trace your first transaction in the [Quickstart](https://hashspan.dev/docs/quickstart), or run the [local lab](https://hashspan.dev/docs/local-lab) without an API key.
