Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ Mesh is an open-source TypeScript and JavaScript SDK for building applications o

With Mesh you can:

- **Build transactions** with `MeshTxBuilder`: send ADA and native tokens, mint and burn NFTs, stake, vote in governance, and spend from Plutus and Aiken scripts.
- **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 with `MeshWallet`.
- **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 the Scalus emulator.
- **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.

Expand All @@ -54,24 +55,33 @@ npm install @meshsdk/core
### Example: send ADA from a browser wallet

```ts
import { BlockfrostProvider, BrowserWallet, MeshTxBuilder } from "@meshsdk/core";
import {
BlockfrostProvider,
BrowserWallet,
output,
TxBuilder,
} from "@meshsdk/core";

const provider = new BlockfrostProvider("<BLOCKFROST_PROJECT_ID>");
const wallet = await BrowserWallet.enable("eternl");

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

const unsignedTx = await txBuilder
.txOut("addr_test1...", [{ unit: "lovelace", quantity: "5000000" }])
.changeAddress(await wallet.getChangeAddress())
.selectUtxosFrom(await wallet.getUtxos())
.complete();

const signedTx = await wallet.signTx(unsignedTx);
const txHash = await provider.submitTx(signedTx);
// 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);
```

Try this and many more transactions interactively in the [Mesh playground](https://meshjs.dev/apis/txbuilder).
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](https://meshjs.dev/apis/txbuilder) walk through payments, minting, scripts, staking and governance, and the [package README](https://github.com/MeshJS/mesh/blob/main/packages/mesh-transaction/README.md) covers every part, option and error.

### Code that uses `MeshTxBuilder`

`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](https://meshjs.dev/apis/txbuilder/migration) maps each old call to its part, and [The old MeshTxBuilder](https://github.com/MeshJS/mesh/blob/main/packages/mesh-transaction/README.md#the-old-meshtxbuilder) lists what changed.

## Packages

Expand All @@ -80,19 +90,22 @@ This monorepo publishes the core Mesh packages to npm under the `@meshsdk` scope
| Package | Description | Docs |
| ------- | ----------- | ---- |
| [@meshsdk/core](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core) | The main entry point. Re-exports transactions, wallets, providers and common utilities. | [Playground](https://meshjs.dev/) |
| [@meshsdk/transaction](https://github.com/MeshJS/mesh/tree/main/packages/mesh-transaction) | `MeshTxBuilder` for sending assets, minting tokens and interacting with smart contracts | [Docs](https://docs.meshjs.dev/transactions) · [Playground](https://meshjs.dev/apis/txbuilder) |
| [@meshsdk/transaction](https://github.com/MeshJS/mesh/tree/main/packages/mesh-transaction) | `TxBuilder` for building, signing and submitting transactions from parts, and plans of several transactions; the deprecated `MeshTxBuilder` | [Docs](https://meshjs.dev/apis/txbuilder) · [API](https://docs.meshjs.dev/transactions) |
| [@meshsdk/wallet](https://github.com/MeshJS/mesh/tree/main/packages/mesh-wallet) | The 1.9 wallets: `BrowserWallet` for CIP-30 browser wallets and `MeshWallet` for signing from a mnemonic or private key | [Docs](https://meshjs.dev/apis/wallets) |
| [@meshsdk/contract](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract) | Open-source smart contracts with off-chain transaction code | [Docs](https://docs.meshjs.dev/contracts) · [Playground](https://meshjs.dev/smart-contracts) |
| [@meshsdk/common](https://github.com/MeshJS/mesh/tree/main/packages/mesh-common) | Shared constants, types and interfaces used across the SDK | [Docs](https://docs.meshjs.dev/common) |
| [@meshsdk/core-cst](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core-cst) | Serialization and utilities built on cardano-js-sdk and Harmonic Labs libraries | [Docs](https://docs.meshjs.dev/core-cst) |
| [@meshsdk/core-cst](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core-cst) | Serialization and utilities built on cardano-js-sdk and Harmonic Labs libraries, and the local script evaluator `OfflineEvaluatorScalus` | [Docs](https://docs.meshjs.dev/core-cst) |
| [@meshsdk/tx-emulator](https://github.com/MeshJS/mesh/tree/main/packages/mesh-tx-emulator) | A local ledger for tests that simulates and submits transactions, alone or in chains, and moves time; a provider for `TxBuilder` | [Docs](https://meshjs.dev/apis/txbuilder/testing) |
| [@meshsdk/scalus-emulator](https://github.com/MeshJS/mesh/tree/main/packages/mesh-scalus-emulator) | Local Cardano ledger emulator built on Scalus, for testing transactions offline | |
| [@meshsdk/x402](https://github.com/MeshJS/mesh/tree/main/packages/mesh-x402) | x402 payments with the Cardano `exact` scheme: client, resource server and facilitator | [Docs](https://meshjs.dev/apis/x402) |

### Packages in other repositories

These `@meshsdk` packages are developed in their own repositories:

| Package | Description | Repository |
| ------- | ----------- | ---------- |
| @meshsdk/wallet | Browser (CIP-30) and headless wallets for managing keys, signing and submitting | [MeshJS/wallet](https://github.com/MeshJS/wallet) |
| @meshsdk/wallet 2.0 (beta) | Browser (CIP-30) and headless wallets for managing keys, signing and submitting | [MeshJS/wallet](https://github.com/MeshJS/wallet) |
| @meshsdk/provider | Blockchain data providers (Blockfrost, Koios, Maestro, Ogmios and more) | [MeshJS/providers](https://github.com/MeshJS/providers) |
| @meshsdk/react | React components and hooks for Cardano wallet connection | [MeshJS/react](https://github.com/MeshJS/react) |
| @meshsdk/hydra | Hydra Head protocol client for layer-2 scaling | [MeshJS/hydra](https://github.com/MeshJS/hydra) |
Expand All @@ -110,7 +123,9 @@ graph TD
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/*"]

Expand All @@ -120,7 +135,10 @@ graph TD
core --> wallet
core --> core_cst
wallet --> transaction
x402 --> wallet
x402 --> transaction
transaction --> core_cst
tx_emulator --> emulator
emulator --> core_cst

subgraph serializers
Expand All @@ -132,9 +150,11 @@ graph TD

click core_cst "https://docs.meshjs.dev/core-cst" _parent
click provider "https://github.com/MeshJS/providers" _parent
click transaction "https://docs.meshjs.dev/transactions" _parent
click wallet "https://github.com/MeshJS/wallet" _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
```

## Cardano smart contracts library
Expand Down Expand Up @@ -179,7 +199,7 @@ npm run build
Contributions of all kinds are welcome: bug fixes, new features, documentation, tests, and help triaging issues and pull requests.

- Read the [contributing guide](https://github.com/MeshJS/mesh/blob/main/CONTRIBUTING.md) and [Code of Conduct](https://github.com/MeshJS/mesh/blob/main/CODE_OF_CONDUCT.md).
- See the [developer docs](https://github.com/MeshJS/mesh/tree/main/docs) for coding and pull request guidelines.
- See the [developer docs](https://github.com/MeshJS/mesh/tree/main/docs) for coding and pull request guidelines, and [docs/design](https://github.com/MeshJS/mesh/tree/main/docs/design) for the design of the transaction builder.
- Report bugs and request features in [GitHub issues](https://github.com/MeshJS/mesh/issues), or ask questions on [Discord](https://discord.gg/dH48jH3BKa).

Using an AI coding assistant? [MeshJS/skills](https://github.com/MeshJS/skills) gives Claude Code, Cursor, Codex and other tools deep knowledge of the Mesh SDK.
Expand Down
Loading