Hedera Hashgraph Smart Contracts

by | Apr 14, 2019 | Hedera Hashgraph

Hedera Hashgraph Smart Contracts Explained


Summary: After the revolutionary development of blockchain and the bitcoin cryptocurrency, the next leap in decentralized technology occurred with the ethereum network and its self-sufficient, self-executing smart contract (SC) technology. A smart contract is simply a computer program or protocol that is able to derive inputs into a contract and enforce their outputs based on a mutual agreement between users. The interface of cryptocurrency with contractually-binding agreements in software code has begun an innovative financial technology (fintech) that will likely dominate the future of internet-based commerce.

To illustrate by example, imagine a SC that is able to negotiate a digitally-binding agreement between two users in a decentralized ride-sharing application. In that example, a user hails a driver thru a decentralized app (dapp) and escrows, or ties up, an amount of hbar cryptocurrency in a smart contract that the driver accepts. In that contract, the user requesting the ride is confirming in computer code and hbar coins that they will pay the amount agreed upon execution to the driver based on a fixed destination.

In this example, the Hedera contract is immutable if the inputs are met, meaning it cannot be arbitrarily reversed. This allows both parties to enter negotiations that are trustworthy and cannot be falsified or rigged. The greatest thing about these peer-to-peer (p2p) transactions is that they occur at the speed of the internet in Hashgraph and can easily be done on any mobile phone.

This contractual agreement is easily supported by modern software in a low payload, or simple data program, and will deliver hbar coins when the input variable of the user arriving in a specified time frame at a certain GPS location. When the user arrives in time at the chosen location, in this example, the hedera hashgraph smart contract will use that GPS input into the smart contract, verify the agreement in computer code, and then deliver to the driver’s wallet the escrowed hbar coins. This is the future of contractual agreements in the burgeoning crypto p2p economy and should be thoroughly understood as an investor to see its future potential.

However, it is also important to consider the ramifications of smart contracts and the probability of software bugs in source code leading to untoward outcomes. If contracts cannot be reversed by design of the immutable Hedera Hashgraph ledger, then some mechanism of contract dispute resolution must exist to help protect users from catastrophic software codes as has happened in the ethereum network with the DAO hack. Novel solutions within the Hedera network have been proposed with the Sagewise Smart Contract Dispute platform. This may help solve the inherent problems with buggy software contracts and immutable ledgers.


Focus Point : A strongly desired consequence of the Hedera smart contract platform is that the industry of intermediaries, or middlemen, could be progressively removed from the transactions within the future distributed ledger ecosystem. This potential ability of Hashgraph smart contract technology alone is one of the greatest intrusive and disruptive elements of the the new distributed ledger technology (DLT) space.

An investor should carefully evaluate the numerous ways that a SC can change current legacy systems, such as lawyer consultation, paralegal service, accounting work, contract services, and many many more. A new economy will arrive from these services similar to the playbook of businesses like Uber, Lyft, and Airbnb, but without a profiting central business. Instead, the profit sharing will occur between direct users and participants in a fairer and more equitable economy.

Allowing peers to engage in commerce without the necessity of a middlemen that charge excessive fees for services that can be easily deployed through computer code will be a revolution in itself. A large financial opportunity is now available to savvy early movers in the growing hbar smart contract world. Developing dapps that meet users needs, cut out the middlemen and make all services cheaper, faster, and with less stress for all participants will dominate the 21st century DLT marketplace.


Discussion:    Hashgraph smart contracts are not that unique from a computer science standpoint in that they use simple programming languages like Solidity, and execute code just like any other modern operating system. They can be performed on nearly any mobile phone technology and have a tiny electrical energetic footprint. Smart contracts are able to integrate the entire internet as an input of any kind and therefore have the ability to affect every single business sector and industry in the world. Executing trustless transactions with payment in hashgraph tokens is the complete fulfillment of the DLT revolution and will transform life for decades to come.

The baseline premise of the Hedera Smart Contract platform is the fact that currency in the form of hbars can become programmable money. This means that instead of hbar currency acting only as a medium of exchange, they can also become a medium of logical financial transaction. Using simple computer code, consisting of ‘if’ and ‘then’ statements in small file sizes, hbar tokens can now carry an algorithm of binding contractual agreements. There is no need for a middlemen to carry out the negotiation, a decentralized application hosted on a mobile phone in a peer-to-peer network can do it just fine.

In fact, the use of a self-sufficient Hashgraph smart contract actually will create a new internet layer of trust and lower intermediary fees to a minimum. A SC can easily create a new economy of p2p, or even business-to-business (b2b), transactions based on the underlying distributed technology of Hashgraph. Imagine a scenario where a local business requires a labor service but cannot easily provide the service due to lack of infrastructure. Instead, the local business owner could solicit work through a distributed application, where a smart contract is created and issued to a public forum of available freelance work. An individual that is subscribed to the freelance work application could receive a notification and either accept the smart contract enabled job with escrowed hbars for payment or negotiate a mutually-agreeable payment.

