nahmii, a Gateway to Scalable Virtual Economies (Part 2)

Katat Choi
hubii
Published in
16 min readMar 11, 2020

--

This is the second part of our recent series on blockchain scaling. In the first article, available here, we assessed the two main approaches to scaling — state channels and side chains — alongside the various compromises inherent in each. Today, we’re taking a closer look at our solution to the problem, nahmii, including a demonstration of the key features using its SDK. We’ll also be showing off nahmii’s new open-source web demo, where you can test the full lifecycle of functions within nahmii.

Scaling on nahmii

nahmii is a second-layer scaling solution which can act as an interoperability bridge between different blockchains. Referring back to the ‘Blockchain Trilemma’, discussed in part one, nahmii’s architecture aims to maximise Scalability and Security while relying on base-layer blockchains to achieve a degree of Decentralisation. The protocol is currently live on Ethereum, with plans to port nahmii to other blockchains in the near future.

The nahmii scaling protocol is implemented by a set of Ethereum contracts and an operator backend that together manage transaction states in a trustless way. Its SDK encapsulates the knowledge of how to interact with the protocol.

Our previous article outlined a number of issues that blockchain scaling solutions must address before the technology will be ready for commercial adoption. Before we dive into a technical demonstration of how nahmii solves these problems, let’s begin with a quick summary of what makes nahmii special:

Real-time finality

What is done is done. Finality of payment plays a crucial role in any economy. Yet in some traditional centralised payment systems, it is common to take hours or even days to settle a transfer of value. Even when confirmed, some transactions can still be revoked or reversed at a later point. Taken together, slow confirmations and reversible transactions create uncertainty for businesses which rely on real-time transactions. These risks can be mitigated by blockchain technology, but only when applied correctly.

Most blockchain solutions are designed to maximise decentralisation and security, often at the expense of transaction finality. This is a key failing, as many commercial use cases for payments require real-time transactions.

nahmii regards the real-time finality a must-have feature for its payment function. Both parties to a payment on nahmii can be confident that their transaction is final as soon as the operator publishes a signed receipt. This process typically takes a fraction of a second, comparable to the leading centralised services. The instant finality in payments contributes to nahmii’s advantages over both the centralised payment systems and many rival blockchain solutions.

Lower latency

Recent work on UX supports the common-sense idea that poor performance on a website or mobile app will drive customers away. Taking a noticeable amount of time to process a request breaks users’ focus flow, even when the delay is a matter of milliseconds. These negative psychological effects become even more obvious when it comes to making digital payments in a physical setting. In commerce, one key goal is to minimise the number of actions required by a customer to complete a transaction. Every click, confirmation or button press matters and more actions almost always translate into fewer sales. In a physical payment scenario, a simple transaction like purchasing a cup of coffee can become embarrassing for both cashier and customer if the payment takes more than a few seconds. Speed and ease of use are therefore of paramount importance when designing payment systems.

Payments within nahmii are processed directly by the operator of the system. This means that, unlike base-layer blockchains, there is no consensus mechanism underpinning the transaction. The off-chain transaction performance of nahmii is therefore simply a question of how fast our operator node can process a transaction request. Latency is currently at the millisecond level, comparable to the best centralised commercial payment services. If required, we can improve nahmii’s responsiveness even further by upgrading the operator nodes.

Scalable throughput

In general, conventional businesses benefit from wider adoption of their third-party services. As these services grow, suppliers can usually offer more cost-efficient products to their customers creating a win-win scenario. In the current blockchain world, we have seen the opposite. When the network became congested with transactions, consumers either have to pay a much higher gas price for their transactions to be mined in a relatively short time or wait for hours even days until the congestion is relieved.

On nahmii, the throughput capacity can be flexibly tuned based on the demand. Technical speaking, horizontally scaling operator nodes can achieve scalable throughput.

Predictable fees

As we all know, there is no such thing as a free lunch. It is not sustainable for a business to provide free services forever; eventually, users will always need to pay something for the services they value. This value exchange can take many forms, from straight payments to viewing advertisements or giving up user data. For traditional centralised infrastructure, suppliers calculate the value of their services by balancing cost, affordability for the user and profit. While prices can vary over time, users can normally predict how much a service will cost them in advance. Predictable fees of this type lower the risk of doing business.

On the other hand, the cost of using today’s blockchain services is unpredictable. For the majority of base-layer blockchains, transactions are processed if and only if they secure a place in the next block. This competition between customers to have their transactions mined creates conditions of uncertainty. When the network is busy, customers must pay more to ensure their transaction goes through. Given that we cannot predict how busy the network will be at any given time, transaction fees are necessarily unpredictable. As with predictable fees, so the opposite is true here: unpredictable fees introduce new risks for businesses, making adoption of blockchain technology less likely.

