The End to End Guide For Minting a Single NFT on the VL
This guide will walk you through successfully submitting a transaction on the VL to mint an NFT and verify the state of the transaction.
The first thing we need to do is ensure that you have npm installed. You'll find instructions on how to do this here. You'll also find instructions on how to install the avn-api library.
Note, all transactions on the VL must be paid for using VOW, so going forward it's important for you to have some VOW in your account. There are multiple ways to purchase VOW and this page provides instructions on how to get some. Note, you'll need 1 VOW in your SURI account to use the API. The tokens need to be lifted (moved) to the Voucher Ledger, and there are also instructions for that too here.
Once you have some VOW in your account, of which you can check your account balance here, let's get to the exciting bit, minting an NFT by submitting a transaction to the VL. For this guide, we'll show a simple transaction minting a single NFT.
const { AvnApi, SetupMode, SigningMode } = require("avn-api");
const VL_GATEWAY_URL = "gateway url of your chosen network";
const options = {
suri: "suri of your account",
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
hasPayer: true,
};
const EXTERNAL_REF = "https://5DA/gxV"; //this takes an arbitrary value
const T1_ADMIN_NAME = "0x1a2...b3c"; //smart contract on Ethereum
const ROYALTIES = [
{
recipient_t1_address: "0x1a2...c3b", //Ethereum address of a royalty recipient
rate: {
parts_per_million: 10000, // 1%
},
},
];
async function main() {
const avnSdk = new AvnApi(VL_GATEWAY_URL, options);
await avnSdk.init();
const api = await avnSdk.apis();
const result = await api.send.mintSingleNft(
EXTERNAL_REF,
ROYALTIES,
T1_ADMIN_NAME
);
// Returns a request id
console.log(result);
}
(async () => {
await main();
})();
Expected Transaction Submission Output
f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a
Congratulations! You've now successfully minted an NFT on the VL.
State of the Transaction
To query the VL on the state of the transaction:
let status = await api.poll.requestState(requestId);
console.log(status);
Expected State Output
{
"txHash": "0x37b5aa6...ae1c773c0acbc63dc90",
"status": "Processed",
"blockNumber": "125412",
"transactionIndex": "2"
}