This business-to-peer smart contract transaction could be hosted by a mobile phone app and never require a job hiring agency, lengthy interview process, or job screening process. This disintermediation, or removal of needless and costly middle steps will allow for a much more frictionless economy of p2p and b2b employment then previously possible. Reviews of previous work and transactions will build a repository of customer service scoring that will guide the community to the best individuals in a competitive yet open economy. Here is a reference to many of the decentralized apps that are building on the Hedera Hashgraph smart contract platform.

REF: https://www.hedera.com/about#dapps

Services already have arisen close to this mode in big cities including on-demand moving assistance but do not operate p2p because of legacy business models. By creating a decentralized smart contract system where the individual is able to directly receive a payment for a service without requiring a building, secretary or even a license, the middleman is completely eliminated. Costs are reduced in this economy and the laborer is directly paid without any unnecessary loss for services that are easily provided by the smart contract system.

Distributed applications that adopt this future business model and enable direct transactions in a trustless economy by utilizing escrowed funds to ensure that contracts are executed will excel. If one considers how powerful the disruption that businesses like Uber and Lyft have been to the legacy transportation system, that person should also be able to see how using hbars in smart contracts will be equally effective at changing the world. The critical step will be in smart contract design and execution. It may take a new type of decentralized organization that derives its value not by being the intermediary of a business agreement, but by facilitating the user to service provider through contract creation.


Decentralized Autonomous Organizations: A novel kind of business model in the realm of cryptocurrency is the concept of a non-governed business that provides computer support and development of a business or ecosystem without having any central authority. Moreover, this decentralized autonomous organization (DAO) has been shown in the ethereum network to add substantial value to the cryptographic smart contract system. This is achieved by setting standards and guiding projects towards a common good without the need of having a centralized profit model, but uses paid services and donations as a way of funding.

The most relevant example of a DAO would be in the example of a fully decentralized exchange (DEX) for trading cryptocurrencies. This internet-based service is currently in full force in the crypto marketplace and allows peers to directly interact with one another without ANY intermediate organization like the New York Stock Exchange or NASDAQ. A DEX is simply a hosted software service on the internet that collates multiple smart contracts that can execute agreements between hbar coin owners in a trading platform without anyone managing the private keys of the transaction. This is a critically important point to understand. The ability to buy or sell hbars at an exchange with minimal fees while maintaining the privacy of one’s digital keys is the greatest way that a market can exist with the least amount of risk to the end users. When an exchange holds the private keys of an end user this is referenced as a custodian, and has a substantial risk of coin loss.

Since the advent of public crypto exchanges, countless hacks into the wallets of the largest exchanges has occurred and cost users hundreds of millions of dollars in the process of custodial risk. The cryptocurrency community has finally arrived at the realization that DEXs should become the dominant form of habr exchanges in order to avoid this costly and irreversible risk of customer funds. A DEX would never be able to lose funds because the transactions occur p2p and only go from one user wallet to another user wallet, through a smart contract. There is no custodial risk in the design and private keys are only maintained by their users instead of centralized crypto exchanges like Coinbase, Gemini, Kraken and Binance.

In this model, user funds would never have exposure or be transferred into a common public exchange wallet that could be hacked. This idea has become so powerful within the crypto community that the CEO of the world’s largest digital asset exchange, Binance, has even started to develop one of the largest DEXs to spearhead the process.

REF: https://bravenewcoin.com/insights/why-a-binance-dex-could-be-a-game-changer


Smart Contract Risks: Despite the innovative and disintermediating force that Hedera smart contracts will create with digital assets, a common problem of software design is still an issue to consider. Software of any kind, smart contract or not, is always subject to an unknown risk of computer bugs or faulty logic in a program that could lead to hacks, failure or disruptive behavior in a network. Currently, there is no formal or practical way to completely predict or plan for a software bug that could lead to such havoc.

In 2016, the ethereum network experienced a critical software error in the DAO project through their decentralized venture capital investment fund smart contract source code. This fund was governance-free and used a variety of smart contracts to manage a venture capital fund without a central control. It was the greatest cryptocurrency fund raising project to date at the time, with nearly $150 million USD equivalent in investment. The DAO was meant to fund other projects in the ethereum network and functioned through smart contract technology built on the programming language of Solidity.

Unfortunately, the DAO vulnerability in code was detected early on and was eventually seized upon by hackers, removing the equivalent of ~$50 million USD in ether. The ethereum community was shaken and was forced to make a radical decision of hard forking the entire ether platform in order to reverse the transactions of the hack. This violated one of their first principles in decentralized organization design, by reversing the immutable ledger with a community-wide database split amongst miners.

The ethereum-DAO hack resulted in a contentious fork that eventually created an alternate ledger known as the ethereum classic network. The experience for the crypto markets was met with confusion and controversy as well as much heated debate. In the end, both ethereum and ethereum classic suffered from a problem that was directly related to a smart contract software failure that allowed an unforeseeable vulnerability in a multibillion dollar crypto platform.

