Marketplace

Operations to help you create and manage a marketplace.

📘

Please note: This is an introductory reference

For the most up-to-date information, refer to the GraphQL Playground and Apollo API Reference.

🚧 The information provided in this section cannot be programmatically updated and may be subject to inconsistencies over time.

👍

Marketplace Endpoints

  • Testnet: http://platform.canary.enjin.io/graphql/marketplace
  • Mainnet: http://platform.enjin.io/graphql/marketplace

This is a detailed reference guide that explains the most commonly used operations.

Mutations

CreateListing

The CreateListing mutation is used to initiate the process of placing a sell order on a marketplace. This mutation is essential for sellers who want to list their assets for sale in the marketplace.

mutation CreateListing {
  CreateListing(
    account: "0x087c3fdc6566230578362759d99e42ed300f5560c305262843b2c61aa2f1d11e"
    makeAssetId: {
      collectionId:7153
      tokenId: {integer:68}
    }
    takeAssetId: {
       collectionId:7153
      tokenId: {integer:70468841277235617716769448539773927607}
    }
    amount: 1
    price: 10000
    salt: "random string"
    auctionData: {
      startBlock:403000
      endBlock:404000
    }
  ) {
    id
    transactionId
    transactionHash
    state
    encodedData
    method
    wallet {
      account {
        publicKey
        address
      }
    }
    idempotencyKey
  }
}
{
  "data": {
    "CreateListing": {
      "id": 11296,
      "transactionId": null,
      "transactionHash": null,
      "state": "PENDING",
      "encodedData": "0x3200c56f1101c56f33b7007b94fad4fa2fe1d6a5b71ece033504419c3472616e646f6d20737472696e6701e298180082a81800",
      "method": "CreateListing",
      "wallet": {
        "account": {
          "publicKey": "0x68b427dda4f3894613e113b570d5878f3eee981196133e308c0a82584cf2e160",
          "address": "cxLnsZcpE1xETr7TQrMCCsRYpSfpHPUpJUFAfiZdZvU6Ccy4B"
        }
      },
      "idempotencyKey": "4863964a-0768-473f-8c02-18be8fff92c1"
    }
  }
}

Use Case:

The CreateListing mutation is a fundamental operation for sellers in a marketplace. It allows you, as a seller, to list your assets for sale on the platform. Here's how you can use it:

  1. Seller's Identity: You provide your account's public key (account) to identify yourself as the seller.

  2. Asset Details: Specify the asset you want to sell (makeAssetId) and the asset you want to receive in exchange (takeAssetId). This includes collection IDs and token IDs.

  3. Quantity and Price: Set the quantity (amount) and the price (price) at which you are willing to sell your asset.

  4. Uniqueness: Include a random string (salt) to ensure the uniqueness of your listing order.

  5. Auction Details (Optional): If you are conducting an auction, you can specify the start and end blocks for the auction (auctionData).

  6. Response: After successfully creating the listing, you will receive a response with details about the new listing, including its ID, state, and other relevant information.

This mutation is essential for sellers to participate in the marketplace, list their assets, and potentially initiate sales or auctions. It forms the basis for trading assets within the platform, allowing sellers to set their terms and conditions for each listing.

FillListing

The FillListing mutation is used to finalize the purchase of an asset listed at a fixed price on a marketplace. It enables buyers to accept the terms of a listing and execute the transaction to acquire the asset they desire.

mutation FillListing {
  FillListing(listingId: "0x101d16dc0fa25d77a92bcb6cde34e8ad1e85d96cd6a4a78eb68acc4f82d37f20", amount: 1) {
    id
    transactionId
    transactionHash
    state
    encodedData
    method
    wallet {
      account {
        publicKey
        address
      }
    }
    idempotencyKey
  }
}
{
  "data": {
    "FillListing": {
      "id": 11297,
      "transactionId": null,
      "transactionHash": null,
      "state": "PENDING",
      "encodedData": "0x3202101d16dc0fa25d77a92bcb6cde34e8ad1e85d96cd6a4a78eb68acc4f82d37f2004",
      "method": "FillListing",
      "wallet": {
        "account": {
          "publicKey": "0x68b427dda4f3894613e113b570d5878f3eee981196133e308c0a82584cf2e160",
          "address": "cxLnsZcpE1xETr7TQrMCCsRYpSfpHPUpJUFAfiZdZvU6Ccy4B"
        }
      },
      "idempotencyKey": "0f4eb316-cf7f-4561-a2d6-112abf08d323"
    }
  }
}

Use Case:

