Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of tag-nft-token-id for the sender param inside the transfer function? #6

Open
ECBSJ opened this issue Aug 1, 2024 · 5 comments

Comments

@ECBSJ
Copy link

ECBSJ commented Aug 1, 2024

@MarvinJanssen

From my understanding, I think the reason why nft-burn? is being called within the private tag-nft-token-id (which is called in the public mint), is to allow a user to be minted more of the same SFT if they already own it.

But am having a hard time understanding why tag-nft-token-id is called for the sender param (on line 55) inside the transfer function.

@MarvinJanssen
Copy link
Owner

MarvinJanssen commented Oct 24, 2024

Excuse me for missing this issue. The purpose of tag-nft-token-id is to create NFT burn and mint events on the specified principal. It adds security because then post conditions must be used to not only protect the amount transferred but also the token ID. Without tag-nft-token-id, post conditions for the token ID are not possible. It is explained in greater detail the README. Let me know if that answers your questions.

@ECBSJ
Copy link
Author

ECBSJ commented Oct 24, 2024

So in the two events below from the README:

  1. It transfers the specified amount of semi-fungible-token fungible tokens from the sender to the recipient.
  2. It performs a burn-and-mint operation for the semi-fungible-token-id NFT for both the sender and the recipient.

How would you construct a post-condition statement for number 2 if post-conditions don't apply to burn and mint events?

@MarvinJanssen
Copy link
Owner

For a burn you need a post condition. That is the trick with the code. The condition would be something like:

  • Sends one NFT of SP123...stx-semi-fungible-token::semi-fungible-token-id,
  • Of token ID tuple { token-id: <token ID>, owner: tx-sender }.

@ECBSJ
Copy link
Author

ECBSJ commented Nov 5, 2024

ah ok got it.

But tag-nft-token-id function will be calling the nft-mint? function again for the same nft-token-id for the sender. So i get why having that burn event is important for enabling a proper post-condition on the nft-token-id, but the last line of the function calls for a mint of the same thing? From what I see is that the sender, even after transferring all their SFTs to another recipient, they are still tied to an nft-token-id?

@MarvinJanssen
Copy link
Owner

It is likewise to generate an event for the recipient but purely for indexing purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants