Mesh SDK API Reference
Build Cardano applications with Mesh's comprehensive SDK for wallets, transactions, data handling, and utilities.
Overview
The Mesh SDK provides everything you need to build Cardano applications: wallet integrations, transaction builders, data serialization, and utility functions. Choose the APIs that fit your use case.
Quick Start
npm install @meshsdk/coreimport { MeshTxBuilder, BlockfrostProvider } from "@meshsdk/core";
import { MeshCardanoBrowserWallet } from "@meshsdk/wallet";
// Connect to a browser wallet
const wallet = await MeshCardanoBrowserWallet.enable("eternl");
// Initialize provider and transaction builder
const provider = new BlockfrostProvider("<YOUR_API_KEY>");
const txBuilder = new MeshTxBuilder({ fetcher: provider });
// Build and submit a transaction
const utxos = await wallet.getUtxosMesh();
const changeAddress = await wallet.getChangeAddressBech32();
const unsignedTx = await txBuilder
.txOut("addr_test1...", [{ unit: "lovelace", quantity: "5000000" }])
.changeAddress(changeAddress)
.selectUtxosFrom(utxos)
.complete();
const signedTx = await wallet.signTx(unsignedTx, false);
const txHash = await wallet.submitTx(signedTx);API Categories
| Category | Purpose | Key Classes |
|---|---|---|
| Wallets | Connect and interact with user wallets | MeshCardanoBrowserWallet, MeshCardanoHeadlessWallet |
| Transaction Builder | Construct and customize transactions | MeshTxBuilder |
| Transaction Parser | Parse and test transaction data | MeshTxParser, TxTester |
| Data | Handle Cardano data types and conversions | MeshValue, JSON/Mesh formats |
| Utilities | Serialize, deserialize, and resolve data | Serializers, deserializers, resolvers |
Wallets
Connect to browser extension wallets (CIP-30) or create server-side wallets for backend applications.
// Browser wallet (frontend)
import { MeshCardanoBrowserWallet } from "@meshsdk/wallet";
const wallet = await MeshCardanoBrowserWallet.enable("eternl");
// Headless wallet (backend)
import { MeshCardanoHeadlessWallet, AddressType } from "@meshsdk/wallet";
const wallet = await MeshCardanoHeadlessWallet.fromMnemonic({
networkId: 0,
walletAddressType: AddressType.Base,
fetcher: provider,
mnemonic: ["..."],
});Transaction Builder
Build any type of Cardano transaction with fine-grained control over inputs, outputs, metadata, and scripts.
import { MeshTxBuilder } from "@meshsdk/core";
const txBuilder = new MeshTxBuilder({ fetcher: provider });
const unsignedTx = await txBuilder
.txOut(recipient, [{ unit: "lovelace", quantity: "5000000" }])
.mint("1", policyId, assetName)
.mintingScript(forgingScript)
.metadataValue(721, metadata)
.changeAddress(changeAddress)
.selectUtxosFrom(utxos)
.complete();Learn more about Transaction Builder →
Data Handling
Work with Cardano's data types and convert between different formats.
import { MeshValue, mConStr0 } from "@meshsdk/core";
// Work with multi-asset values
const value = new MeshValue();
value.addAsset({ unit: "lovelace", quantity: "5000000" });
// Create Plutus data
const datum = mConStr0([pubKeyHash]);Utilities
Serialize addresses, deserialize transactions, and resolve various Cardano identifiers.
import {
deserializeAddress,
serializeNativeScript,
resolveScriptHash
} from "@meshsdk/core";
// Get key hash from address
const { pubKeyHash } = deserializeAddress(address);
// Create and serialize a native script
const { address, scriptCbor } = serializeNativeScript(nativeScript);
// Get policy ID from script
const policyId = resolveScriptHash(forgingScript);Available APIs
Wallets
Connect CIP-30 browser wallets and create server-side wallets for Cardano dApps.
Transaction Builder
Build and sign Cardano transactions with automatic UTXO selection and fee calculation.
Transaction Parser
Parse Cardano transactions from CBOR, run unit tests, and rebuild with modifications.
Providers
Connect to Cardano via Blockfrost, Koios, Ogmios, Maestro, or UTxO RPC with a unified API.
Utilities
CBOR serializers, bech32 resolvers, and Cardano data type converters for off-chain code.
React Components
Pre-built React wallet UI components and hooks for Cardano dApp frontends.
Smart Contracts Lib
Production-ready Cardano smart contracts with TypeScript SDK, full docs, and live demos.
Aiken
Write Cardano smart contracts in Aiken and build off-chain code with Mesh SDK.
Hydra
Build fast, low-cost Cardano apps with Hydra Layer 2 state channels.
Yaci
Spin up a local Cardano devnet for testing smart contracts and transactions.
Midnight
Build privacy-preserving dApps with zero-knowledge proofs on the Midnight Network.
Related
- Providers - Connect to blockchain data sources
- React Integration - UI components and hooks for React apps
- Smart Contracts - Pre-built contract interactions
- Guides - Step-by-step tutorials