Non Fungible Tokens
In this session, we will learn how to create digital art using Non-Fungible Tokens (NFTs) with their metadata and specific attributes.
Start coding
Create a new file or edit index.ts
Running this to ensure everything works should log a few things to the console. If you are running this from your node environment, don't forget to runnpm i xrpl
to add it to your project.
Creating NFT
First, to create digital art, you need to create an NFT using NFTokenMint
. You need one available wallet for that. For an NFT to host metadata and have specific attributes, we usually provide a JSON file for the metadata. You can gain a better understanding of the OpenSea metadata standards (https://docs.opensea.io/docs/metadata-standards). When creating the NFT, you will use a URI field to include the URI to the metadata of the NFT you want to create.
At this point, you should have one account with an NFT created.
Putting your NFT on sale
Once you have your NFT, you may want to put it on sale and allow people to bid on it. Thanks to XRPL built-in functions, the NFT marketplace is already provided within the ledger. We only need to use NFTokenCreateOffer
to put our NFT up for sale.
At this point, your NFT should be on sale, and it will be available for someone specific or anyone to buy.
Extra credits
Canceling your offer
You can cancel your NFT offer, you will need to use the NFTokenCancelOffer function to do so (https://xrpl.org/docs/references/protocol/transactions/types/nftokencanceloffer/)
Burning your NFT
You can burn your NFT, you will need to use the NFTokenBurn function to do so (https://xrpl.org/docs/references/protocol/transactions/types/nftokenburn/)
Last updated