A Decentralized App for Minting, Viewing, and Transferring NFT-based Certificate of Authenticity for Luxury Watches
This is the 2nd part of my series of articles to demonstrate how Non-Fungible Tokens (NFTs) may replace paper-based Certificate of Authenticity for luxury goods such as watches.
Refer to Part 1 to learn the business logic behind how this may work.
I name my imaginary watchmaker BreitLex. In this article, I will demonstrate how BreitLex and watch buyers will use BrietLex’s Decentralized App to mint and transfer NFT-based Certificates of Authenticity.
The BreitLex Decentralized App (DApp) performs the following functionalities:
- Deploy a new BreitLex contract — to begin minting NFTs, the watchmaker must first deploy its NFT Smart Contract
- Transfer NFTs to buyers — when watches are sold between BreitLex and its customers as well as between watch owners, the DApp is used to transfer ownership of NFT Certificates of Authenticity.
- View NFTs — anyone who’s interested to look at the watch, its serial number, manufacture date and to view a picture of it may do so through the DApp
Developers may access the source codes of this project on my Github Repository.
In this scenario, we have 3 accounts, namely, BreitLex (the watchmaker), John (who buys the watch from BreitLex), and Mary (who buys the watch used from John).
To begin minting NFTs as Certificates of Authenticity for its watches, BreitLex first deploys its ERC-721 Smart Contract. To do this, switch to BreitLex’s account on Metamask. Visit the BreitLex DApp at https://jacksonng.org/codetest/nft.
Since this is a brand new contract, just click [Go] to deploy it, followed by [Confirm] on MetaMask.
This deploys a brand new ERC-721 Smart Contract. Note the contract’s address.
Copy and paste the address of the ERC-721 Smart Contract to Etherescan to view it there. Here’s an example.
Minting An NFT for a Newly Manufactured Watch
BreitLex has manufactured its first watch. Click [Mint], then key in the watch’s model number, manufactured date, serial number, and its picture. Then click [Go]. This step performs several actions:
- It makes an API call to Pinata via the BreitLex IPFS JSON Web Service to save the picture on IPFS.
- It saves the watch’s model, manufactured date, and serial number as a JSON file on IPFS via the same BreitLex IPFS JSON Web Service.
- It mints a new NFT and writes the URI of this metadata on the NFT token.
You may view the NFT token on Etherscan by clicking on the Token Tracker of the ERC-721 Smart Contract at Etherscan. Here’s an example.
Newly minted tokens are assigned a running serial number. In this example, the first NFT token is given the Token ID: 0.
To view the watch, anyone can enter BreitLex’s ERC-721 Smart Contract, followed by the Token ID of the watch. The details of the watch, including its owner (for Token 0 at the moment, BrietLex itself, since the watch has been newly manufactured, and just had its NFT newly minted).
When it is the owner of the watch viewing its detail, he has the right to transfer it by clicking the [Transfer] button.
You may also view the details of the NFT token for the watch on Etherscan. It shows here on Etherscan that the NFT for the watch was newly minted just 2 minutes ago.
For the watch owner to view his token in his MetaMask wallet, click [Add Token] at MetaMask, then enter the ERC-721 Token Contract Address. In this example, BreitLex now has 1 BNFT token for the NFT that it has just minted.
Transferring the NFT-based Certificate of Authenticity to the Watch Buyer
Imagine that John comes along and says “I want that watch!”.
Here’s what BreitLex needs to do next. BreitLex clicks on the [Transfer] button at Token ID 0. Then he enters John’s Ethereum wallet address.
This performs a token transfer between BreitLex’s wallet and John’s wallet. The transaction can be seen by reviewing the Etherscan records for Token ID: 0.
If anyone else other than the Token Owner views the token, he can see the watch’s metadata as well as its picture. However, he isn’t allowed to perform a token transfer.
Of course, he isn’t allowed! He doesn’t own the watch!
Once the NFT has been transferred from BreitLex to John, BreitLex’s wallet no longer shows the token. Instead, John now has 1 new BNFT token added to his wallet.
John Sells his Watch to Mary
It’s been a few months and John has gotten bored of his watch. He found a new buyer, Mary. After Mary has accepted and paid for the watch, John now transfers the watch’s NFT-based Certificate of Authenticity to her.
To do this, John visits the BreitLex DApp and enters the watch’s Token ID.
Next, he clicks [Transfer].
He enters Mary’s Ethereum Wallet Address and clicks [Go].
Now Mary owns the NFT token.
Mary may confirm this too simply by visiting the Token’s Etherscan record.
Can Everyone Mint New BreitLex Tokens?
Of course not, only BreitLex can mint BreitLex tokens. Let’s try it.
Using BreitLex’s MetaMask account, click on the [Mint] button.
No problem, a new token can be minted.
Now try this again, but this time, with John’s Wallet.
Notice that MetaMask complains that executing this transaction will result in a transaction error.
Of course, since John isn’t BreitLex and thus does not manufacture BreitLex watches, he has no authority to mint BriexLex NFTs.
Does This Work Only For Watches?
Nope. In fact, it works for similar businesses cases where you wish to represent products with an NFT-based Digital Twin. If the product is valuable enough for you to track individually such as paintings, bags, jewelry, you may consider NFTs. You just need to change the product’s metadata fields that you store on IPFS.
There’s just one more article to complete in this series. In the last article of this series, I will walk through the codes for the JSON Web Service that saves the watch’s metadata and image permanently on the web.
- NFT-Based Luxury Watch Certificate: How It Works
- NFT-Based Luxury Watch Certificate: Decentralized App Demo (this part)
- NFT-Based Luxury Watch Certificate: Explaining the IPFS JSON Web Service
If you enjoyed this tutorial, perhaps you may also wish to read:
- Introducing the Ethereum Development Environment: A step-by-step guide to setting up a development environment for building Decentralized Apps in Ethereum.
- Freelancer Smart Contract: A payment system between a freelancer and his client to ensure both delivery and payment.
- Ropsten Ethereum Faucet: I built an Ethereum faucet to give out ETH on the Ropsten network.
- Voting on a Blockchain: An implementation of a Voting DApp on Ethereum.
- Deploy a Private Ethereum Blockchain in 10 Minutes with Kaleido: Getting a private Ethereum Blockchain up and running in a jiffy.
- Smart Contract Explained by Demonstration: A demo of an Escrow Service Smart Contract DApp — in my opinion, the fastest way to explain to a layman, what Blockchain is.
- Lottery as a Smart Contract: Decentralized Lottery, an attempt to build a lottery system on the Ethereum Blockchain.
Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing
- Best crypto exchange | Top 10 cryptocurrency exchanges in 2021
- 9 Best Crypto Lending Platforms in 2021 | CoinCodeCap
- Best Crypto Trading Bots (FREE and Paid) in 2021
- Best 4 Crypto Trading Signals Telegram Channels
- BlockFi Review 2021: Pros, Cons and Interest Rates | CoinCodeCap
- How to Buy Bitcoin in India? 7 Best Apps to Buy Bitcoin 2021 [Mobile Version]
- Crypto Tax Software — Top 5 Best Bitcoin Tax Calculators 
- Best Crypto Hardware Wallets to Store Bitcoin  | CoinCodeCap
NFT-Based Luxury Watch Certificate: Decentralized App Demo was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.