Want to create unique ID for NFT

Hello guy im create a site when someone can mint their own nft, so I have the problem with the ID for the .json, I don’t know how to proceed, need I store an object call id and every time someone want to create a nft I do + 1 in the id ? but how to create the object with a id without always set to 0 because everyone will have id 1 ?

my js =>
async function createJsonFile() {
//let id = ?;
let file_name = (“0000000000000000000000000000000000000000000000000000000000000000” + id).slice(-64);
let name = document.getElementById(“name”).value;
let description = document.getElementById(“description”).value;
let image = currentUser.get(‘nft_picture’);
console.log(image);
let metadata = {
name: name,
description: description,
image: image
};
const metadata_file = new Moralis.File(file_name + “.json”, {base64 : btoa(JSON.stringify(metadata))});
//currentUser.set(‘nft_metadata’, metadata_file);
//metadata_file.save();
}

thank you for ur help :slight_smile:

ok i have a solution but its not very good because they will be able to have just 1 NFT so I query all the user and I take the result and add it to the file name. if u find a better way pls explain to me :wink:

my js =>

async function getId() {
const query = new Moralis.Query(“User”);
const alluser = await query.find();
return alluser.length;
}

You can keep that ID internal to the smart contract and increment it every time you mint another NFT. Or I don’t understand what you want to ask?

Its for set the metadata I believe I need to do it myself, I don’t know I can just take the id from the smart contract and increment it every time I mint one, I will see how to do that thank you :wink: u always help me I love you <3