Skip to main content
BETA
HomeIntegration BuilderAPI ReferenceGuidesChangelog
View Mirror World on Github
Join the Discord server

Creating an NFT Marketplace for your ERC721/ERC1155 NFT collection

By MirrorWorld

In this guide, you will create an NFT marketplace for listing and trading NFT for the NFTs you created using the Mirror World SDK. If you do not yet have a collection, please follow this guide to create an ERC721/ERC1155 collection, mint some NFTs and return to this page to create an NFT Marketplace to your collection.

That's it! Let's move forward to the pre-requisites. Make sure that your collection_address is prepared, you have your API credentials (API Key and Secret Access Key) ready, and your wallet has been funded. If you haven't funded your project wallet yet, follow the instructions in the "Funding your project wallet" section. If you don't have your API credentials yet, refer to the "API Credentials" section for instructions on how to acquire them.

Pre-requisites

  • Your collection_address is prepared. You may also prepare multiple collections
  • Your have prepared your API credentials (API Key and Secret Access Key).
  • Your project wallet has been funded.

Funding your project wallet

Skip this section if your project wallet is already funded

Before deploying your Marketplace Instance, you need to make sure that your project wallet is funded with enough funds to pay the gas fee for deployment.

You can see your project wallet on the top-right of the developer dashboard when you select the Chain/Network combination on the developer dashboard.

  • For Mainnet, you can fund your wallet by directly transferring funds into your project wallet from an external wallet, or exchange.
  • For Testnet, you can use a faucet to get tokens. Examples of popular testnet faucets include https://mumbaifaucet.com/ and https://goerlifaucet.com/

API Credentials

Skip this section if you already have your API credentials

Minting NFTs requires the following API credentials:

  • API Key - passed in to the x-api-key header. If you don't have an API Key, please use the Getting Started guide to create a project and get the API Key for your project.
  • Secret Access Key - passed into the Authorization: Bearer <SECRET_ACCESS_KEY> header. If you don't have your Secret Access Key yet, please follow this guide to acquire your Secret Access Key.

Deploying your Marketplace Instance

Behind the scenes, Mirror World uses the widely supported Seaport Protocol to orchestrate marketplace listings and transactions.

Seaport is a marketplace protocol for safely and efficiently buying and selling NFTs. Each listing contains an arbitrary number of items that the offerer is willing to give (the "offer") along with an arbitrary number of items that must be received along with their respective receivers (the "consideration").

With HTTP

You can use the Deploy Marketplace Instance API to deploy your NFT Marketplace instance.

Replace :chain and :network parameters to the chain and network combination you want to deploy to.

Here is the full table of supported chains.

Required parameters:

  • seller_fee_basis_points: The seller fee basis points

Optional parameters:

  • payment_token: The payment token address. Default is null, which means the native token
  • storefront: The storefront UI configuration details. Used when deploying a storefront client application The storefront configuration conforms to the following schema:

    export interface IStorefrontConfig {
    subdomain: string
    name: string
    description: string
    logo?: string
    banner?: string
    }

  • collections: The array of ERC721/ERC1155 collections to be added to the marketplace.

In this example for the payment_token, we shall use polygon's MATIC testnet token address (0x0000000000000000000000000000000000001010)

Below is an example code snippet. Take note of the variables to be replaced


curl --location 'https://api.mirrorworld.fun/v2/:chain/:network/asset/marketplaces/create' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Authorization: Bearer <YOUR_SECRET_ACCESS_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"payment_token": "0x0000000000000000000000000000000000001010",
"seller_fee_basis_points": 100,
"collections": ["SOME_COLLECTION_ADDRESS"]
}'

With JavaScript SDK

This example uses the JavaScript SDK to create an NFT marketplace on Polygon Testnet.


import { MirrorWorld, Polygon, EVMContractType } from "@mirrorworld/web3.js"
const mirrorworld = new MirrorWorld({
apiKey: "YOUR_API_KEY",
chainConfig: Polygon("mumbai-testnet"),
auth: {
secretAccessKey: "YOUR_SECRET_ACCESS_KEY",
},
})
const payload = {
payment_token: "0x0000000000000000000000000000000000001010",
seller_fee_basis_points: 100,
}
const marketplace = await mirrorworld.Polygon.Asset.createMarketplace(payload)
console.log("my new marketplace", marketplace)

Successfully creating a marketplace returns an object with the marketplace_address property. This represents your marketplace instance. Keep this address as you will use it to transact with your marketplace.

You have successfully an EVM-compatible Marketplace.

Listing, Buying and Transacting with your NFT Marketplace

You can list your NFTs using the List NFT API.

With HTTP API

Required parameters:

  • collection_address: The address of the collection
  • token_id: The token_id of the NFT
  • price: The price of the NFT
  • marketplace_address: The address of the marketplace

Optional parameters:

  • confirmation: The confirmation level of the transaction. Default is finalized. Allowed values are finalized and confirmed

Replace :chain and :network parameters to the chain and network combination you want to deploy to.

Here is the full table of supported chains.


curl --location 'https://api.mirrorworld.fun/v2/:chain/:network/asset/auction/list' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Authorization: Bearer <YOUR_SECRET_ACCESS_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"collection_address": "<YOUR_COLLECTION_ADDRESS>",
"token_id": 1,
"price": 0.1,
"marketplace_address": "<YOUR_MARKETPLACE_ADDRESS>"
}'

With JavaScript SDK

This example uses the JavaScript SDK to list an NFT on your marketplace


import { MirrorWorld, Polygon, EVMContractType } from '@mirrorworld/web3.js';
const mirrorworld = new MirrorWorld({
apiKey: 'YOUR_API_KEY',
chainConfig: Polygon("mumbai-testnet"),
auth: {
secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
},
})
const payload = const payload = {
collection_address: 'YOUR_COLLECTION_ADDRESS',
price: 0.1,
token_id: 1,
marketplace_address: 'YOUR_MARKETPLACE_ADDRESS',
}
const listing = await mirrorworld.Polygon.Asset..listNFT(payload);
console.log("token listing", listing)

Other Marketplace Transactions

Getting Marketplace Events

You can query the listing events for your Marketplace in the same using the following APIs:

Congratulations! You can now transact with you EVM Marketplace.

Edit this page on GitHub

Copyright © Mirror World, Inc. 2023
On this page

Home

Integration

Guides

API Reference

Changelog