Sell a NFT
The following sample will show you how to sell a NFT using the Hedera Hashgraph and Filecoin to store the media. We will first generate a request for the end user. Once validated, you will get notified for the NFT's selling success.
Prerequisites:
Getting startedStep 1: Import the following modules
Let's continue building on the index.js from the previous example (Environment Set-up) and add the following modules:
const { Client, CategoryNFT } = require("@xact-wallet-sdk/client");
require("dotenv").config();Step 2: Initializing
When initializing a NFT's selling, a request will be sent to the end user
/* Update the fields with your informations */
const fromAccountId = '' /* Account Id of the Seller */
const hbarAmount = 10 /* Unit Price per NFT in Hbar */
const nftIds = ['1@0.0.123456'] /* Array of nftIds to sell */
/* You can specify a quantity if you prefer to let us choose randomly for you */
/* But nftIds field cannot be set with quantity */
const tokenId = ''; /* token Id of the NFT */
const isCollection = ''; /* Sell the nftIds under one QR Code */
/* Optional NOT YET AVAILABLE - The NFT could only be sell to accountId present on that list */
const accountIds = ['', ''];
/* Optional - Add a middle men in order to collect fees */
const middleMen = {
middleManAccountId,
middleManTypeOfFees: MiddleManFeesType.HBAR,
middleManFees: 10
};
/* If you're selling by nftIds replace quantity by ndtIds */
await client.sellNFT({fromAccountId, nftIds, hbarAmount, tokenId, accountIds, isCollection, middleMen});Step 3: Listen for the NFT's sell
Finally get notified when your NFT has been successfully set in sale !
Code Check ✅
Your index.js file should look like this:
Last updated