List NFT

This guide will walk you through the process of listing NFT(s) using the Rarible SDK.

Prerequisite

Follow our Getting started guide to install needed libraries and instantiate SDK.

Listing an NFT

To list an NFT, follow these steps:

  1. Connect Wallet: Ensure the user's wallet is connected. This can be done using wallet connect protocols.
  2. Create an NFT Item: Before listing, you need to have an NFT item. If you don't have one, you can create it using the Rarible SDK's minting function.
  3. List the NFT: Use the sell function from the SDK to list your NFT. Here's an example:
const orderId = await sdk.sell({
  itemId: "ETHEREUM:YOUR_NFT_CONTRACT_ADDRESS:TOKEN_ID",
  amount: 1, // amount of NFTs to sell
  price: "0.1",
  currency: toCurrencyId("ETHEREUM:0x0000000000000000000000000000000000000000"), //check toCurrencyId jsdoc for more examples
});

console.log(`Successfully listed. Order ID: ${orderId}`);

*Replace YOUR_NFT_CONTRACT_ADDRESS and TOKEN_ID with your NFT's contract address and token ID.

  1. Confirm Transaction: The user will need to confirm the transaction in their wallet and sign order message.
  2. Check Listing: Once the transaction is confirmed and order message is signed, the NFT will be listed on Rarible

Conclusion

Listing NFTs using the Rarible SDK is a straightforward process. By following the steps outlined in this guide, developers can easily integrate NFT listing functionality into their applications. Remember to handle user authentication and wallet connections securely, and always test your implementation thoroughly.