nahmii is designed to provide predictable, low fees at all times. This is a key requirement for making blockchain technology comparable with the best of centralised financial systems. The fees on nahmii are at a constant ratio of the currency being transferred and, unlike many rival scaling solutions and blockchains, including Ethereum, transaction fees within nahmii are paid in the currency of the transfer — no additional ‘fee tokens’ are required. Currently, payments on nahmii have a fee of 0.1% of the total transfer value; however, our fee structure is flexible and will soon include substantial discounts for larger transfers.

Usability

In some blockchain scaling solutions both parties must be online when making a transaction, while knowing how to sign the transaction using certain tools. There are a number of drawbacks to this approach, beginning with the high barrier to entry for both parties — particularly the recipient. These prerequisites for making transactions are a clear problem for the typical user experience and a significant barrier to adoption. No one really wants to wake up in the middle of the night to sign a transaction from a counterparty on the other side of the world.

There is a better way: nahmii aims to make trustless payments happen as seamlessly as on the base layer. To make a payment, the sender only needs to own a wallet and have a sufficient balance. As long as the recipient owns an Ethereum wallet, the recipient doesn’t have to be aware of the existence of nahmii in order to receive the funds sent from the sender. The goal here is to match the trustless features of the base layer while bettering the user experience of centralised payment systems.

A smoother, flatter learning curve

The majority of ICO projects have failed to ship a single usable product, why? In many cases, the answer lies in the complexity of developing software using immature developer tools. When combined with the tendency for ICOs to over-promise in order to attract investment, it’s easy to see why so many blockchain projects have failed to deliver on their vision.

The ability to evaluate and comprehend the complexity of the underlying requirements plays a key role in software development. This process encompasses a wide range of elements: teams must be able to understand the potential risks and rewards associated with their development tools and dependencies, while determining the resources and strategies to best fit their business model.

This principle applies to almost every software project. For blockchain technology, the complexity of a typical blockchain project is escalating compared to the conventional B/S or C/S architecture. Complexity leads to uncertainty, which is further multiplied by the shortage of proficient and experienced developers in the blockchain industry. Building high-quality software products is difficult, developing high-quality blockchain-based software is even more challenging. It is therefore unsurprising that so many ICO projects have failed, primarily because they have underestimated the time and expense required to build their promised products.

Complexity in development leads to increased risk and higher costs. Familiar, easier to understand developer tools can mitigate these risks and lower the barriers to entry for new blockchain projects. nahmii has been built with these principles in mind, with simple tools to help developers of all backgrounds build on the protocol. Under nahmii protocol, developers simply need to know how to use the nahmii SDK. The development experience is therefore similar to integrations with SaaS platforms.

Using nahmii SDK

Below, we set out the full cycle of the nahmii protocol using the SDK. This includes depositing ERC-20 assets, making transfer transactions with real-time finality and withdrawing the assets.

The overall scenario is as follows:

  1. Alice deposits ERC-20 assets into nahmii
  2. Alice makes a payment to Bob on nahmii
  3. Bob starts a settlement and then withdraw the assets back to the base layer

Deposit

Before transacting assets within nahmii, whether it is ERC-20 or ETH, we first need to make a deposit into the contract that manages funds within the protocol. This can be done via the SDK or interacting with the contract directly.

Deposit assets to nahmii

Once the deposit is completed and tokens have been transferred into nahmii, the relevant contract will emit an event to the operator. The operator then increments the asset balance for the wallet address on the second layer. For security reasons, we wait for 12 blocks confirmations before the operator recognises the deposit as final.

Deposit ERC20 token

Once the deposit is confirmed, the client can start making payments via the second layer or start a settlement to withdraw the deposited amount by interacting directly with the contracts.

Transfer on 2nd layer

For the transactions in the second layer, clients only need to interact with the operator. Here is the typical procedure:

  1. Alice has a balance on the second layer.
  2. Alice signs a payment to Bob using her wallet key, then sends the signed payment payload to the operator.
  3. After the operator receives the payment request, it updates the second layer balances for both Alice and Bob.
  4. The operator then generates and publishes a receipt, this shows the latest balances for both Alice and Bob.
2nd layer transfers

At the 4th step, the transaction is considered final once the operator receipt is published. This happens almost instantly. Transaction latency is at the millisecond level, comparable with the best centralised solutions and suitable for most of the real-world use cases.

For Bob, he doesn’t need to do anything to receive the payment or being online to sign the transaction as the counterparty during the transacting period. He doesn’t even need to be aware of the existence of nahmii until he wants to make use of his balance under the nahmii protocol. The only thing Bob needs to do before receiving funds via nahmii is to tell Alice his Ethereum wallet address. This is a significant advantage over state channel solutions, which require both parties to a transaction to be available in order to process and secure the transaction.

