Skip to main content

Create a royalty token

Using the self-service minting feature, you must generate your own royalty token. While this step is optional, it is often necessary for most projects.

Parameters

AttributeDescription
utxosAn array of UTXOs
changeAddressWallet change address
royaltyThe royalty info to mint
policyScriptsThe policy script of the policy

Usage Example

Step 1

Create a royalty token transaction.

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

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

const mint = await server.transaction.mintRoyaltyToken({
changeAddress: wallet.changeAddress,
utxos: wallet.utxos,
royalty: {
rate: "YOUR_RATE", // The % of rate in decimal, 5% would eb 0.05
addr: "THE_ROYALTY_WALLET_ADDRESS",
},
policyScripts: {
type: "all",
scripts: [
{
type: "sig",
keyHash: wallet.keyHash, // Public key hash of the policy owner
},
{
type: "before",
slot: 0, // replace by the slot number you are aiming for
},
],
},
});
} catch {
console.log("YOUR ERROR HANDLING");
}

Step 2

Submit transaction.

Caution

To successfully submit the transaction, it is necessary to have a certain amount of ADA in the wallet.

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

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

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

Return from anvil.transaction.mintRoyaltyToken

AttributeDescription
transactionIdentifier for the transaction

Return from anvil.walletExt.submit

AttributeDescription
transactionHashIdentifier for the transaction
submittedTxThe submited transaction