Mesh API
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
Wallets APIs for interacting with the blockchain.
Transaction Builder
Build transactions with cardano-cli like APIs
Transaction Parser
Parse transactions for testing and rebuilding
Providers
Data providers for connecting to the blockchain
Utilities
Serializers, resolvers and data types for converting between different formats.
React Components
Frontend React UI components and React hooks
Svelte Components
Svelte UI components for wallet connections
Smart Contracts Lib
Open-source smart contracts, complete with documentation, and live demos
Aiken
Functional programming language created for Cardano smart contract development
Hydra
Layer 2 scaling solution for Cardano
Yaci
Custom devnet to tailor your devnet needs with a builtin indexer
Midnight
Zero-knowledge privacy network for Cardano
Wallet as a Service
Access self-custodial wallet using social logins
Transaction Sponsorship
Sponsor blockchain transaction fees for your users to eliminate friction.
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