Skip to main content

Self served mint

Create a managed mint transaction for one or multiple assets.

With the self-service minting option, you take control of the keys, mint price, metadata, distribution, whitelist, and any other conceivable configuration.

Caution

Incorrect distribution handling could result in a double mint.

Parameters

AttributeDescription
utxosAn array of UTXOs
changeAddressWallet change address
min.assetsAn array of assets to mint

Usage Example

Step 1

Create the mint transaction server-side.

Find the UTXOs and change address on the front-end using anvil.wallet.getUtxos() and anvil.wallet.getChangeAddress() with the client SDK.

import { anvil } from "@ada-anvil/sdk-server";

try {
// Generate a policy ID using the cardano-serialization-lib or a similar alternative.
const policyId = yourCustomCreatePolicyFunction();

const mint = await anvil.transaction.mint({
changeAddress: "THE_CHANGE_ADDRESS",
utxos: ["THE_UTXO"],
mint: {
assets: [
{
version: "cip25", // cip25 or cip68
assetName: "THE_ASSET_NAME",
policyId: policyId,
quantity: 1,
metadata: {
// The metadata
},
},
],
},
});
} catch {
console.log("YOUR ERROR HANDLING");
}

Step 2

Send the transaction to the front-end so the user can sign the transaction. Do not submit the transaction at this point.

import { anvil } from "@ada-anvil/sdk-client";

try {
const frontendSignature = await anvil.wallet.signTx({
transaction: "THE_TRANSACTION", // from mint.transaction
partialSign: true,
});
} catch {
console.log("YOUR ERROR HANDLING");
}

Step 3

Send back the signed transaction on the backend.

import { anvil } from "@ada-anvil/sdk-server";

try {
// Sign the transaction using a custom function with cardano-serialization-lib or an equivalent.
const backendSignature = yourCustomSignatureFunction(mint.transaction);

const response = await anvil.walletExt.submit({
transaction: mint.transaction,
signature: backendSignature,
appendSigs: [frontendSignature],
});
} catch {
console.log("YOUR ERROR HANDLING");
}

Return from anvil.transaction.mint

AttributeDescription
transactionIdentifier for the transaction

Return from anvil.wallet.signTx

Return the signature as a string.

Return from anvil.walletExt.submit

AttributeDescription
transactionHashIdentifier for the transaction
submittedTxThe submited transaction

Burn mechanism

You have the ability to burn an asset owned by the front-end wallet by constructing a transaction that specifies the asset name and sets the quantity to -1.