First IOTA Smart Contract by Qubic Lite enables instant TOQEN Transfers via “MicroHash Channels”
First off, excuse the complex headline. You have to understand that this is a quite abstract thing to talk about because it all happens on a 4th layer:
- 1st Layer: IOTA (data transmission, data integrity, data persistence)
- 2nd Layer: Qubic Lite (quorum consensus framework on top of IOTA)
- 3rd Layer: TOQEN (qApp on Qubic Lite; simulates a token blockchain)
- 4th Layer: MicroHash (smart contract on TOQEN protocol)
MicroHash is the first smart contract on the Tangle – and it is already live at this very moment!
Isn’t Qubic basically Smart Contracts anyways?
Not directly. In first place, qubic itself is decentralized computing. A smart contract, however, is an enforced decentralized digital contract that controls an asset (e.g. a token). “Asset” is the keyword here, and the reason why smart contracts are more advanced and go beyond pure computations.
The IOTA Foundation has stated that Qubic will enable smart contracts but has not yet specified how this will be done technically¹. All we know for now is the implementation concept for decentralized computing.
Unfortunately, for smart contracts you cannot just use the IOTA token directly² because it would require changes to the IOTA core protocol that allow us to lock-up iotas. So having a first smart contract working on the Tangle is not trivial at all — and the reason why I had to build three additional layers on top of IOTA to make this happen.
TOQEN as a Smart Contract Platform
Since the native IOTA token does not support smart contracts, it was necessary to build a separate token on top of the Tangle for this purpose. This is the reason why TOQEN was created. It’s basically a blockchain with its own token (TQN).
Once value transactions were live in the TOQEN network, enabling smart contracts was actually super easy. Nothing more was required than to simply allow qubics to hold TQN. Since qubics are decentralized consensus based entities, their TQN holdings themselves are subject to consensus. This is basically the definition of a smart contract.
Introducing MicroHashes
What are MicroHashes?
For the first smart contract, I wanted to create something non-trivial. I decided to build the Lightning Network (BTC) or Flash Channel (IOTA) equivalent for TOQEN. The smart contract I created allows you to send micro-payments via hashes (called “microhashes”).
Creation and Settlement of a MicroHash Channel
First, the payer sends TQN to the smart contract. This way the funds are locked up. The payer can now open a unidirectional channel to the payee. From here on, all transfers happen off-chain. The payer simply sends certain coupon-like hashes (the “microhashes”) to the payee.
When one party requests to close the channel, the payee can redeem the latest microhash. The end balances are then settled with a second on-chain transaction which releases the TQN from the smart contract. The redeemed funds are sent to the payee while the remainder is sent back to the payer.