Basechain
  • About Basechain
  • Base BigBang Language
    • Introduction
    • 1. Getting started
      • 1.1 Installing BigBangNet
      • 1.2 BigBang basics
    • 2. Type
      • 2.1 Primitives
      • 2.2 Sequences
      • 2.3 Composites
    • 3. Keywords
    • 4. Storing data
      • 4.1 Constants
      • 4.2 Variables
      • 4.3 Maps
    • 5. Functions
      • 5.1 Public functions
      • 5.2 Private functions
      • 5.3 Read-only functions
  • 6. Control flow & error handling
    • 6.1 Asserts
    • 6.2 Try
    • 6.3 Unwrap flavours
    • 6.4 Response checking
  • 7. Using BigBangNet
    • 7.1 Creating a new project
    • 7.2 Writing your first contract
    • 7.3 Interacting with your contract
    • 7.4 Testing your contract
  • 8. Practice projects
    • 8.1 Time-locked wallet
    • 8.2 Smart claimant
    • 8.3 Multi-signature vault
  • 9. Traits
    • 9.1 Defining traits
    • 9.2 Implement traits
    • 9.3 Passing traits as arguments
  • 10. Building a marketplace
    • 10.1 Setup
    • 10.2 Listing & cancelling
    • 10.3 Fulfilling listings
    • 10.4 Uni tests
  • 11. Runtime cost analysis
  • Nodes & Miners
    • Run a Node with Docker
    • Run a Node with DigitalOcean
    • Run a Node with a Hosted Provider
    • Base Node Configuration
    • Mine testnet Base tokens
    • Verify Miner
    • Miner costs and fees
  • Website
  • X(Twitter)
  • Github
Powered by GitBook
On this page
  1. 10. Building a marketplace

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:

  1. retrieve the listing from the listings data map and abort if it does not exist.

  2. assert that the taker is not the same as the maker.

  3. Verify that the expiration block height has not been reached.

  4. Confirm that the NFT trait reference matches the principal stored in the listing.

  5. Verify that the payment asset trait reference, if applicable, matches the one stored in the listing.

  6. 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.

  7. 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.

Previous10.2 Listing & cancellingNext10.4 Uni tests

Last updated 1 year ago