How to configure NFT pricing during minting process?

I’m in the process of creating NFTs on the NEAR blockchain and need guidance on setting prices. I’m utilizing the near-contract-standards library for the minting aspect, but I’m unclear on how to correctly assign a price to each token.

Specifically, I’m interested in knowing the best way to incorporate pricing details in the token’s metadata to ensure it aligns with the NEP 171 standard. Should the pricing info be included directly in the metadata, or is there a designated field that I should utilize?

For context, here’s a basic example of what I’m attempting to do:

use near_contract_standards::non_fungible_token::metadata::TokenMetadata;

let token_info = TokenMetadata {
    title: Some("My Digital Art".to_string()),
    description: Some("Unique artwork piece".to_string()),
    media: Some("https://example.com/art.png".to_string()),
    // Where do I insert the price information?
    extra: Some("price: 5000000000000000000000000".to_string()), // 5 NEAR in yoctoNEAR?
};

Your advice on the correct implementation would be greatly appreciated. Thanks!

hey, i totally agree! keep pricing outta the extra field. that should be used for metadata only. its better to handle payment checks in your mint function and maybe use contract storage for your prices. makes things smoother and saves gas!

hey Isaac31! interesting question :thinking:

I’ve been working with NFT contracts on NEAR for a while - the pricing thing’s definitely tricky. NEP-171 doesn’t define how to handle pricing during minting. It just covers the core stuff like ownership transfers and metadata.

Your extra field approach might work for storing price info, but are you handling the actual payment logic in your minting function? Having the price in metadata doesn’t automatically enforce payment.

I’ve seen people create a separate mint_with_payment function that checks the attached deposit against their set price. Others store pricing in a separate hashmap on the contract instead of in the token metadata.

What’s your use case? Fixed price mint or dynamic pricing? Do you want the price permanently stored with the token or just used during minting?

Also - have you checked out existing NEAR NFT marketplaces to see how they handle this? Might give you some ideas.

Would love to hear more about what you’re building!

NEP-171 doesn’t specify pricing mechanisms - that’s marketplace functionality, not core NFT stuff. Don’t use the extra field for prices since metadata should stay static and descriptive. Handle pricing through your contract’s minting logic instead. Set up a storage map linking token IDs to prices, then validate the deposit in your mint function before creating tokens. Something like require!(env::attached_deposit() >= required_price, "Insufficient payment"); I’ve deployed several NFT contracts on NEAR and this separation works way cleaner. Keep pricing logic in contract methods while metadata stays purely descriptive. You can still query prices through view functions for frontend integration. Decide if you want fixed or dynamic pricing based on supply/demand. Fixed pricing’s easier to start with.