Mint a Batch of NFTs
Mint a batch of NFTs on the Voucher Ledger.
Minting from a batch of NFTs has a different flow from minting a single NFT. To mint a single NFT, please follow the steps here. The main difference between minting single and batch NFTs is when you mint an NFT from a batch, the batch abstraction must already exist to allow the NFT to be minted from within that batch.
For example, firstly create a batch of 10 NFT using the endpoint here and then as needed mint any number of NFTs less than the total number of NFTs (10) into that batch.
await api.send.mintBatchNft(BATCH_ID, INDEX, OWNER, EXTERNAL_REF);
You can get the VL_GATEWAY_URL for all networks here.
- Example
- Example Result
- JSON-RPC
- JSON-RPC Output
const { AvnApi, SetupMode, SigningMode } = require("avn-api");
const VL_GATEWAY_URL = "https://gateway.testnet.voucherledger.com";
const singleUserOptions = {
suri: "0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24", // this is from the generated example account
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
};
const avnSdk = new AvnApi(VL_GATEWAY_URL, singleUserOptions);
// follow the link above to learn about EXTERNAL_REF
const EXTERNAL_REF = "https://5DA/gxV";
// Index of the nft within the batch
const INDEX = 1;
// New owner address
const OWNER = "5G7B3...";
// any string can represent the batch Id
const BATCH_ID = "batch_id";
async function main() {
await avnSdk.init();
const api = await avnSdk.apis();
let request_id = await api.send.mintBatchNft(
BATCH_ID,
INDEX,
OWNER,
EXTERNAL_REF
);
// Returns a request id
console.log(request_id);
}
(async () => {
await main();
})();
You have now successfully submitted a transaction to the VL to mint an NFT from a previously created batch.
f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a
REQUEST
POST https://VL_GATEWAY_URL/send
HEADERS
Content-Type: application/json
Authorization': bearer <awtToken>
REQUEST PARAMS
- relayer [required] - a string representing the relayer.
- user [required] - a string representing the user's SS58 address.
- payer [required] - a string representing the payer's SS58 address.
- batch_Id [required] - A string representing the BATCH ID (32 bytes) to check for nonce.
- index [required] - string integer value of the index of the NFT within the batch.
- owner [required] - New owner address for the nft to be minted.
- externalRef [required] - a unique string representing the NFT's external reference.
- proxySignature [required] - a proof signed by the user allowing the transaction to be proxied.
- feePaymentSignature [required] - a proof signed by the payer allowing the relayer fees to be paid.
- paymentNonce [required] - string integer value of the current payment nonce of the payer.
JSON-RPC Example
curl https://VL-GATEWAY-URL/send \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"proxyMintBatchNft", "params":{"relayer":"5FbUQ2kJWLoqHuSTSNNqBwKwdQnBVe4HF3TeGyu6UoZaryTh", "user":"5DAgxVxKmn...irSVJDdMr", "payer":"5DAgxVxKmn...irSVJDdMr", "batchId": "0x2c94a703a7b01f0c2d1eed5ccf82b9cbadd0bdd5e4e5283ddf01b249586181c2", "index": "23", "owner":"5DAgxVxKmn...irSVJDdMr", "externalRef":"my-unique-ref-2022-01-18T10:32:45.199Z", "proxySignature":"0xd4d20c5be0943cd1e784b7d83f7bf69...100d0fe24717104cad467890272d47a36f8daf497ebd2ec3ed106c58d8f", "feePaymentSignature":"0x4e4ec2190d44765d1b5fa88f6...ccd633403f75068604cf3b94336c7e93a56b13a0973d181432d381b5b0f8a", "paymentNonce":"201"}, "id":1}'
result - a request ID that can be queried for the transaction's status
{
"jsonrpc": "2.0",
"id": 1,
"result": "a3ef1c40-c1be-4beb-9953-357d0ab504a9"
}
You can query the state of your transaction here using the returned request id.