First IOTA Smart Contract powered by Qubic Lite enables instant TOQEN Micro-Payments 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.

Smart Contracts on Qubic (image from, edited)

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.

So how does it work?

The payer starts with a random hash (hash #0) which is kept secret. The hash is hashed to produce hash #1, which is hashed again to produce hash #2 etc. Only the last hash in the chain (hash #N, with N 100,000) is published.

This microhash chain works in a single direction: If you know microhash #80, you can hash it to find out what microhash #81 is. But it’s practically impossible to find out microhash #79 without the help of the payer. To pay, the payer simply reveals the hashes in descending order (up to hash #0).

microhash table (N: 100; step: 1,000 TQN)

Upon settlement, the smart contract pays the payee an amount of funds proportional to how far back he or she is able to reconstruct the chain, beginning by hash #N. This gives every hash an associated value (see microhash table).

The smart contract can easily verify how much the payer has paid to the payee by testing how often the microhash can be hashed before it equals hash #N.


Sending a tiny hash is simple and as fast as your internet allows. You can pay-per-decisecond and send money around the globe within fractions of a second instead of waiting for confirmation. Moreover, moving transfers to an off-chain settlement layer increases scalability and can reduce multiple thousands of transfers between sender and receiver to only two single on-chain transactions (one to open and one to settle the channel).

Try it out Yourself

The whole process is quite technical. But here is how to do it if you are eager to try it out yourself:

  • install v0.5.0 of the QLRI
  • run the QLRI and open Qlite Web
  • install the TOQEN wallet from Qlite Web
  • ask me on discord (microhash#4229) for some TQN to play with
  • follow the steps shown in the demo video:
Demo Video: How to use MicroHash channels.

Potential Use Case: Rewarding Oracles

This instant micro-payment layer might be used to incentivize oracles: The qubic author could reward every oracle with a few TQN after each completed epochs for calculating the correct results. This could be automated and added as a feature to a future QLRI (ql-node software) version.

The actual beauty of this whole concept lies in the fact, that oracles (2nd layer) would be rewarded through the MicroHash smart contract (4th layer), which is built on top of TOQEN (3rd layer) which is a qubic processed by other oracles (again 2nd layer).

It’s a quite interesting feedback loop: basically the oracles are rewarded through a service they themselves provide.

Complexity and Conclusion

The development of MicroHash was quite complicated since it required a high level of abstraction to work on a 4th layer. The qubic code of this smart contract is actually even more complex than that of the underlying smart contract platform (TOQEN):

qubic code comparison: TOQEN on the left, MicroHash on the right

But this is the minor part of the entire code. Additionally, I extended the TOQEN wallet to include a GUI for the creation and settlement of these channels. And don’t forget about the software to run the API nodes which filter out valid API requests from the Tangle and submit them to the MicroHash qubic.

It was exhausting for me, the person most familiar with Qubic Lite. Therefore it would be purely insane to expect anyone else to construct anything of this extent on top of TOQEN themselves. I do not even expect more than two handful of people to actually test this whole thing by setting up their own microhash channels.

I think we have to settle down here and accept that the smart contract ability of Qlite will most likely stay a PoC that shows what is possible. Instead of reworking this into a user-friendly development environment where anyone can set-up a smart contract with a few lines of codes, we might just as well wait for the official Qubic.

Nonetheless, this PoC proves that smart contracts on the Tangle are feasible. And if IOTA is technically able to support smart contracts, it is just a matter of time before this develops into a serious and integral application.

More importantly: The mere fact that it was even possible to build such a completely abstract construct entirely on top of the Tangle, truly highlights what IOTA is capable of.