Mesh SDK

repository·main·Indexed 43 days ago

https://github.com/meshjs/mesh

An all-in-one TypeScript SDK for building applications on the Cardano blockchain. Mesh provides high-level APIs for wallets, transactions, blockchain data providers, and a library of open-source smart contracts including Escrow, Marketplace, NFT Minting, and Vesting. It includes tools for Aiken-based smart contract development and guidance on avoiding common vulnerabilities such as Unbound Value, Infinite Mint, and Double Satisfaction.

Tokens
64.5K
Snippets
211
Records
286
Agent score
54%

What's inside Mesh

  1. Overview of the Content Ownership contract

    main

    The Content Ownership contract enables the creation of a content registry where users can register and transfer ownership of content (such as files stored on IPFS).

    Key features include:

    • On-chain ownership records: Provides a single source of truth for content ownership.
    • Trustless verification: Uses the blockchain trace to verify who owns specific content.
    • Extensibility: The registry facilitates additional application logic such as royalty distributions and licensing models.
  2. Overview of Mesh SDK packages

    main

    Mesh is composed of several specialized packages for interacting with the Cardano blockchain:

    • @meshsdk/common: Constants, types, and interfaces used across the SDK.
    • @meshsdk/contract: A collection of smart contracts and their associated transactions.
    • @meshsdk/core: The main entry point exporting wallets, transactions, and providers.
    • @meshsdk/core-csl: Utilities for compatibility with cardano-serialization-lib.
    • @meshsdk/core-cst: Utilities for compatibility with cardano-js-sdk.
    • @meshsdk/provider: Blockchain data providers.
    • @meshsdk/react: React component library for building UIs.
    • @meshsdk/transaction: Tools to send assets, mint tokens, and interact with smart contracts.
    • @meshsdk/wallet: Tools to manage assets and interact with the blockchain via wallets.
  3. Overview of @meshsdk/core-csl

    main
    @meshsdk/core-csl is a utility package that provides types and helper functions to bridge the gap between the Mesh SDK and the cardano-serialization-lib (CSL). It is designed to facilitate easier interaction with low-level Cardano serialization primitives within the Mesh ecosystem.
  4. Explore the Mesh Smart Contracts Library

    main

    The Mesh Smart Contracts Library provides a collection of open-source smart contracts designed for various use cases. Each contract includes documentation, live demos, and end-to-end source code to help developers implement secure blockchain logic.

    Available contract types include:

    • Content Ownership: Create a content registry for user-generated content.
    • Escrow: Securely exchange assets via a trusted intermediary.
    • Giftcard: Lock assets into a contract for redemption by any user.
    • Hello World: A basic lock-and-unlock contract for learning transaction building.
    • Marketplace: Enable buying and selling of native assets like NFTs.
    • NFT Minting Machine: Automatically incrementing NFT minting.
    • Payment Splitter: Distribute incoming payments among multiple accounts.
    • Swap: Facilitate asset exchanges between two parties.
    • Vesting: Lock tokens for a specific duration before withdrawal.
  5. Use the NFT Minting Vending Machine smart contract

    main

    The NFT Minting Vending Machine is a Plutus smart contract that allows users to mint NFTs with an automatically incremented index. Each newly minted NFT receives a token name that increases by one based on a counter managed by an oracle.

    You can interact with this contract using three primary actions:

    1. Setup Oracle: Performs a one-time minting policy execution to initialize and set up the oracle.
    2. Mint Token: Mints an NFT where the token name is automatically incremented by the current counter.
    3. Get Oracle Data: Retrieves the current oracle state, which includes the current NFT index and other relevant metadata.
  6. Overview of the Giftcard smart contract

    main

    The Giftcard contract allows users to lock assets into a smart contract via a transaction, which can subsequently be redeemed by any user.

    Workflow:

    1. Create Giftcard: This action mints a token and sends the locked assets to the contract.
    2. Redeem Giftcard: This action burns the token and sends the assets to the redeemer.

    Available actions:

    • create giftcard
    • redeem giftcard
  7. What is the Swap smart contract

    main

    The Swap contract facilitates peer-to-peer asset exchanges between two parties. It works by locking assets in the contract until the counterparty accepts the swap.

    Key features:

    • Asset Locking: Assets are held by the contract during the swap process.
    • Cancellation: Any party can cancel the swap at any point before it is accepted to retrieve their locked assets.

    Available actions (endpoints):

    • initiate swap
    • accept asset
    • cancel swap
  8. What is the Escrow smart contract?

    main

    The Escrow smart contract acts as a trusted intermediary to facilitate the secure exchange of assets between two parties. It holds assets in escrow until specific conditions are met, requiring both parties to agree and sign off on the transaction before assets are released.

    Available actions for interacting with the contract include:

    • initiate escrow and deposit assets: Starts the escrow process and deposits the initial assets.
    • deposit assets: Adds assets to an existing escrow.
    • complete escrow: Finalizes the transaction and releases assets once conditions are met.
    • cancel escrow: Terminates the escrow agreement.
  9. What is a TransactionPrototype and how is it used?

    main

    A TransactionPrototype is a fully-resolved, backend-agnostic representation of a Cardano transaction. It serves as the intermediate handoff between a transaction builder (which decides what the transaction is) and a serializer (which decides how the bytes are laid out).

    Key Characteristics:

    • Post-Resolution: It is created after coin-selection, witness collection, and fee calculation are complete.
    • No Builder Intent: It contains no unresolved references or partial state; it is a final snapshot of a transaction.
    • Backend Agnostic: It is designed to be consumed by different serialization backends (like mesh-core-cst or mesh-core-csl) to produce identical CBOR outputs.

    Workflow: Builder State $\rightarrow$ TransactionPrototype $\rightarrow$ CBOR (Hex string)

    Note: This is not a builder API for users to assemble manually; it is the intended output of the transaction builder.

    type TransactionPrototype = {
      body: TransactionBodyPrototype;
      witness_set: TransactionWitnessSetPrototype;
      is_valid: boolean;
      auxiliary_data?: AuxiliaryDataPrototype;
    };