Get the NFT ID of an existing NFT through its External Reference
Returns the NFT ID for a given external reference.
await api.query.getNftId(external_reference);
tip
If you're checking the ID for a newly minted NFT, allow time for consensus to be achieved on the minted NFT.
You can get the AVN_GATEWAY_URL here.
- Example
- Example Result
- JSON-RPC
- JSON-RPC Output
const { AvnApi, SetupMode, SigningMode } = require("avn-api");
const AVN_GATEWAY_URL = "https://gateway.testnet.aventus.network/";
const singleUserOptions = {
suri: "0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24", // this is from the generated example account
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
};
const avnSdk = new AvnApi(AVN_GATEWAY_URL, singleUserOptions);
//replace with the external ref set when minting the NFT.
const EXTERNAL_REF = "https://5DA/gxV";
async function main() {
await avnSdk.init();
const api = await avnSdk.apis();
let request_id = await api.query.getNftId(EXTERNAL_REF);
console.log(request_id);
}
(async () => {
await main();
})();
0x1068fa5b1f3e033d7e802a2d3f355a0b96b07f367c69ba1aa2ea58ee61af82ce
REQUEST
POST https://AVN_GATEWAY_URL/query
HEADERS
Content-Type: application/json Authorization': bearer <awtToken>
REQUEST PARAMS
- externalRef [required] - a unique string representing the NFT's external reference.
JSON-RPC Example
curl https://AVN_GATEWAY_URL/query \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"getNftId", "params":{"externalRef":"my_unique_nft_2022-01-17T12:15:31Z"}, "id":1}'
note
result - hex string value representing the NFT ID.
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x4184aa1d0e5a1a44d36d92b02ad07ab4285a43086f538a7e5b7d5cbd858e0e71"
}
Production Example
Multiple NFTs have been minted on the AVN and HERE is a link to the AVN Explorer that provides more detail on the minted NFT. Click on the Advanced tab on the page to view more details on the transaction.