EOS Smart Contract Development (Part — 1)
By Shivank Chopra Blockchain Developer at QuillHash
Since the launch of the EOS main-net in June 2018, crypto speculators and application developers are being polarised over their opinion on EOS and Ethereum. Ethereum was launched in 2015, and since then have matured and grown it’s ecosystem and user base considerably. However, with the arrival of EOS, many believe it to be the “ethereum killer” that will take over ethereum in the race of being the best distributed computation platform. In times like these, it becomes important for the stakeholders and application developers that are new to blockchain space to understand the fundamental difference between these two amazing platforms, so that they can rationalize their decision for choosing either of them for building their next dApp.
In this article, I will point out and analyze the fundamental differences between these two frameworks and how does they affect the nature of dapps being built on them.
What is EOS ?
EOS is a free, open-source blockchain software protocol that provides developers and entrepreneurs with a platform on which to build, deploy and run high-performing decentralized applications. Like Ethereum, EOS is a smart contract platform aiming to be a “world computer”. This means that EOS provides capabilities to program and deploy applications (dApps) by providing the necessary infrastructure in a decentralized fashion. EOS boasts a very high transaction processing rate relative to Ethereum, which is partly the reason why it sparked interest in the blockchain community. Apart from this, the fact that EOS does not cost for deploying a transaction, like spending “gas” in Ethereum further lead people to believe EOS to be a superior choice over ethereum. However, each of these characteristics come with necessary trade-offs in the design of the protocol, which in turn affect the applications to be built on them.
Unlike Ethereum, EOS does not use proof-of-work (POW) consensus mechanism. Instead it uses delegated proof-of-stake (DPOS), which is a faster consensus mechanism. Essentially, it involves people staking their tokens for getting the right to vote for the block producers, where block producers are the nodes that will finalize transaction and make blocks out of them. If block producers act maliciously, voters can remove them and vote for other producers. The more tokens staked, the more voting power can be availed. In fact this same approach is extended to other resources on the blockchain. EOS treats network bandwidth, CPU usage, and RAM (memory used by dApps) as resources which can be obtained by staking tokens (RAM needs to be bought, but can be sold depending on RAM market prices).
These characteristics provides EOS with high transaction speed and no gas fees. In Ethereum someone needs to pay for processing transaction, and this is implemented as ‘gas’ required for every transaction. In EOS, this is achieved by application developer paying for the RAM. However, EOS provide programmatic flexibility in deciding who will pay for the RAM. This can lead to applications that may allow users to pay for their own actions depending upon situation and use case.
Another important aspect is DPOS consensus which provides EOS with high transaction speed. However, at any given time, only 21 block producers are responsible for making blocks in EOS. Although EOS provides a rigid constitution and measures to remove and recover from a malicious behaviour by these block producers, Ethereum still appears more secure as thousands of nodes verify the transaction upon addition of new blocks. Thus we can say that EOS sacrifices some decentralization for speed, however DPOS is still a robust consensus mechanism.
Nature of applications that could be built on EOS ?
EOS offers great infrastructure for supporting high performance dApps. It is sufficiently fast and decentralized to build creative dApps that could not have been possible earlier due to performance limitations. Application like decentralized games, which were previously limited by the slow transaction per second (TPS) of the underlying platform, can now be built over EOS. Popular games like CryptoKitties caused a lot of traffic on the Ethereum network upon it’s inception. Such applications could work quite smoothly with fast TPS offered by EOS. Rich permissioning support is provided out of the box by EOS, along with the notion of account names which would help towards early adoption among users less familiar with the blockchain.
One of the main hurdles in large scale adoption of blockchain technology has been difficult to understand ecosystem and slower transaction speeds. Often end users tend to care much about user experience than the underlying technology powering the application. In this context, platforms such as EOS will shine as it will provide a sufficiently decentralized and yet fast execution of applications. However there are applications where decentralization can not be compromised with. Applications involving lot of financial stakes will require high security in decentralized context, and in such case POW based systems appears to stand ahead of DPOS system.
Developer’s perspective on developing dApps on EOS: —
A dApp developer’s perspective is also an important factor for adoption of a new technology. At the end it’s they who will build applications on top of platforms such as Ethereum and EOS, so their ease for entering the ecosystem is also a crucial factor. Ethereum came out in 2015, and the tools used for developing dApps over it have also matured. Solidity, the programming language used for writing smart contracts is contract-oriented, and easy to pick up by majority of developers. EOS on the other hand is relatively new, and the development tools are still evolving, although tools like Scatter, eosjs and eosfactory are present for EOS dApp development. The smart contracts written on EOS compile to web assembly, and the recommended programming language for writing them is C++, which can be slightly time consuming to learn and develop with. However with passing time, the tools used to write dApps on EOS will mature, as it has happened with various other technologies.
For the general populace to embrace decentralized applications built on the blockchain, it is very important that the applications does not slow down significantly in comparison with the current centralized alternatives. High performance dApps are needed if we want the general population to adopt blockchain on a larger scale. Platforms like EOS are aiming for this by providing a faster decentralized architecture, that support TPS rivaling centralized solutions with benefits of decentralization. The end users that are accustomed to faster traditional apps will not move to decentralized alternatives if they offer slower and difficult to understand ecosystem. However, ensuring strong consensus mechanism is equally important for applications that are native to blockchain, that includes financial applications involving lot of funds where security can not be compromised. Hopefully we will see both of these characteristics coinciding as the research goes on for developing even more secure and faster consensus algorithms.
Stay tuned for the next part…
Part 2 — EOS Smart Contracts Audit checklist to Keep In mind Before Development
Part 3- Understanding fundamental concepts for writing dApps on EOS.
Part 4- Analysing EOS standard token contract .
Part 5- Develop a basic crowd sale application with EOS .
Part 6- EOS for high performance dApps — Games on EOS!
Thanks for reading. Hopefully this guide has been useful to you and will help you to understand the basics of EOS smart-contract and Also do check out our earlier blog posts.