NFT-Based Luxury Watch Certificate: Decentralized App Demo

0
30

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.

Photo by Pierre Bamin on Unsplash

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.

Architecture

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

The BreitLex DApp saves the watches’ metadata and pictures on InterPlanetary File System (IPFS). It does this by making API calls to Pinata via a JSON-based API service that I run on Glitch.

The Watchmaker and watch owners use the BreitLex DApp on their web browsers and the MetaMask plug-in. The ERC-721 Smart Contract and NFT minting process happens on the Ethereum Blockchain.

Developers may access the source codes of this project on my Github Repository.

Getting Started

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:

  1. It makes an API call to Pinata via the BreitLex IPFS JSON Web Service to save the picture on IPFS.
  2. 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.
  3. 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.

What’s Next?

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.

  1. NFT-Based Luxury Watch Certificate: How It Works
  2. NFT-Based Luxury Watch Certificate: Decentralized App Demo (this part)
  3. NFT-Based Luxury Watch Certificate: Explaining the IPFS JSON Web Service

Stay tuned!

If you enjoyed this tutorial, perhaps you may also wish to read:

Photo by Wilhelm Gunkel on Unsplash
Icons made by
Freepik from www.flaticon.com
Icons made by
Vitaly Gorbachev from www.flaticon.com

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also Read


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.