Mesh: the TypeScript SDK for Cardano
Build Cardano dApps in TypeScript: transactions, wallets, smart contracts and blockchain data in one open-source SDK.
Website & live demos · API docs · Guides · Examples · Discord
Mesh is an open-source TypeScript and JavaScript SDK for building applications on the Cardano blockchain. It handles the hard parts of Cardano development, such as coin selection, fee calculation, CBOR serialization and script evaluation, so you can focus on your app.
With Mesh you can:
- Build transactions with
TxBuilder: describe a transaction as a list of parts (outputs, mints, script spends, certificates, votes and proposals), and the builder selects inputs, adds change, evaluates scripts and sets the fee. - Sign and submit with a browser wallet, a
MeshWallet, a private key or your own signing service, or send several transactions in order as a plan, which a store keeps across restarts. - Connect wallets in the browser through CIP-30 (such as Eternl) with
BrowserWallet, or sign server-side from a mnemonic or private key withMeshWallet. - Use ready-made smart contracts for escrow, marketplaces, vesting, swaps and more, each with on-chain code and off-chain TypeScript.
- Query and submit through Blockfrost, Koios, Maestro, Ogmios, Yaci and other blockchain providers.
- Test offline against a local ledger with
TxEmulator: simulate and submit transactions, see why the ledger would refuse one, and move its clock.
Mesh runs in Node.js, the browser, Next.js and other modern frameworks.
Create a new Cardano dApp from a template with the Mesh CLI:
npx meshjs your-app-nameOr add Mesh to an existing project:
npm install @meshsdk/coreimport {
BlockfrostProvider,
BrowserWallet,
output,
TxBuilder,
} from "@meshsdk/core";
const provider = new BlockfrostProvider("<BLOCKFROST_PROJECT_ID>");
const wallet = await BrowserWallet.enable("eternl");
const builder = new TxBuilder({ network: "preprod", provider });
// Picks the wallet's UTxOs, adds change and sets the fee
const built = await builder.build(
output({ address: "addr_test1...", value: { lovelace: 5_000_000n } }),
{ payer: wallet },
);
await built.sign(); // the wallet signs
await built.submit(); // through the provider
console.log(built.txHash);A transaction is a list of parts, such as output(...), mint.native(...), spend.plutus(...) or certificate.stakeDelegation(...), each checked when it is made. builder.plan(...) builds several transactions at once and sends them in order, without building any of them again. The Transaction Builder docs walk through payments, minting, scripts, staking and governance, and the package README covers every part, option and error.
MeshTxBuilder is deprecated and still works: it now builds on TxBuilder and keeps its chain of calls. Where it used to return a transaction the ledger refuses, such as one with an output below the minimum ADA, it now throws. Migrating to TxBuilder maps each old call to its part, and The old MeshTxBuilder lists what changed.
This monorepo publishes the core Mesh packages to npm under the @meshsdk scope. Most apps only need @meshsdk/core, which re-exports transactions, wallets, providers and common utilities.
| Package | Description | Docs |
|---|---|---|
| @meshsdk/core | The main entry point. Re-exports transactions, wallets, providers and common utilities. | Playground |
| @meshsdk/transaction | TxBuilder for building, signing and submitting transactions from parts, and plans of several transactions; the deprecated MeshTxBuilder |
Docs · API |
| @meshsdk/wallet | The 1.9 wallets: BrowserWallet for CIP-30 browser wallets and MeshWallet for signing from a mnemonic or private key |
Docs |
| @meshsdk/contract | Open-source smart contracts with off-chain transaction code | Docs · Playground |
| @meshsdk/common | Shared constants, types and interfaces used across the SDK | Docs |
| @meshsdk/core-cst | Serialization and utilities built on cardano-js-sdk and Harmonic Labs libraries, and the local script evaluator OfflineEvaluatorScalus |
Docs |
| @meshsdk/tx-emulator | A local ledger for tests that simulates and submits transactions, alone or in chains, and moves time; a provider for TxBuilder |
Docs |
| @meshsdk/scalus-emulator | Local Cardano ledger emulator built on Scalus, for testing transactions offline | |
| @meshsdk/x402 | x402 payments with the Cardano exact scheme: client, resource server and facilitator |
Docs |
These @meshsdk packages are developed in their own repositories:
| Package | Description | Repository |
|---|---|---|
| @meshsdk/wallet 2.0 (beta) | Browser (CIP-30) and headless wallets for managing keys, signing and submitting | MeshJS/wallet |
| @meshsdk/provider | Blockchain data providers (Blockfrost, Koios, Maestro, Ogmios and more) | MeshJS/providers |
| @meshsdk/react | React components and hooks for Cardano wallet connection | MeshJS/react |
| @meshsdk/hydra | Hydra Head protocol client for layer-2 scaling | MeshJS/hydra |
| @meshsdk/midnight-setup | Development setup for Midnight Network dApps | MeshJS/midnight-setup |
| @meshsdk/midnight-contracts-wizard | CLI wizard for new Midnight contract projects | MeshJS/midnight-contracts-wizard |
graph TD
core["@meshsdk/core"]
common["@meshsdk/common"]
core_cst["@meshsdk/core-cst"]
provider["@meshsdk/provider"]
transaction["@meshsdk/transaction"]
wallet["@meshsdk/wallet"]
contract["@meshsdk/contract"]
tx_emulator["@meshsdk/tx-emulator"]
emulator["@meshsdk/scalus-emulator"]
x402["@meshsdk/x402"]
cardano_sdk["@cardano-sdk/*"]
harmoniclabs["@harmoniclabs/*"]
contract --> core
core --> provider
core --> transaction
core --> wallet
core --> core_cst
wallet --> transaction
x402 --> wallet
x402 --> transaction
transaction --> core_cst
tx_emulator --> emulator
emulator --> core_cst
subgraph serializers
core_cst --> cardano_sdk
core_cst --> harmoniclabs
end
core_cst --> common
click core_cst "https://docs.meshjs.dev/core-cst" _parent
click provider "https://github.com/MeshJS/providers" _parent
click transaction "https://meshjs.dev/apis/txbuilder" _parent
click wallet "https://meshjs.dev/apis/wallets" _parent
click contract "https://docs.meshjs.dev/contracts" _parent
click tx_emulator "https://meshjs.dev/apis/txbuilder/testing" _parent
click x402 "https://meshjs.dev/apis/x402" _parent
@meshsdk/contract includes open-source Cardano smart contracts, each with on-chain Aiken code, off-chain TypeScript, documentation and a live demo.
| Contract | What it does | Links |
|---|---|---|
| Content Ownership | A registry where users create content that is recorded on-chain | Demo · Source · Docs |
| Escrow | Holds assets between two parties until both agree to complete the exchange | Demo · Source · Docs |
| Giftcard | Locks assets behind a newly minted gift card token; redeeming burns the token and releases the assets | Demo · Source · Docs |
| Hello World | A simple lock-and-unlock contract to learn end-to-end validation and transaction building | Demo · Source · Docs |
| Marketplace | An NFT marketplace where anyone can list, buy and sell native assets | Demo · Source · Docs |
| NFT Minting Machine | Mints NFTs with an index that increments by one for each new token | Demo · Source · Docs |
| Payment Splitter | Splits incoming payments among a group of addresses | Demo · Source · Docs |
| Swap | Exchanges assets between two parties | Demo · Source · Docs |
| Vesting | Locks tokens until a set time, after which the beneficiary can withdraw them | Demo · Source · Docs |
| Asteria (work in progress) | A bot challenge where ships race across a 2D grid to showcase the eUTxO model | Source |
| Royalties (work in progress) | CIP-102 royalties for NFTs | Source · Docs |
Mesh is a Turborepo monorepo using npm workspaces. You need Node.js 18 or later.
git clone https://github.com/MeshJS/mesh.git
cd mesh
npm install
npm run build| Command | What it does |
|---|---|
npm run build |
Build all packages |
npm run dev |
Build packages in watch mode |
npm test |
Run the test suites |
npm run lint |
Lint all packages |
npm run format |
Check formatting with Prettier (format:fix to apply) |
Contributions of all kinds are welcome: bug fixes, new features, documentation, tests, and help triaging issues and pull requests.
- Read the contributing guide and Code of Conduct.
- See the developer docs for coding and pull request guidelines, and docs/design for the design of the transaction builder.
- Report bugs and request features in GitHub issues, or ask questions on Discord.
Using an AI coding assistant? MeshJS/skills gives Claude Code, Cursor, Codex and other tools deep knowledge of the Mesh SDK.
Mesh is released under the Apache 2.0 License.