Skip to main content

Marketplaces

thirdweb supports marketplace contracts where a user can list an NFT and receive funds when a buyer purchases it.

Integration is identical to a checkout using a CUSTOM_CONTRACT contract type. Follow the guide on integrating custom contracts, and ensure the mintMethod identifies the method on your smart contract that purchases the NFT (a "buy" method).

Your contract method should do the following:

  • Accepts the wallet address where the NFT should be delivered.
  • Accepts payment in the chain's native coin or USDC / ERC-20 tokens from the caller (msg.sender) of the method.
  • Transfers the NFT from the seller to the recipient's wallet address. Remember: msg.sender is thirdweb's minter wallet and not the buyer's wallet address. Your function needs to ensure the recipient is specified in the argument list.

Third-party marketplaces

Checkouts also supports purchases of tokens listed on third-party Marketplaces such as OpenSea, LooksRare, or X2Y2.

Purchases on third-party marketplaces are facilitated by the Reservoir contract. You can create a Checkout for an item listed on any supported Reservoir marketplace.

Integration

  1. Register a new contract
    1. Set your Contract Type to Reservoir.
    2. Leave Contract Address blank.
  2. Create a checkout link with the ID of the registered contract. We recommend using one-time checkout links as the underlying token listed on third-party marketplaces may sell out.

Code sample

const body = {
contractId: "REGISTERED_CONTRACT_ID", // this contract should be registered with Reservoir as the contract type
title: "My Checkout",
contractArgs: {
// TIP! You can add more than 1 token to the nfts array and we'll accept all of those listings!
nfts: [
{ token: `COLLECTION_CONTRACT_ADDRESS_1:TOKEN_ID_1` },
{ token: `COLLECTION_CONTRACT_ADDRESS_2:TOKEN_ID_2` }
]
},
};

const resp = await fetch("https://payments.thirdweb.com/api/2022-08-12/checkout-link-intent", {
method: "POST",
headers: [
"Authorization": "Bearer MY_THIRDWEB_API_SECRET_KEY",
"Content-Type": "application/json",
]
body: JSON.stringify(body);
});
const { checkoutLinkIntentUrl } = await resp.body();

// Navigate users to this URL to purchase your NFT.

Please update the following variables:

  • REGISTERED_CONTRACT_ID: The Contract ID from Step 1.
  • COLLECTION_CONTRACT_ADDRESS: The contract address of the NFT collection.
  • TOKEN_ID: The token ID of the NFT from the listing. This listing must exist on one of Reservoir's supported marketplaces.
  • MY_THIRDWEB_API_SECRET_KEY found on your API Keys dashboard page.

For a more embedded and branded checkout experience, you may also sell marketplace NFTs with Checkout Elements.