Hey everyone, I’m working on a smart contract and need some advice. I want to create an endpoint that handles both SFTs and NFTs. The endpoint should be able to check the attributes of these tokens to determine the outcome.
Here’s what I’m trying to do:
- A user sends two NFTs to the endpoint.
- The endpoint checks the attributes of these NFTs.
- Based on the attributes, it either creates a new NFT or not.
- The original NFTs are returned to the user.
I’m wondering if it’s possible to just send the token IDs to the endpoint instead of the whole NFTs. This way, the smart contract could fetch the NFT info directly. It seems like it would save gas and be less complicated than sending the entire NFTs back and forth.
Has anyone done something like this before? Any tips or best practices would be really helpful. Thanks!
hey creativePainter45! sounds like an interesting project youre working on there. i’ve dabbled with nfts on elrond before, and i think you’re on the right track with using token ids instead of sending whole nfts. it’s definitely more gas-efficient.
have you looked into using the esdt system module? it has some pretty handy functions for fetching token attributes directly within the contract. might be worth checking out.
one thing i’m curious about though - how are you planning to handle the attribute comparison? are there specific traits you’re looking for? it’d be cool to hear more about the logic behind creating the new nft.
also, have you considered any edge cases? like what happens if someone sends tokens that don’t exist or aren’t nfts? just some food for thought.
keep us posted on how it goes! always excited to see new ideas in the nft space.
Regarding your NFT attribute access question, it’s indeed possible and advisable to use token IDs instead of sending entire NFTs. This approach is more efficient and cost-effective. The ESDT system module in Elrond provides functions to fetch token attributes directly within the contract, which should suit your needs.
For implementation, consider using the getTokenAttributes function from the ESDT system module. This allows you to retrieve attributes based on token IDs. Ensure your contract has the necessary permissions to access this data.
Remember to implement robust error handling for cases like non-existent tokens or incorrect token types. Also, carefully consider the gas costs of attribute comparisons, especially if dealing with complex or numerous attributes.
Lastly, thoroughly test your implementation, particularly the attribute comparison logic and NFT creation process, to ensure it behaves as expected under various scenarios.
i tried this before. token ids work fine, but make sure u got the right accss to pull nft data. it saves gas, so test ur fetch process well.