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
- Register a new contract
- Set your Contract Type to Reservoir.
- Leave Contract Address blank.
- 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
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.