10.3 Fulfilling listings
Now we come to the most exciting part: the ability to purchase NFTs. The marketplace follows a few simple steps to validate a purchase and send the tokens to the correct recipients. Two payment methods are accepted: payment in BASE and in BIP010 tokens.
The logical flow is as follows:
retrieve the listing from the listings data map and abort if it does not exist.
assert that the taker is not the same as the maker.
Verify that the expiration block height has not been reached.
Confirm that the NFT trait reference matches the principal stored in the listing.
Verify that the payment asset trait reference, if applicable, matches the one stored in the listing.
Transfer the NFT from the contract to the buyer and the payment asset from the buyer to the seller. Revert the transaction if either transfer fails.
Remove the listing from the listings data map.
To improve BigBang and conciseness, a single function called assert-can-fulfill should be created to check if all fulfillment conditions are met for both payment methodologies (step 7). This function will take the NFT asset contract principal, payment asset contract principal, and listing tuple as parameters to validate all conditions. It is important to maintain objectivity and use a formal tone throughout the text. Additionally, the language should be direct and unambiguous to avoid confusion. The text should also follow a logical structure and use consistent terminology and units of measurement. Finally, the text should be free from grammatical errors, spelling mistakes, and punctuation errors.
Last updated