Making a payment in nahmii protocol

Once the operator has received the transfer request from Alice and effectuated the request, the operator creates a receipt for both Alice and Bob. As soon as the receipt is generated, the receipt marks the finality for the transfer transaction. The transaction receipt can then be used immediately by Alice or Bob as proof to start a settlement for withdrawals by directly interacting with the contracts.

Settlement

Settlement is the process by which funds within nahmii become eligible for withdrawal back to the base layer. This process is required because the base layer cannot see what is happening on the second layer. Before funds are released from nahmii’s client fund contract, we must make sure that the request is valid. This requires that all settlement requests to pass a challenge period, during which anyone with proof (in the form of a valid receipt) can challenge the settlement attempt. Receipts can be used to prove that a user has tried to withdraw funds that they do not have, an attempted fraud known as a ‘double spend’.

Start settlements

Suppose Bob wants to withdraw assets from nahmii protocol back to the Ethereum base layer, the process starts by determining which type of settlement is required to fully cover the intended withdrawal amount.

Continuing the workflow in the section above, Bob wants to withdraw the assets transferred from Alice. He can start a payment settlement using the receipt as proof of the maximum amount of balance he is eligible to withdraw in a currency.

Starting new settlements

There are two types of settlements.

  • on-chain balance settlement is used to stage funds when there has been no interaction with the backend, i.e. there is no payment receipt to start the settlement with (such as when a client has deposited into nahmii and wants to withdraw without making any payments)
  • payment settlement is used to stage funds using a payment receipt as proof.

The length of the challenge period for settlements is currently configured to be 5 days. During this period, anyone with proof that a settlement is fraudulent can submit the relevant receipt as a ‘challenge’ to nahmii’s smart contracts. The contract can immediately verify whether the receipt is a valid challenge candidate. If it is valid, the user who attempted the fraudulent settlement will lose their balance in the currency of the settlement (which is seized automatically by the smart contract). The challenger will receive the full amount of the seized balance from the contract.

In practice, the applications which integrate with nahmii’s settlement functions may want to collect information about the current status of the ongoing settlements so as to display appropriate messages on the UI.

Querying the statuses of the settlements

Withdrawal

Once the challenge period is passed and no challenge proof has been submitted, the settlement proposal will be marked as qualified and withdrawable.

The code below shows the procedure to complete the settlement, which will update the immediately withdrawable balance on the contracts. This balance is called staged balance.

Staging and withdrawing assets back to the base layer

Here is an open-source web app for you play around with the functionalities described above. To make it easier for you to digest through the code while playing around the demo UI, I’ve kept the code base as compact as possible using a lightweight frontend framework: Svelte. Most of the code is located within one file containing both the functions and the HTML. The web app also demonstrates the integration with wallets generated from web3 API, therefore can be used as a boilerplate for porting to integrate with other web3 compatible wallets, such as the wallet-connect protocol.

Web demo: https://hubiinetwork.github.io/nahmii-web-demo

Repository: https://github.com/hubiinetwork/nahmii-web-demo

For more details about nahmii, please check out its official website and whitepaper.

Potential use cases

Blockchain technology fundamentally changes the definition of ownership, offering people the ability to exchange values on the Internet and maintain stable relationships across the world.

Once the outstanding issues relating to the finality latency and fees have been resolved, blockchain will immediately open up all the practical possibilities for real-world use cases that cannot be realised today. Eventually, this exciting technology will create a platform on which existing markets will evolve and new markets can thrive.

Virtual Economies: Design and Analysis by Vili Lehdonvirta and Edward Castronova

In many cases, the primary purpose of a virtual economy is not even to earn revenues directly, but something more subtle yet equally powerful: to attract, hold, and manage attention; to reward referrals and incentivize contributions; to allocate resources; to lock users into a platform or to guide them around it. (Virtual Economies: Design and Analysis)

Blockchain technology has a lot to teach to other money systems, both traditional and virtual. In contrast to traditional systems, blockchain offers an easy way for software developers to integrate all sorts of money-related features into their applications, providing a great platform for money-related innovation. Blockchain is natively compatible with the world of digital value.

With nahmii’s unique features, it is now commercially viable for anyone to build scalable and trustless products on the blockchain. We anticipate that the community will use nahmii in creative ways that we haven’t even thought of yet, but to give you some ideas about what is possible here are some example use cases:

Payments

Integration with nahmii for making transfers and payments is probably the most obvious use case. nahmii enables businesses to exchange products or services for cryptocurrencies with predictable fees and real-time finality.

