Usage

ℹ️

This page is work in progress.

Before you begin, you need to create a project on Mesh Web3 Services. To do so follow these steps:

  1. Create an account by logging in with one of the supported providers.
  2. From the dashboard, create a new project.
  3. Set up your Entity Secret in Dashboard > Project Settings > Security.
  4. Save the Private Key and keep it safe.
  5. Copy the Project ID from the project settings.

Create a sponsorship

  1. Go to the dashboard and create a new sponsorship.
  2. Define the sponsorship configurations.
  3. Copy the Sponsorship ID from the sponsorship settings.

To sponsor a transaction, developers need to create a Cardano transaction with any transaction builder library.

Then, use the sponsorTx function from the @meshsdk/web3-sdk to add sponsorship to the transaction. This will return a new transaction with the sponsorship added. The new transaction ready for user’s signature and submission.

import { sponsorTx } from "@meshsdk/web3-sdk"; // import sponsorTx
 
// this is your existing transaction builder output, expected to be a CBOR encoded transaction
const txCbor = buildTx();
 
// add sponsorship to the transaction
const { sponsorTxCbor, sponsorTxhash } = sponsorTx({
  sponsorshipId: "public_sponsorshipId",
  txCbor: txCbor,
  feeChangeAddress: "addr_xxx", // Either this or feeOutputIndex is required. Fee balance will go to first output identified with this address
  feeOutputIndex: 1, // Either this or feeOutputIndex is required. Fee balanace will combine with the output with this index
});