Post
Share your knowledge.
How to keep NFT metadata stable without leaking info?
I'm trying to develop an NFT contract and wish to make sure all NFT metadata remains stable. I'm concerned that if I include a source metadata link in the contract, it could be visible to users who might exploit it. How can I prevent this from happening? Additionally, I'd like to know if I can add optional fields to an NFT object as I do in TypeScript. Here's my idea:
type NFT = {
name: string;
description: string;
url: string;
attributes: {field: string; value: string}[];
};
I've never seen this approach before and I feel like I'm missing something. Can someone guide me on the best practices here?
- Move CLI
- Smart Contract
Answers
3Regarding adding optional fields similar to TypeScript, you can indeed customize your NFT metadata. There's a 'standard' metadata format used by popular NFT collections, but you can deviate from it. Use VecMap
for attributes as you mentioned, and explore the options of using the Display
parameter to customize what metadata is shown. To learn more, explore these resources:
It sounds like your main concern is that someone might deduce future NFT metadata because of how they're minted sequentially. To mitigate this risk, consider shuffling the metadata sequence outside the blockchain. This way, even though they may appear sequential on the blockchain, the metadata won't be predictable. Alternatively, assign a random ID and ensure that the minting function checks that this ID hasn't been minted yet.
Yes, in Sui Move, you can add optional metadata fields similar to optional fields in TypeScript. While many NFT collections follow a common metadata format, you’re free to customize it.
To achieve this: • Use a VecMap (or vector<(key, value)>) to store flexible attribute data. • For optional fields, include only the ones you need — Sui doesn’t enforce a strict schema. • To control how metadata appears in wallets or explorers, use the Display object. It lets you define how fields like name, description, image_url, or any custom key should be displayed. • For completely custom formats, create your own metadata struct and attach it to the NFT or manage it via dynamic fields.
This approach gives you full control over your NFT’s metadata, while keeping it clean, flexible, and UI-friendly
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.
