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
Attribute | Description |
---|---|
utxos | An array of UTXOs |
changeAddress | Wallet change address |
royalty | The royalty info to mint |
policyScripts | The 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
Attribute | Description |
---|---|
transaction | Identifier for the transaction |
Return from anvil.walletExt.submit
Attribute | Description |
---|---|
transactionHash | Identifier for the transaction |
submittedTx | The submited transaction |