Because of the inherent security of nahmii’s underlying blockchain, users only need to confirm a transaction with a standard Ethereum wallet. This removes the need for third-party middlemen from the transaction, such as banks. The user experience during the transaction can be better than using mainstream payment services such as Paypal or Stripe, as there is no need to redirect the user away to different web pages or apps between the payment service provider and the merchandise provider. Consumers only need to digitally sign a transaction and send it to the nahmii operator. Once the receipt for the payment is published by operator, the transaction is done.

Token airdrop with almost zero cost

The value of the notes was upheld purely by a collective belief in their value. This can be called community fiat money. (Virtual Economies: Design and Analysis)

On Ethereum, performing an airdrop to a large number of recipients is generally an extremely expensive process. Gas prices, which determine the cost of a transaction, rise when the Ethereum network is busy. Airdrops can cause enormous congestion on Ethereum, which in turn leads to much higher gas prices. One solution to the problem is to spread the airdrop out over a long period of time, but this can be impractical for the larger airdrops.

Performing airdrops on-chain doesn’t make economic sense unless it is certain that the resulting value of the airdrops is greater than the costs in fees and time. Usually, the ERC-20 tokens being distributed through an airdrop are merely minted from the contracts with no circulation in the market as of the time. These initial minted tokens therefore have almost zero value, so it makes no sense to pay for a large amount of fees to distribute them.

On the other hand, nahmii can be used to perform quick, inexpensive airdrops on the second layer. Due to nahmii’s greatly increased capacity over Ethereum, transactions can be processed in real-time without congesting the Ethereum network. Transaction fees are fixed at a low level and paid in the currency of the airdrop. Therefore, new ERC20 tokens can be transacted in a scaleable way within their communities while growing their virtual economies. In this sense, nahmii can also play a role similar to startup incubators.

In fact, nahmii’s own token (NII) has been the subject of twelve airdrops over the last year. The monthly nahmii ‘airdriip’ distributes 1 billion NII tokens to thousands of addresses at a total cost of less than $5. Compared to using Ethereum, second-layer airdrops on nahmii for NII have generated significant savings.

Gaming currency

Contrary to popular belief, there is no fundamental difference between “virtual currency” and “real currency.” Both US dollars and World of Warcraft coins are fiat money. The major difference between these two moneys is in the size of their currency areas. (Virtual Economies: Design and Analysis)

Traditionally, the creator of a video game has absolute control over their in-game currency. This control extends to determining how many coins should be created, their purchase price and how they can be used. These variables are typically tuned over time, so that the game maximises profit while keeping players engaged.

The advent of blockchain technology brings new opportunities for the video games industry. With a blockchain, in-game currency and other collectibles can be tokenised and traded on a decentralised network. This gives players genuine ownership over their assets for the first time, which creates new and interesting monetisation opportunities. Perhaps most importantly, true ownership in this sense promises to radically reshape the relationship between content creators and consumers.

Imagine an in-game asset represented as an ERC-20 token. This token could be traded on a blockchain, sold at an exchange or even imported into other games. Similarly, tokens can be used to grant far more than simple ownership of an asset; tokens can act as vouchers, tickets, loyalty points and more. The ability to trade tokens in this sense also allows content creators to benefit from secondary item trading markets, a lucrative opportunity which is currently unavailable for most companies. Until today, these unique blockchain-based benefits have come at a significant performance cost. Gaming is a time-sensitive and highly competitive industry. If in-game transactions are to be reflected in real-time on a blockchain, that would typically introduce unacceptably high latency. To avoid breaking the focus flow of players, in-game transaction latency needs to be at the millisecond level. This is now possible with nahmii.

Conclusion

This two-part article has covered a wide range of topics in the blockchain space, including the key barriers to adoption, a comparison between rival scaling approaches, nahmii and use cases.

Our goal with nahmii has always been the same: to bring commercially-viable scaling to the blockchain industry. Scaling for us means more than just improved throughput; we understand that businesses need high-capacity, low-latency, affordable transactions with immediate finality. At the same time, we know that blockchain projects are struggling with a steep learning curve and immature development tools. That’s why we’re lowering the barrier to entry for would-be blockchain developers, with intuitive tools like our CLI, SDK, suite of APIs and web demo application.

We’re delivering on our promises, as you can see with the sample code in this article from nahmii’s web demo application and SDK. The nahmii protocol is designed to bring more developers into the blockchain industry, which in turn will drive commercial adoption. We invite you all to build on our example use cases to create new and exciting blockchain products.

As always, we welcome any comments that you might have. The community around hubii and nahmii is our greatest asset and something that we’re understandable proud of. To that end, we’re happy to help if you’re looking to integrate nahmii into your own project. For regular updates on our progress, please join our Telegram group here and follow us on Twitter.

Many thanks to John Derbyshire for graciously doing the proofreading and rephrasing the sentences in this article.

--

--