Skip to main content
Tutorial
Intermediate

How to Sell an NFT

In this tutorial, you will learn how to sell an NFT.

Deploy an ERC721

You will start by deploying an ERC721 that will be the base of the NFT you want to sell.

Upload Contract-level metadata on IPFS

To enter a name on the marketplace’s dashboard and perceive fees when someone sells one of our NFTs, we need to implement the contract-level metadata.

Here are the values we will use:

{
"name": "My Super NFT for Sale",
"description": "You’ve never seen NFTs this beautiful.",
"image": "",// the URI of your image, for example ipfs://CID_OF_YOUR_IMG
"external_link": "",
"seller_fee_basis_points": 100,
"fee_recipient": "PUT YOUR ADDRESS HERE"
}

We now have the content of our metadata, we need to upload it on IPFS.

To upload our files on IPFS we will now use the Starton IPFS pinning service.

As the contract-level metadata only needs to be uploaded once, we can directly do it from our dashboard.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Enter JSON content.
  5. Enter a name for the file.
  6. Click Upload.

Once done, a column “CID” appears with a value for our file. We will use this data for the Contract Uri Suffix of our smart contract!

Upload a file on IPFS

We also use IPFS to store the content that will be referenced in our deployed contract. We do not store the content directly on blockchain as it is too heavy and would induce a very high cost. The best solution is to store it somewhere else and only store a reference on-chain.

  1. Go to IPFS.
  2. Click Upload.
  3. Select File(s).
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.

Upload the metadata of your content on IPFS

info

Consult the metadata standard format on your marketplace's documentation.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Everything we need to sell your NFT is an auction is done.

Deploy the base contract

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 NFT Smart Contract template.
  2. Enter:
    • a name for your contract,
    • a wallet to sign the transaction,
    • a blockchain / network on which to deploy, here BNB testnet.
    • the parameters of our contract. For more information on parameters, check out the Deploying a Smart Contract.

For example, we can call our contract “Best NFTs on BNB” and deploy it on the BNB Testnet network.

The following constructor parameters are:

  • definitiveName: This name stored on blockchain, we will use “Best NFTs on BNB”.
  • initialTokenUri: This is the public URL that contains the metadata of the collection. Here it starts with ipfs://ipfs/,
  • initialContractUri: The URI of the metadata that will be used to give more details about the description.
  • initialOwnerOrMultisigContract: The address that will own the NFT Collection.

We can finally deploy our contract!

Deploy an ERC721 Sale

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 Sale template.
  2. Enter:
  • definitiveTokenAddress: The token address of the ERC721 that you want to sell.
  • definitivePrice: The price that the NFTs will be sold for.
  • definitiveStartTime: The time when the sale will begin and users can mint tokens.
  • definitiveEndTime: The time when the sale will end and users couldn't mint anymore tokens.
  • definitiveMaxTokensPerAddress: The maximum amount of tokens that can be minted by a single address.
  • definitiveMaxSupply: The maximum amount of tokens that can be minted during the sale.
  • definitiveFeeReceiver: The address that will receive all the price paid to mint the NFTs.

Interact with your contract

Once your NFT is sold, you can withdraw the amount received during the sale by interacting with the smart contract.

  1. On the smart contract page, click Interact.
  2. Select the withdraw function.
  3. Click Run.

The amount is transferred from the address of the smart contract to the address of the fee receiver.

Loubna Benzaama

Lead technical writer


Created:

February 26, 2024

Reading time:

4 min


Content