Inspiration
A lot of articles, research and use cases about NFTs brought me to this idea: through blockchain, we can prevent counterfeited items, we can track real-world items, we can prove ownership without the need of a bill or any easily falsifiable document. Moreover, most of the new released smartphones are now NFC (Near Field Communication) compatible, so it’s becoming an accessible technology that would be really useful with blockchain.
What it does
The project links NFC technology to blockchain: if you scan one of our NFC tag with a compatible smartphone, you’ll be redirected to our mobile application, on the token page. Then you’ll be able to verify two things:
Authenticity
To guarantee authenticity, I used the NFC technology. But you will probably wonder: « how does it prevent from counterfeiting, as the data stored on an NFC tag is not protected and everybody can copy it?». Well, anybody can indeed copy the NFC tag, but there is something unique in each tag: the ID. The ID of a tag is set by the constructor and can’t be modified. Which means we can compare two tags with the same data and figure out which one is the authentic one.
Ownership
To guarantee ownership, we provide an optional functionality, which is, « claiming ownership ». By optional, I just mean that this project intends to target general public, and not only blockchain regulars. So we will not ask customers, when they buy real-world items, to provide a blockchain wallet. Instead, we provide a way to claim the token linked to the item, only if the customer wants to. To do so, the customer will have to do a phone number verification (number that have been provided when the customer bought the item), and then, if he’s indeed the owner of the phone number, will be able to claim the token.
Why would we need tokens linked to our real-world Items ?
- METAVERSE: you'll be able to use your real-world items into games or metaverses
- To replace bills or any easily falsifiable document
- To verify that someone own a item he pretend to own (ex: you want to buy something on Ebay)
- To showcase your items
- To track the lifecycle of items
How we built it
To build it, I used several technologies:
- For the front-end: ANGULAR
- For mobile: IONIC
- DB: Firebase Firestore
- Server & External Adapter: Google Cloud Functions
- Chainlink KOVAN node deployed using the service naas.link
- IPFS Storage: nft.storage
The main contract is derived from the OpenZeppelin ERC1155 standard, and allow us, in addition of the possibility to track user balances, to track each unit. We can now navigate into tokens in two ways: from an address to a balance, and from ids to an owner. How do we do that ? We just implemented a new mapping:
mapping ( uint => mapping (uint => UnitData)) _unitData ;
We now introduce a new parameter, the unitId. There are now two Ids to track an item:
- tokenId: which is related to the ‘model’ or ‘type’, it’s linked to metadata (such as name and uri in our case).
- unitId: which is related to a unit of this token. Using tokenId and unitId, we can access to the unitData, which contains in our case a status (‘minted’, ‘sold’, ‘owned’, ‘lost’, ‘stolen’, etc) and a tagId (id of the NFC tag) Just imagine a bag brand: for each bag model (tokenId), a lot of units will be created and sold (unitId).
NFC technology (Near Field Communication)
We used NFC technology to guarantee authenticity : To do so, when a minter mint a new unit through our minter mobile app, few things are done:
- Firstly, an NFC tag is scanned so we can fetch the tag ID
- Secondly, the token unit is minted with the tag ID
- Finally, a deep link to this token unit is written on the NFC tag, and the tag is locked (read-only mode)
Chainlink phone number verification JOB
I used chainlink, with Google Cloud Services and Twilio, to condition access to a smart contract function, to a phone number verification. To do so, there are several steps:
- Firstly, remember that when an item is bought, the seller save the phone number of the customer off-chain
- Secondly, to verify the number, a first HTTP call is done off-chain (as it doesn’t need to be on-chain) to our server, to first fetch the phone number stored on Firestore, using tokenId and unitId, and secondly, to call the Twilio API, to request an SMS verification.
- Thirdly, when the Sms is received, the customer can send the PIN through the smart contract, which will call, through our job and ou external adapter, an other cloud function which will: fetch again the phone number, and then call Twilio to verify the PIN. It then sends back the result. The fulfill function will then give or not the permission to the sender to claim the token (we don’t directly send the token as it is using too mush gas).
- Finally, the customer can, if the permission has been gave, claim the token throught the smart contract.
Challenges we ran into
Using chainlink services properly was a big part of the challenges. I’m a Windows user, so I had hard time trying to run a chainlink node locally. I first tried to use UNIX shells for Windows, then I tried to use my Ubuntu dual boot, but all of this took me a lot of time without any success, so I decided to run the node using a cloud service (naas.link). Other questions were hard to figure out:
- How to increase de default external adapter call timeout (which is initially 3000ms) ?
- Is it possible to fulfill multiple values?
But there are also other challenges I faced:
- Signing transactions from a mobile application
- Signing message and check signature from a cloud function
- Reading and writing NFC tags from a mobile app
- Deep linking NFC to our app
- Dealing with the maximum smart contract size
Accomplishments that we're proud of
I’m proud of all of this project. I managed to do all of what I wanted to, either on authenticity part than on ownership. I successfully implemented chainlink services, successfully implemented NFC technology into mobile application, with reading and writing, successfully extended ERC1155 standard to track units, etc…
What we learned
I learned a lot about the following technologies:
- Chainlink services
- Web3
- NFC technology
- IPFS
What's next for NFC for real goods
- Testing this prototype with brands
- Improving UI/UX and design (which is really important but was not the main focus during this hackathon.)
- Add all web3 admin functionalities integrations (give role, revoke role)
- Add new roles (seller, supplier)
Built With
- angular.js
- chainlink
- filecoin
- firebase
- google-cloud
- ionic
- nft.storage
- solidity

Log in or sign up for Devpost to join the conversation.