How to develop DAPP on EtherZero?

What is EtherZero? EtherZero (ETZ) is a new generation of smart contract platform. It is an open-source underlying system that can implement smart contracts on blockchains. With zero transaction fees, real-time transactions, high concurrency, the masternode arbitration, double-layered network and so on.

The development of DAPP on EtherZero is fully compatible with Ethereum. Compared with Ethereum, the biggest advantage of developing DAPP on the EtherZero is zero fees!

Because of its many advantages, such as zero fee and instant transaction, it is the most suitable public chain for DAPP development.

1. Preparation for development

In each Etherzero full node, complete blockchain data is stored. EtherZero not only saves the transaction data, the compiled contract code is also stored on the chain. In the EtherZero full node, a virtual machine is provided to execute the contract code.

Transaction data

Each transaction in EtherZero is stored on the blockchain. When you deploy a contract, a deployment is a transaction. When you vote for a candidate, one vote is another transaction. All these transactions are public and everyone can see and verify. The transactions can never be tampered with.

Contract code

EtherZero not only stores transaction data on the chain, it can also store the contract code on the chain. At the database level, the role of the blockchain is to store transaction data. The EtherZero DApp developer can use the Solidity language to write the business logic/application code (ie contract: Contract), then compile the contract code to bytecode and deploy the bytecode to the blockchain. You can also use other languages to code , but Solidity is the most popular choice by far.

Virtual machine

The EtherZero blockchain contains a virtual machine in each node to execute the contract code.


Web3.js encapsulates the API protocol of EtherZero node, making developers to easily connect to blockchain nodes without having to write tedious RPC protocol packages. So we can directly introduce the library in the commonly used JS framework to build decentralized applications:

The web page communicates with the blockchain nodes via Remote Procedure Call (RPC). Web3.js already encapsulates all of the RPC calls defined by EtherZero, so you can use it to interact with the blockchain.

GoETZ plugin wallet

Deploying smart contracts on EtherZero requires a plug-in wallet called GoETZ developed by EtherZero. Take the Chrome browser as an example. You can find the wallet plugin by searching GoETZ in the online app store. Click “Add to CHROME”.

2.EtherZero Energy System — Power

2.1 Introduction of Power

The EtherZero system uses Power to ensure the normal operation of zero commission transactions. Power is an EtherZero-origin native currency, issued by the PoS mechanism, and is not tradable. It is only used for the consumption of Gas in transactions.

All accounts with a balance ≥0.01ETZ will continue to produce Power as the block grows until reaching the Power limit . The upper limit of Power Max is determined by the ETZ balance, and the speed of producing Power of each block is determined by the ETZ balance.

2.2 Power implementation principle

(1)Power of an account
Power = Min(PowerMax, BlockGap * PowerSpeed)
BlockGap = current block height — last transaction block height

(2) Power consumed by a transaction
Powerpend = Gas * GasPrice
For example, a general transfer of Gas is 21000 and GasPrice is 18Gwei.
18Gwei = 0.000,000,018 ether
A normal transfer requires power= 21000 * 0.000000018 = 0.000378 ether

(3) Power upper limit PowerMax for one account
PowerMax = (Math.exp(-1/(x*50)*10000)*10000000+200000)*0.000000018

For example, an account with a 0.01ETZ balance, PowerMax is 0.0036 ether.

Assume that GasPrice is set to 18Gwei (ie 0.000000018 ether).
Then the single transaction of this 0.01ETZ balance can be set up to Max Gas= 0.0036 / 0.000000018 = 200000.
 In the case of GasPrice 18Gwei, this account cannot send transactions asking for more than 200,000 gas.

Assume that GasPrice is set to 36Gwei (ie 0.000000036 ether).
Then the single transaction of this 0.01ETZ balance can be set up to Max Gas= 0.0036 / 0.000000036 = 100000.
 In the case of GasPrice 36Gwei, this account cannot send transactions asking for more than 100,000 gas.

(4) Power recovery speed of an account-PowerSpeed
PowerSpeed = (Math.exp(-1/(x*2)*1000)*200000+1000)*0.000000018

For example, an account with a balance of 0 receives 0.01ETZ at a block height of 100.

Power of this account at block height 101=(101–100) * 0.000018 = 0.000018

Power of this account at block height 102=(102–100) * 0.000018 = 0.000036

Power of this account at block height 201=(201–100) * 0.000018 = 0.0018

Power of this account at block height 301=(301–100) * 0.000018 = 0.0036

Power of this account at block height 401=(401–100) * 0.000018 = 0.0036(no more increasing)

After the block height 301, the upper limit has been reached. If you need to upgrade Power, you need to increase the account balance.

2.3 Balance-Power comparison table

From the table, you can find out that an account with a 0.01ETZ ​​balance can consume a maximum of 3.6 million Gas for a single transaction (assuming GasPrice is set to 1Gwei).

3.Develop smart contracts with Remix

Remix is​​ an open source Solidity smart contract development environment that provides basic functions such as compiling, deploying to a local or test network, and executing contracts. Solidity is a development language that is officially supported by EtherZero and is designed for writing smart contracts. Http:// , Remix is an online development environment that does not require installation, and can start Remix directly in any browser.

The following will introduce the EtherZero-basedDapp development process based on Remix. we will introduce how to deploy smartcontracts on the EtherZero .

3.1 Compiling aContract with Remix

Click on the upper right corner + Add anew contract

The name is arbitrary as long as the extension is “.sol”.Taking a simple currency-buying contractas an example, write the corresponding code content to the contract and compileit. The solidity grammar used for the contract can be found on the officiallearning website Remix defaultsettings will be automatically compiled, as long as the side does not pop up ared error prompt that represents a successful compilation.

3.2 EtherZero Smart Contract Deployment

Open GoETZ, and you can see the ETZ balance in your account.

Select Injected Web3 in Remix, it will automatically import the address in the GoETZ plug-in wallet.

Click Deploy to send the transaction andyou can deploy the contract to the EtherZero main network.
Wait a moment, after the deployment issuccessful, the contract interface will come out, so that you have completedthe deployment of an EtherZero smart contract. So easy.

3.3 Issues of deploying

After you click Deploy to send thetransaction, if the remix reports the following error, indicating that thePower value of the transaction is not enough. you can lower down the GasPriceof the transaction, for example, to 1 or 2, and then try again.

In case of network congestion, the lowerGasPrice may need to wait longer, and this can also be solved by increasing theaccount’s ETZ balance.

3.4 Obtaining ETZ

Since the EtherZero(ETZ) is completely free of charge, there is no cost in the contract commissioning, unlike the Ethereum development. Therefore, developers are advised to test and develop directly on the EtherZero main network. There is no need to build a private network locally, which can save time for code migration testing and greatly improve development efficiency.

You can buy ETZ on exchanges,such asCryptopia、Digifinex、Coin918、Betop and so on. You can also getETZ free from our DAPP developer activities.

4 References Resources: