Mesh LogoMesh

Data

Parse and manipulate Cardano data types for smart contract development

MeshJS provides comprehensive utilities for working with Cardano data. Use these tools to construct datums, redeemers, and other on-chain data structures in multiple formats.

Overview

Cardano smart contracts require data in specific formats. MeshJS supports three data representation formats:

FormatBest ForDescription
Mesh DataQuick prototypingSimple JavaScript primitives with minimal wrappers
JSON DataWeb3 applicationsStrong type validation for frontend-backend communication
CBORInteroperabilityRaw binary format for cross-library compatibility

Quick Start

Install the MeshJS SDK:

npm install @meshsdk/core

Choose your preferred data format:

// Mesh Data format - simple and quick
import { mConStr0, mConStr1 } from "@meshsdk/core";
const datum = mConStr0(["owner-key-hash", 1000000n]);

// JSON Data format - validated types
import { conStr0, byteString, integer } from "@meshsdk/core";
const datum = conStr0([byteString("owner-key-hash"), integer(1000000)]);

Browse Data APIs

When to Use Each Format

Use Mesh Data When

  • You need to quickly prototype smart contract interactions
  • You want minimal boilerplate code
  • You are comfortable with JavaScript primitives

Use JSON Data When

  • You need strong input validation
  • You are building production web applications
  • You want type safety for complex data structures

Use CBOR When

  • You are integrating with other serialization libraries
  • You need the raw binary representation
  • You are working with data from external sources

On this page