The FillListing mutation is a critical operation for buyers in a marketplace. Here's how you can use it:

  1. Select Listing: You specify the unique listingId of the listing you want to fill, indicating the asset you wish to purchase.

  2. Quantity: Determine the amount of the asset you want to buy. Ensure that this quantity matches the available quantity in the listing if it's a fixed price sale.

  3. Transaction Submission: Execute the mutation, triggering the transaction. The response will provide transaction details, including the initial state as "PENDING."

  4. Transaction Processing: The network processes the transaction, and eventually, the transactionId and transactionHash fields in the response will be updated with the respective values once confirmed.

  5. Completion: The successful execution of the FillListing mutation indicates that you have committed to the purchase, and the asset will be transferred to your wallet upon transaction confirmation.

This mutation is essential for buyers to participate in the marketplace, finalize purchases, and take ownership of assets. It facilitates the transfer of both digital assets and funds between parties on the blockchain, ensuring a seamless and secure transaction process.

FinalizeAuction

The FinalizeAuction mutation is used to complete the auction process for a specific asset listed in a marketplace. This operation is crucial for officially closing the auction and transferring the asset to the highest bidder, typically after the auction has ended.

mutation FinalizeAuction {
  FinalizeAuction(listingId: "0x101d16dc0fa25d77a92bcb6cde34e8ad1e85d96cd6a4a78eb68acc4f82d37f20") {
    id
    transactionId
    transactionHash
    state
    encodedData
    method
    wallet {
      account {
        publicKey
        address
      }
    }
    idempotencyKey
  }
}
{
  "data": {
    "FinalizeAuction": {
      "id": 11298,
      "transactionId": null,
      "transactionHash": null,
      "state": "PENDING",
      "encodedData": "0x3204101d16dc0fa25d77a92bcb6cde34e8ad1e85d96cd6a4a78eb68acc4f82d37f20",
      "method": "FinalizeAuction",
      "wallet": {
        "account": {
          "publicKey": "0x68b427dda4f3894613e113b570d5878f3eee981196133e308c0a82584cf2e160",
          "address": "cxLnsZcpE1xETr7TQrMCCsRYpSfpHPUpJUFAfiZdZvU6Ccy4B"
        }
      },
      "idempotencyKey": "0deaaad8-f6a0-4ef5-b8f1-fadd1ecb8ac5"
    }
  }
}

Use Case:

  • You can use the FinalizeAuction mutation in scenarios where you have conducted an auction-based listing and need to complete the auction process. This includes:
    • Officially transferring the auctioned asset to the winning bidder.
    • Ensuring that the funds are allocated as per the auction terms.
    • Providing finality to the auction and enforcing the bid commitments.

It's important to note that FinalizeAuction is specific to auction listings and is used after the auction has ended. This mutation represents the final step in the auction process, marking the asset as officially won by the highest bidder and concluding the transaction.

CancelListing

The CancelListing mutation in used to cancel a listing on the Enjin Blockchain marketplace. This operation is typically performed by the seller or the system administrator and is used to remove an asset from a marketplace listing.

mutation CancelListing {
  CancelListing(listingId: "0x101d16dc0fa25d77a92bcb6cde34e8ad1e85d96cd6a4a78eb68acc4f82d37f20") {
    id
    transactionId
    transactionHash
    state
    encodedData
    method
    wallet {
      account {
        publicKey
        address
      }
    }
    idempotencyKey
  }
}
{
  "data": {
    "CancelListing": {
      "id": 11295,
      "transactionId": null,
      "transactionHash": null,
      "state": "PENDING",
      "encodedData": "0x3201101d16dc0fa25d77a92bcb6cde34e8ad1e85d96cd6a4a78eb68acc4f82d37f20",
      "method": "CancelListing",
      "wallet": {
        "account": {
          "publicKey": "0x68b427dda4f3894613e113b570d5878f3eee981196133e308c0a82584cf2e160",
          "address": "cxLnsZcpE1xETr7TQrMCCsRYpSfpHPUpJUFAfiZdZvU6Ccy4B"
        }
      },
      "idempotencyKey": "bfdb8fe9-3d93-4322-bf16-077c9566050d"
    }
  }
}

Use Case:

  • You can use the CancelListing mutation when you want to:
    • Remove an asset from a marketplace listing.
    • Take an asset off the market temporarily or permanently.
    • Manage the availability of assets in the marketplace.

By canceling a listing, you ensure that the asset is no longer available for purchase in the marketplace. This can be useful when an item is no longer for sale, is undergoing maintenance, or if the seller wants to withdraw it from the market for any reason. The cancellation is a critical aspect of marketplace management and allows you to maintain control over the assets listed in your platform.