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:
- Create an account by logging in with one of the supported providers.
- From the dashboard, create a new project.
- Set up your
Entity Secret
in Dashboard > Project Settings > Security. - Save the
Private Key
and keep it safe. - Copy the
Project ID
from the project settings.
Create a sponsorship
- Go to the dashboard and create a new sponsorship.
- Define the sponsorship configurations.
- Copy the
Sponsorship ID
from the sponsorship settings.
Sponsor a transaction
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
});