Integrating physical devices with IOTA — The IOTA debit card, Part 1
The full article was originally published by Coinmonks on Medium. Read the full article here.
The 6th part in a series of beginner tutorials on integrating physical devices with the IOTA protocol.
This is the 6th part in a series of beginner tutorials where we explore integrating physical devices with the IOTA protocol. This tutorial is the first part in a sequence of tutorials where we will try to replicate a traditional fiat based debit card payment solution with an IOTA based solution. In this first tutorial we will concentrate on the debit card itself as we learn how to read and write information to the card. In the second tutorial we will be integrating our new payment solution with a physical device that will allow us to pay for its service using the IOTA debit card. Finally we will take a look at implementing a PIN code protection mechanism as an additional level of security when using the IOTA debit card.
Before we continue with this tutorial i would like to issue a warning with respect to not using large amounts of IOTA tokens when playing around with these tutorials. There is always something that can go wrong, and when it does, make sure you don’t loose any extensive amount of IOTA’s. This warning is especially relevant for this tutorial as we will be creating and storing seed’s on an RFID tag. If something where to happen to the tag, you may not be able to recover the seed. One preventive measure you can take is to make a copy of every seed you save on to a tag in case you need to recover it later on.
The Use Case
Now that our hotel owner has is new cleaning log system in place as described in the previous tutorial he wants to tackle an even greater problem that has been bugging him for a while. This problem is related to how he can charge his hotel guests for using common appliances and services located in his hotel; such as the coffee maker in the hotel reception or the swimming pool lockers. People don’t carry coins around anymore and implementing a Visa based payment system would simply be to complex and expensive. As an enthusiastic supporter of the IOTA technology he would like his new payment system to be based on the IOTA token. But to be honest, must people don’t own IOTA’s and have no idea how to get them. Also, most people don’t have an IOTA wallet installed on there mobile phones and let alone know how to use it. After scratching hos head over this problem for a while he comes up with the perfect solution.
What if the guest could use his hotel key card to pay the coffee maker or swimming pool locker? In that case, the guest would simply go to the reception and purchase any quantity of IOTA tokens that would be transferred to his key card. As such, effectively turning his key card in to an IOTA debit card. Each time the guest uses his IOTA debit card to pay for a service, the appropriate amount of tokens will subtracted from his key card and transferred back to the hotel owners IOTA account.
But wait a second, you can store IOTA’s on a key card?
Well, not rally, but you can store an IOTA seed that will allow you to access and spend IOTA’s related to that particular seed.
The main objective of this first tutorial is to implement the functionality required by the hotel owner to create and issue new IOTA debit cards for his guests. This will include functions such as:
- Creating and writing an IOTA seed to a key card
- Retrieving and displaying an IOTA seed from a key card
- Checking the balance for the IOTA seed stored on a key card
- Creating new and unused addresses for a seed stored on a key card in case he wants to send additional funds to the card.
That sounds great but how do we accomplish this in practice? Well, short answer is, we will use our MFRC522 RFID reader/writer from the previous tutorial to effectively convert an RFID tag to an IOTA debit card.
You may ask yourself why there is no function to transfer funds to the card in this list? The simple answer is that it would require sending valued IOTA transactions using the PyOTA library, which is a topic we will save for the next tutorial. Until then, when the hotel owner wants to transfer IOTA tokens to a particular card, he simply uses his favorite IOTA wallet and transfer the funds to the address shown when using the “ Display IOTA debit card seed transfer address” function.
The Mifare RFID tag
In this section we will take a closer look at the RFID tag itself. Check out the previous tutorial for more information about RFID in general, the MFRC522 RFID module and how to install and use it with a Raspberry PI.
Now that we want to read and write custom data to/from the tag, as appose to the previous tutorial where we just retrieved the internal ID of the tag, we should take a closer look at the tag itself and how it works.
The RFID tags we are using in this tutorial are commonly known as the Mifare series of RFID tags. A common feature for all tag’s in the Mifare series is that they operates at 13.56MHz, and that they support authentication and data encryption. The Mifare tag’s typically comes in the shape of a key ring or credit card.