Mesh LogoMesh

Cookbook

Complete TxBuilder recipes to copy: payments, tokens, scripts, shared signing, servers, staking, governance and tests.

Overview

Each recipe is one complete example for one job, where the task pages explain one part at a time. Recipes take the safe path: a transaction is built once and a retry is the same call on the same object, a transaction from another party is read before you sign it, and transactions that depend on each other go through a plan, or are chained with after. A plan is not atomic: a step may land while the next never does, so read the status of each step.

Before you start

Recipes use the names below, and a builder made like this:

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

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

plan() needs a provider that returns block heights and the validity flag. The plain BlockfrostProvider does not, and plan() throws CANNOT_OBSERVE: see Use Blockfrost for Plans. run() returns when the transaction is in a block. Add { waitFor: "final" } before you release goods or ship an order: see Read the Statuses.

NameWhat it is
builder, providerthe builder above, and the provider it reads through
wallet, partnerWalletthe MeshWallet that pays, and the wallet of the other party
changeAddress, recipient, partneraddresses: the wallet's own, a payee, the other party's
unita policy id plus an asset name in hex
scripta Plutus script, { code, version }
store, dba plan store, and your own list of open payouts: see Server Recipes
validator, wordsthe emulator's TxValidator, and a test wallet's mnemonic: see Test Recipes

Payments

Tokens and NFTs

Scripts

Several Parties

Server Recipes

Staking and Governance

Test Recipes

On this page