NFT-Based Luxury Watch Certificate
Folks who trade used luxury watches know how important it is for your watch to come with a certificate. Typically in the form of a credit-card sized plastic or a folded piece of paper with a serial number, the name of the first owner, and the date of purchase, the watch certificate is an important determinant of the watch’s resale value.
This is so because of authenticity. By matching the serial number stated on the certificate and the serial number engraved on the watch case, a buyer will be relatively well assured that the watch is authentic. This is not foolproof because it is still possible to manufacture a replica of a watch, and then print a fake certificate.
Can Non-Fungible Tokens (NFT) save the day?
Here’s a demo of how it might.
The Scenario
An imginary watch manufacturer, BreitLex has decided to switch to issuing NFT tokens to replace paper-based watch certificates. To do this, the company developed BreitLex-NFT, a Smart Contract to mint a BreitLex NFT token for every new watch it manufactures.
When John buys a watch from BreitLex, the ownership of it’s corresponding NFT token proves that he owns it. If John decides to sell the watch to Mary a few months later, he can hand the watch, and concurrently transfer the ownership of the NFT token to her.
Let’s execute this scenario. Setup Metamask on your Chrome browser, with 3 accounts to represent BreitLex, John and Mary.
In this scenario, we use Remix, to compile, deploy and run the NFT Smart Contract.
The watch certificate will be saved a JSON file on the Interplanetary File System (IPFS). An image of the watch will also be saved on (IPFS). To upload and pin the certificate and image to IPFS, you will need a Pinata account. You may register a Pinata account for free.
Deploying the NFT Smart Contract
To kickstart the scenario, BreitLex deploys its BrietLex NFT Smart Contract.
Visit Remix. Add a new file to the workspace and name it “breitlexNFT.sol”. The Solidity codes for breitlexNFT.sol can be downloaded from my Github account. I built the source code for breitlexNFT.sol by generating an ERC721 contract with OpenZepplin Contracts Wizard. I also made modifications to its mint()
function to allow BreitLex to add a link to the watch’s information on IPFS (more on this later).
Compile the Smart Contract.
And then deploy it on the Ethereum Blockchain.
Minting a new BreitLex NFT
When BreitLex manufactures a new watch, it takes a picture of it and puts together the information about its model, manufacture date, and serial number, and pins them to IPFS.
To do this, create a Pinata account. Then upload a file.
Upload the image of the newly manufactured watch.
Then upload the JSON file that contains the watch’s model, manufacture date as well as a URL to the watch image.
Here’s how the JSON file looks like. Notice that the image URL of the watch is written into the watch’s JSON file.
{
"model": "Sub-Timer",
"manufactured-date": "2021-01-01",
"serial-number": "112235",
"photo": "https://ipfs.io/ipfs/QmVaN1SPzDWoWLocxvZwsufxoRxwHmHuUGc2hyPTnDLVuC"
}
https://ipfs.io/ipfs/QmbbV9eB1hahApMgVadxn3gPfLs6gD6LEZYfrKtGzks9XK
BreitLex is now ready to mint a new BreitLex-NFT token for its newly manufactured watch.
As part of the minting process, we will be saving the URL of the watch’s information which we have pinned to IPFS earlier into the BreitLex NFT token.
Return to Remix. At the mint
function, enter the following:
- _to: <BreifLex’s MetaMask Wallet Address> e.g. 0x02d4806b89913ed833010aC3282bE2EaAc2D2BaE
- tokenURI: <the URL of the watch’s information on IPFS e.g. https://ipfs.io/ipfs/QmbbV9eB1hahApMgVadxn3gPfLs6gD6LEZYfrKtGzks9XK
Click [transact] to mint.
Visit Etherscan to view the BreitLexNFT token contract. A new BreitLexNFT token has been minted.
Click on “BreitlexNFT (BNFT)” at the Token Tracker to view the total number of token holders, transfers that have taken place as well as details of each individual token minted.
The BreitLex NFT Smart Contract gives every token it mints a running serial number – TokenID. In a real-life implementation, BreitLex could etch this TokenID on the watch’s case.
Since this is the first token minted, the TokenID is 0.
At Remix, enter “0” at the tokenURI()
function to see the IPFS address that holds the watch’s information. A buyer may review the details of the watch by executing this step.
To identify the watch and its BrietLex NFT token owner, click on the ownerOf()
function to view the owner’s wallet address.
When a BreitLex NFT token is minted, it is added to the wallet of the account that deployed the BreitLex Smart Contract (i.e. BreitLex Watch Manufacturer itself)
To see the BreitLex NFT token in BreitLex’s MetaMask wallet, click [Add Token]. Then paste the BreitLex NFT Smart Contract address into the text field.
Finally, click [Add Tokens] to see the new BNFT token that BrietLex has just minted.
Selling the Watch (And Transferring The BreitLex NFT Token to the New Owner)
Assuming that BreitLex has just sold the watch to John, it now needs to transfer the watch’s BreitLex NFT token to him.
This step will be similar to how the salesperson at the watch boutique fills in the warranty card when he registers your purchase.
To perform a token transfer in the Breitlex NFT Smart Contract, execute the transferFrom()
function with the following information:
- from: <wallet address of the current watch owner> (its Breitlex itself at the moment)
- to: <wallet address of the new owner> (John)
- tokenID: <unique ID of the token to transfer> (0)
Now assuming that John decided, at some point in the future, to resell the watch to Mary, this is what he will do.
John visits the BreitLex NFT Smart Contract and execute transferFrom()
with the following information:
- from: <wallet address of the current watch owner> (John)
- to: <wallet address of the new owner> (Mary)
- tokenID: <unique ID of the token to transfer> (0)
The best part about this NFT-based implementation is that anyone can view the full history of the watch’s Breitlex NFT Token transactions.
Want to know how many times the watch has changed hands? The date it was first sold? How it looks like? Just ask the BreitLex NFT Smart Contract!
Why is NFT a Good Replacement for Paper-based Certificates?
- It’s permanent: Unlike paper-based certificates that deteriorate with time or gets lost when the watch changes hands, NFT tokens are permanently recorded in the Ethereum Blockchain. Over time, the watch manufacturer may cease to exist, but records of the watches that it manufactured live on as NFT Token on the Ethereum Blockchain forever.
- It’s unfakable: A watch buyer simply needs to visit Etherscan to view BreitLex’s Smart Contract, the BreitLex NFT tokens minted, and then cross-reference the watch details on IPFS to be assured that it is authentic.
- Its history is known: Details about how the watch changed hands are well documented as part of the token’s transaction. Now you know that you are the 4th, 5th, or nth owner!
But hang on, what happens if the watch’s photo and watch information in IPFS gets deleted? Wouldn’t all be lost?
Here’s the good news. IPFS is known as “the permanent web”. Using the concept of peer-to-peer file system storage, IPFS will significantly minimize the chances of pinned data disappearing on the network. BreitLex, as the watchmaker wouldn’t unpin the information from IPFS. Subsequent owners of the watch do not have the right to unpin the watch’s information from IPFS either.
Find out more about how data stored in IPFS is “permanent” here.
Hang on again. What if Mary sells the watch to Jane, but didn’t transfer its NFT token to her?
That’s like selling a watch without handing over its certificate to the new owner. It will be impossible for the new owner to take over the ownership of the watch’s corresponding NFT token if the seller does not execute an ownership transfer. However, it is still possible to retrieve the watch’s information by performing a query on the BrietLex NFT Smart Contract. That’s not too bad! If this was a paper-based certificate, records of the watch would have been lost forever (unless the watch manufacturer entertains authentication requests – yes they do, with a fee).
Hang on again, what if someone unauthorized mint a new token by executing the mint() function on the BreitLex Smart Contract?
The BreitLex Smart Contract only allows the mint()
function to be called by the contract owner – which is the wallet address that deployed it.
What’s stopping someone from uploading a new JSON watch information record onto IPFS for a watch that was never manufactured?
The URI of the JSON watch information wouldn’t have been saved in any BreitLex Tokens!
Can’t a watch replica maker simply etch the same serial number and TokenID on a fake watch?
Yes. That will be similar to a fake watch with the same serial number of a genuine watch etched on itself. Although NFT doesn’t solve this problem, it does make it easier to spot. When you are buying the watch used, simply ask the seller to show you their digital wallet with the NFT token of the watch they are selling you. If he doesn’t also own the token, better call off the deal!
Wait. Isn’t this cumbersome? Everyone needs to execute codes in this process!
No, BreitLex can build a Decentralized App around this process. Each watch owner can be given their own digital wallet smartphone app to store and transfer their BreitLex tokens. In the next part of this tutorial, I will describe how to build this app.
What’s Next?
I will be developing this demo further and releasing this tutorial in multiple parts as follows:
- NFT-Based Luxury Watch Certificate: How It Works (this part)
- NFT-Based Luxury Watch Certificate: Decentralized App Demo
- 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:
- 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.
Icons made by Pixel Buddha from www.flaticon.com
Icons made by Freepik from www.flaticon.com
Icons made by Vitaly Gorbachev from www.flaticon.com