Scaling Ethereum on-chain with Commitment Hashes and 0% transaction fees

Steven Enamakel
Steven Enamakel
Published in
5 min readNov 18, 2018

--

Commitment Hashes are nothing more than cryptographic IoUs on the Ethereum blockchain. If you still haven’t got the idea, then continue reading.

In this post, I describe a very simple implementation of commitment hashes on the Ethereum blockchain. A Commitment hash is a special hash very similar to how commitment transactions work in the Lightning Network Whitepaper. If you haven’t read it yet, I would highly recommend going through it once.

Commitment hashes are a great way for creating blockchain applications that are simple and easy to use. Commitment hashes don’t need to be broadcast onto the blockchain but the very possession of them ensure that the user can claim something in the future. It’s like an IoU that is given to users.

But before we deep into the what/why of commitment hashes, I first will explain the problem for which I was trying to solve this for.

ENA coins and using the blockchain for music

On June 2018, I had met with Ena Marley, a wonderful and incredibly talented spanish musician who wanted to use her ideas on creating music that’d leave a deep social impact.

After a few weeks of discussion, we decided to launch a project that would create a cryptocurrency that will be used to represent shares in an artist (in this case called as ENA coins). Users/fans of the artist, would use the cryptocurrency to interact with the artist and earn royalties from the artist’s success.

However, the challenge with cryptocurrencies and making it easier for the public to use it

It’s pretty clear that 99.99% of Ena’s fans won’t even know what Ethereum is, let alone have even heard of Bitcoin. Which is a problem because it can really become hard for people to understand how to use the platform.

Since most users won’t have any Ether amongst themselves, the only way for people to interact with ENA coins was if somehow they were to interact with the blockchain and not pay any transaction fees at all.

Which means probably the site would have to pay for the transaction fees on behalf of the user if it needs to make any transaction. This clearly becomes very expensive as the number of users grows.

Using commitment hashes

Commitment hashes are very easy to generate. They are basically signed hashes (in our case, these hashes are signed by our server) that’ll allow the giver to cryptographically commit something (ENA coins) to the receiver (a registered user on the site).

These commitment hashes do not necessarily have to be transmitted onto the blockchain. However the very possession of the hash assures the receiver that he/she can use it to get what he/she wants; and the very creation and deliver of it, ensures the giver that he/she will have fulfilled his/her commitment.

Just like how paper money was used in the 1600s as an IoU for gold, commitment hashes are created to represent IoUs for some action on the blockchain.

The receiver can then send this hash to a public function in a smart-contract which is designed to behave in a specific way if and only if the hash was signed by the giver.

Use case of commitment hashes with ENA coins

In the case of ENA coins, non-crypto users will have an ethereum wallet generated for them from their web browser itself. This wallet will have no ether to pay for gas but it’s address will be used to hold ENA coins.

Generating a commitment hash

To generate a commitment hash, we use the code below which runs on the server-side.

Code from the server-side generating a commitment hash

This hash is what we call a “commitment hash”. The user can now use this hash at any time to claim his/her ENA coins from the ethereum blockchain.

Claiming the IoUs/Commitment hashes

Once the signed hash is created, it can be sent to the smart-contract at any time by the user. Here’s some sample code demonstrating a call made to metamask.

Client-side code that sends the commitment hash to the Ethereum smart-contract

The smart-contract works by first recreating the hash from the input parameters sent to it. Once the hash is valid, the smart contract then verifies that it has been signed by the server. Once that’s done, it then finally mints the new ENA coins to the user and the commitment hash is marked as used.

There’s a nonce in place to prevent anybody from claiming a commitment hash twice.

The end result?

By simply holding a commitment hashes for say 1000 ENA coins, it is as good as saying that the user actually holds 1000 ENA coins because he/she knows that they can later use it to claim coins on the blockchain.

A screenshot of the ‘claim coins’ page where users can claim the ENA coins from the Ethereum blockchain

The website maintains an ethereum full-node, which keeps track of all the commitment hashes that have been claimed and use that to derive the final balance of all ENA coin holders.

Conclusions

With commitment hashes, our website can generate thousands of ENA coin accounts and credit users with coins to incentivise them for certain activities from within the site.

The ethereum blockchain is used for settlement whenever the user wants to take coins into her own hands for which she will need to find ether to pay for gas from somewhere. But for most use cases, the user never needs to know about the Ethereum blockchain at all.

Why use the term commitment hashes?

A few people have come up to me and have said “There’s already a concept called as meta-transactions. Isn’t this exactly the same?”

First off, It’s my wish to confuse everybody by creating a new term altogether. Hence the term “commitment hashes”.

Secondly, Meta-transactions are not IoUs. Commitment hashes need not ever be committed onto the blockchain because the very possession of it assures the user that he’ll get what he’s promised.

Commitment hashes are more easy to use and they can be adapted to many other use-cases. I hope you can build interesting things with it.

--

--