REF:https://medium.com/@ogucluturk/the-dao-hack-explained-unfortunate-take-off-of-smart-contracts-2bd8c8db3562

The future success of smart contracts will benefit from understanding these programming failures and will be well advised to plan accordingly. Smart contract design will require rigorous testing in order to confirm before deployment that they are not flawed and do not expose cryptocurrencies at risk of theft. If an hbar smart contract is flawed and allows a hacker the ability to exploit it and steal funds without reversibility, then some mechanism must be in place to help either restore funds through another transaction or by means of an intermediate authority. As the Hedera smart contract ecosystem evolves new systems of risk management will be necessary to mitigate these software vulnerabilities.


Smart Contract Risk Management: One proposed solution to the unknowable risk of faulty smart contract software code error is the concept of a multi-signature key structure that involves a trusted third party in order to resolve disputes. Sagewise is an innovative solution of the contract dispute process and may solve a serious problem in smart contract design. To date, nearly 2 billion USD has been lost in faulty code, hacks and contract errors in the cryptocurrency ecosystem. Sagewise hopes to leverage the Hedera Hashgraph platform by performing a unique function in the process of contentious contract outcomes.

In the structure of a smart contract built on the Hedera network, an authoritative role by the contract generators is executed through the use of a private key digital signature. However, in the case of contract disputes there is no current mechanism that can help manage or mitigate the problems that may arise in a faulty negotiation.

For example, imagine that an individual wishes to buy a digital asset that is mediated through a Hedera smart contract and purchased with hbar currency in the transaction. The seller of the digital asset arranges the contract and proposes it the the buyer in an open market place with no intermediary business. However, in this scenario, also imagine that the smart contract contains a code error that misdirects the digital asset to the wrong wallet. The unintended receiving wallet owner may not realize that it has received the asset and may not care to return the valuable virtual property. This leads to a major problem that cannot be reversed by the design of the unchangeable ledger.

In this hypothetical situation, Sagewise proposes that a multi-key signature could be used in the originating Hashgraph smart contract design to help avoid the consequences of a faulty coded negotiation. In their solution, Sagewise could represent a trusted third party that could resolve the dispute in the code and disallow the contract execution since it did not create the original desired outputs of digital asset ownership transfer from one to the other intended parties. In a putative multi-key signature contract, Sagewise would represent one of the keys that could effectively freeze the transaction if the desired outcome is not executed correctly. In this example, The smart contract could be signed by the buyer and seller, but until the transfer is made and the digital asset is transferred correctly, Sagewise would wait to do the final sign off. If the transfer is proper, then Sagewise could finalize the transaction with their third digital signature.

However, if the preliminary transaction executes, but shows through the hashgraph that the asset was transferred in error, Sagewise  could execute their 3rd party function and halt the transaction. This could then be investigated for the software error, all parties could be notified and the contract could be nullified. This assistive role in Hashgraph smart contract could become an entirely new industry in the distributed ledger technology space and allow Sagewise an important role in reducing risk of faulty code. This virtual safety net in DLT can be further explored through this link below.

REF:https://www.sagewise.io/sagewises-vision-to-build-the-safety-net-for-smart-contracts/


Hedera Smart Contract Code: The underlying technology of hbar smart contracts is built on the ethereum-compatible coding language of Solidity. Sharing this common coding base between ethereum and Hedera Hashgraph allows the capability of either network the ability to execute a software-driven negotiation within either network seamlessly. This also facilitates the developer community by leveraging the ethereum network progress into the hashgraph platform with no additional computer programming language required. This is a unique software cross-compatibility that could also allow future interoperability of the Hashgraph and ethereum distributed ledgers.

Hedera Hashgraph has mentioned that the development of additional coding languages and code bases could be used for future smart contract developments as well. As the developer community grows in the ecosystem surrounding the hbar smart contract platform, more developments in this technology are expected.


Conclusion: Powering the future distributed ledger economy will be a combination of hbar smart contracts and trusted third-party conflict resolving solutions as proposed by Sagewise. The ability to predict each and every software coding error or bug may never be achieved in the near or long term future. However, in the rapidly proliferating ecosystem of Hashgraph and other smart contract-enabled cryptocurrencies, the ability to resolve disputes between users will be critical for success.

Sagewise could be well suited to fulfill this role and offer an unforeseen benefit of a non-court based system of multikey signature transactional arbitration. It will take considerable foresight in the planning and execution of smart contracts in order to obviate this kind of problem in the DLT environment.

Finally, it is essential for a healthy DLT community to create, execute and finalize smart contracts with the use of the hbar cryptocurrency with a safety net. The failsafe protection could be in the form of a service such as suggested by Sagewise. Resolving disputes with a trusted third party will help protect the end user as well as reduce the need for any kind of legal court action.

Ħello Future.