---
title: "Mesh for AI Coding Agents"
description: "What an AI coding agent needs to write correct Mesh code: install, current package versions, canonical TxBuilder snippets, and where to read more."
url: https://meshjs.dev/ai/agents
markdown: https://meshjs.dev/ai/agents.md
lastModified: 2026-12-03
---

# Mesh for AI Coding Agents

What an AI coding agent needs to write correct Mesh code: install, current package versions, canonical TxBuilder snippets, and where to read more.

This page is written for AI coding agents such as Claude Code, Cursor, Codex and ChatGPT, and for the people who set them up. It is short on purpose: read it first, then fetch the pages it links to as needed.

## Rules

- **Prefer `TxBuilder`.** Build every new transaction with `TxBuilder` and its parts (`output`, `mint`, `spend`, ...). `MeshTxBuilder`, the chain of calls, is legacy: it still works, but do not write new code with it. To convert existing code, see [Migrating to TxBuilder](https://meshjs.dev/apis/txbuilder/migration).
- **Use the docs, not memory.** Mesh 2.0 changed the transaction API. Code from training data that calls `txOut(...)`, `changeAddress(...)` and `complete()` on a builder is the legacy API.
- **Amounts are `bigint`.** Write `5_000_000n`, not `5000000`.
- **Never rebuild to retry.** Call `submit()` again on the same `BuiltTx`; see [Errors](https://meshjs.dev/apis/txbuilder/errors).
- **Wallets:** see [Wallets](https://meshjs.dev/apis/wallets) for how to connect a browser wallet or create a server-side wallet. This page shows no wallet code.

## Install

```bash
npm install @meshsdk/core
```

For React apps, add the React package:

```bash
npm install @meshsdk/react
```

## Package Versions

| Package                | Version on npm |
| ---------------------- | -------------- |
| `@meshsdk/core`        | 2.0.0          |
| `@meshsdk/transaction` | 2.0.0          |
| `@meshsdk/wallet`      | 2.0.0          |
| `@meshsdk/react`       | 2.0.0-beta.2   |

`@meshsdk/core` re-exports `@meshsdk/transaction`, `@meshsdk/wallet` and the providers, so most code imports from `@meshsdk/core` only. Check the current version with `npm view @meshsdk/core version`.

## Canonical Snippets

These come from [Transaction Basics](https://meshjs.dev/apis/txbuilder/basics) and [Mint and Burn Assets](https://meshjs.dev/apis/txbuilder/minting). They use `provider` (a provider such as `BlockfrostProvider`, see [Providers](https://meshjs.dev/providers)), `wallet` (see [Wallets](https://meshjs.dev/apis/wallets)), and `recipient`, an address.

### Create a Builder

```tsx
import { TxBuilder } from "@meshsdk/core";

const builder = new TxBuilder({ network: "preprod", provider });
```

### Send Lovelace

```tsx
import { output } from "@meshsdk/core";

const built = await builder.build(
  output({ address: recipient, value: { lovelace: 5_000_000n } }),
  { payer: wallet },
);
await built.sign(); // the payer signs
await built.submit({ submitter: wallet }); // the wallet sends it
const { slot } = await built.awaitInclusion(); // found in a block
```

The builder selects inputs, adds change and sets the fee. `build()` signs and sends nothing; `built.tx` is the unsigned transaction as CBOR hex and `built.txHash` is known before signing.

### Mint a Token with a Native Script

```tsx
import { ForgeScript, mint, stringToHex } from "@meshsdk/core";

const changeAddress = await wallet.getChangeAddress();
const forgingScript = ForgeScript.withOneSignature(changeAddress);

const built = await builder.build(
  mint.native({
    script: forgingScript,
    assets: { [stringToHex("MeshToken")]: 1n },
  }),
  { payer: wallet },
);
```

A negative quantity burns. Sign and submit as above.

### Handle Errors

Every error of `TxBuilder` is a `TxError` with a `code`. Check the code, not the message, with `TxError.is(error, "CODE")`. The [Errors](https://meshjs.dev/apis/txbuilder/errors) page lists every code and which ones a retry can fix.

## Where to Read More

- [TxBuilder](https://meshjs.dev/apis/txbuilder) and the [Cookbook](https://meshjs.dev/apis/txbuilder/cookbook): recipes for payments, tokens, scripts, staking and governance
- [Errors](https://meshjs.dev/apis/txbuilder/errors): every error code and what to do about it
- [llms.txt](https://meshjs.dev/llms.txt): an index of every page, each linked as plain markdown. Add `.md` to any docs URL for its markdown; [llms.txt](https://meshjs.dev/ai/llms-txt) explains the section files.
- [MCP Server](https://meshjs.dev/ai/mcp): search and read these docs from your agent, at `https://meshjs.dev/mcp`, no API key
- [Agent Skills](https://meshjs.dev/ai/skills): installable Mesh skills for coding agents
- [Examples](https://github.com/MeshJS/examples): complete example apps
