Skip to content

Commit

Permalink
Improve explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Dec 11, 2024
1 parent 493971f commit b2346c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
12 changes: 3 additions & 9 deletions explanations/contract.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
You would find the function the mint a moment in your Set resource. To mint a moment you would call on this function and input the playID you would like to mint.
The Set resource in the contract is central to minting Moments, which are represented as NFT resources. To mint a Moment, you use the mintMoment function in the Set resource, providing the playID of the play you want to mint. When a play is added to a set, the number of Moments minted for that play is initialized to zero. The mintMoment function first checks preconditions to ensure that the specified play exists in the set and has not been retired. If these conditions are met, the function retrieves the current count of minted Moments for the play, increments it, and uses it as the serial number for the new Moment. A new Moment NFT is then created with the provided parameters, and the count of minted Moments for the play is updated.

Remember when we added our play to the set we intialized the moments as 0 so when you mint a moment it will add 1 to that minted moment per play. Before we mint however, we check to see if the play exists in the set or if the play is retired.
The minted Moment is returned as an NFT resource, ready to be stored in a recipient's collection. For cases where a large number of Moments need to be minted efficiently, the batchMintMoment function allows multiple Moments to be minted at once. This function creates a temporary collection resource, mints the specified number of Moments, and deposits them into the collection. Once all the Moments are minted, the collection is returned, enabling batch deposits into the recipient's account.

If not, we then get the number of moments minted for this play and store that number variable in numInPlay. We would then mint a new Moment as an NFT resource type. We would send in all the parameters specified for the NFT and once we mint that new Moment we then increase the number of moments minted for this play by one.

We then return the moment with is of an NFT resource type, to later be stored in a collection in a receivers account.

We could also batch mint these moments. This would save a lot of time if you wanted to mint 60,000 moments. When doing this, you would have to create a collection resource that would deposit all of the minted NFTS into it.

Once that happens you would return the collection resource and then deposit that into the receivers collection.
The Moments themselves are structured to include metadata such as their unique ID, the play and set they reference, and their serial number. These NFTs can be deposited into a Collection resource, which manages ownership of Moments and facilitates operations like withdrawal, deposit, and locking. Batch operations are supported for both withdrawal and deposit, streamlining the handling of multiple Moments.
10 changes: 3 additions & 7 deletions explanations/transaction.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
To mint a moment you will need to borrow a reference to the admin resource from the Auth Account.
To mint a Moment in the TopShot system, you start by borrowing a reference to the Admin resource from the authorized account. This reference grants access to administrative functions, including minting Moments and managing sets. Next, you use the borrowSet function on the Admin reference to access the specific Set resource by its setID. The Set resource contains the functionality needed to mint Moments associated with a particular play.

Once you do, you will need to borrow the set that you would like access to by calling the borrowSet function. This gets whatever setID is created that you want to have access to.
To store the minted Moments in the recipient's account, you need a capability reference to the recipient's collection, which can accept the NFTs. Using this reference, you can deposit the Moments into their collection. In this scenario, the batchMintMoment function is used to mint multiple Moments at once.

You will also need to have the capability to receive the NFT or NFTS for the receiving account referenced.

In this case we use the batchMintMoment to return a collection of minted NFTS that we can store it into the receivers collection.

Then we specify what playID we would like to mint and how many moments will be minted. After that we deposit the collection that is returned into the receivers account.
The transaction specifies the playID for the Moments being minted and the desired quantity. After minting, the resulting collection of Moments is deposited directly into the recipient's collection.

0 comments on commit b2346c4

Please sign in to comment.