Zentanetwork is a forkless Proof of Stake consensus for communication and data storage.
This project is under active development, there may be breaking changes.
Zentanetwork is a forkless PoS consensus for communication and data storage. Zentachain's native token is called Zentachain CHAIN. The consensus used by Zentanetwork is the Proof of stake (PoS) algorithm. Zentalk users can earn CHAIN tokens by supporting the Zentanetwork. To become a validator, users need to have some CHAIN, and lock (Bonding) up the tokens. Thus, users will both strengthen the Zentanetwork and will be rewarded at the rate of CHAIN they regularly stake.
Rust is a programming language designed for security, speed, and concurrency. Its structure lets you create programs that have the power and control of a low-level language, but with the powerful abstractions of a high-level language. Rust performs most of its security checks and memory management decisions at compile-time, so it does not affect the runtime performance of your program. This makes Rust useful for a number of use cases for which other languages are not suitable: Programs with predictable memory and timing, embedding in other languages, and writing low-level code such as device drivers, operating systems, blockchain, or even networks. The network is built with the Substrate framework.
Cargo is Rust’s build system and package manager. Most use this tool to manage their Rust projects. Cargo handles a lot of tasks, such as building your code, downloading the libraries your code depends on, and building those libraries. When you write more complex Rust programs, you will add dependencies, and when you start a project with Cargo, adding dependencies will be much easier.
Substrate framework can be defined as an open-source community, a modular software development framework, and a developer platform. The Substrate framework provides modular development of fast, secure, and forkless blockchains using Substrate palettes.
Please follow the instructions to download rustup-init.exe
Open terminal and type:
$ curl https://sh.rustup.rs -sSf | sh
🎉 Great Rust is now installed 🎉
1.2 Updating Rust
$ rustup update
1.3 Uninstalling Rust
$ rustup self uninstall
$ rustc --version
1.5 Downgrade Nightly Version
$ rustup install nightly-YYYY-MM-DD
$ rustup override set nightly-YYYY-MM-DD
1.7 To install a specific Rust version use:
$ rustup toolchain install 1.30.0 (Example)
1.8 Rust Version Managing
1.9 Change between the version in the directory:
If you'd like to have a different default per-directory, that's easy too! If you run this inside of a project:
$ rustup override set nightly
Or, if you'd like to target a different version of Rust:
$ rustup override set 1.30.0
Be sure you have add nighlty run the command:
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-02-10
1.0 Cargo version
$ cargo --version
Cargo Building & Running
$ cargo build
Cargo check (Quickly checks your code to make sure it compiles)
$ cargo check
1.1 Building for Release
When your project is finally ready for release, you can use
cargo build --releaseto compile it with optimizations. This command will create an executable in target/release instead of target/debug. The optimizations make your Rust code run faster, but turning them on lengthens the time it takes for your program to compile the code. If you’re benchmarking your code’s running time, be sure to run cargo
build --releaseand benchmark with the executable in
1.0 Start Substrate on Windows
1.1 Start Substrate on macOS
Setup / Install Choco
To install GNU make, run the following command from the command line or from PowerShell:
$ choco install make
A Subkey is a tool that generates keys specifically designed to be used with Substrate. This may take up to 15 minutes.
1.0 Install Subkey
$ cargo install --force subkey --git https://github.com/paritytech/substrate --version 2.0.0
$ subkey generate --scheme sr25519
$ subkey inspect --scheme ed25519 "--Seed--Phrase--"
1.3 Generate a Password Protected Key-Pairs
add command --password "enter-password-here"
1.4 For more security, use (supports 12, 15, 18, 21, and 24)
add command --words 24
1.5 Information about the keys:
- Secret Phrase = Mnemonic phrases (Important keep it Safe)
- Secret Seed = Private Key or Raw Seed (Important keep it Safe)
- Public Key (HEX*) = Account ID (Public Address)
- SS58 Address = SS58-encoded address (Public Address)
- It is better for hierarchical deterministic key derivations.
- It is generally more resistant to misuse.
One sacrifice that is made when using Schnorr signatures over ECDSA is that both require 64 bytes, but only ECDSA signatures communicate their public key.
1.6 Generate Key pairs with Polkadot-JS
1.0 Token Economics
- Network ID: Zentanetwork
- Symbol: CHAIN
- Algorithm: PoS
- Supply: 5.500.000
Proof of stake (PoS) is a type of consensus algorithm by which a cryptocurrency blockchain network aims to achieve distributed consensus. In PoS-based cryptocurrencies, the creator of the next block is chosen via various combinations of random selection and wealth or age (i.e., the stake). In contrast, the algorithm of proof-of-work-based cryptocurrencies such as bitcoin uses mining; that is, the solving of computationally intensive puzzles to validate transactions and create new blocks.
The main advantages of the Proof of Stake algorithm are energy efficiency and security. A huge number of users are encouraged to run nodes since it’s easy and affordable. This along with the randomization process also makes the network more decentralized, since mining pools are no longer needed to mine the blocks.
Incentives differ between the two systems of block generation. In Proof of Work (PoW), miners may potentially own none of the currency they are mining and thus seek only to maximize their own profits. It is unclear whether this disparity lowers or raises security risks. In Proof of Stake(PoS), however, those "guarding" the coins always own the coins, although several cryptocurrencies do allow or enforce the lending of staking power to other nodes.
In the Proof of Stake system, the validation process is done randomly depending on the number of $CHAIN in the wallet account of the people. So every wallet that owns the $CHAIN can become a validator in the network. Of course, accounts with a large number of $CHAIN's in the system are more likely to be used as validation and therefore receive more shares from the network.
The Framework for Runtime Aggregation of Modularized Entities (FRAME) is a set of modules (called pallets) and supports libraries that simplify runtime development. Pallets are individual modules within FRAME that host domain-specific logic. (Substrate Runtime Modules)
Pallets are a special kind of Rust module from which Substrate runtimes can be composed. Each pallet has its own discrete logic which can modify the features and functionality of your blockchain's state transition function. (A Substrate runtime modules)
The Balances module provides functionality for handling accounts and balances.
GRANDPA provides block finalization. It has a known weighted authority set like BABE. However, GRANDPA does not author blocks; it just listens to gossip about blocks that have been produced by some authoring engine like the three discussed above. GRANDPA validators vote on chains, not blocks, i.e. they vote on a block that they consider "best" and their votes are applied transitively to all previous blocks. Once more than 2/3 of the GRANDPA authorities have voted for a particular block, it is considered final. GRANDPA Abstract paper by Alistair Stewart can be found here.
The property of a block can not be reverted. Generally, created blocks are not final until some point in the future - perhaps never, in the case of "probabilistic finality".
BABE also provides slot-based block authoring with a known set of validators. In these ways, it is similar to Aura. Unlike Aura, slot assignment is based on the evaluation of a Verifiable Random Function (VRF). Each validator is assigned a weight for an epoch.y This epoch is broken up into slots and the validator evaluates its VRF at each slot. For each slot that the validator's VRF output is below its weight, it is allowed to author a block. BABA Abstract by Handan Kılınç Alper can be found here.
Slot-based consensus algorithms must have a known set of validators who are permitted to produce blocks. Time is divided up into discrete slots, and during each slot, only some of the validators may produce a block. The specifics of which validators can author blocks during each slot vary from engine to engine. The Substrate provides Aura and Babe, both of which are slot-based block authoring engines.
An epoch is a time duration in the BABE protocol that is broken into smaller time slots. Each slot has at least one slot leader who has the right to propose a block.
A (whole) number of sessions, which is the period that the validator set (and each validator's active nominator set) is recalculated and where rewards are paid out.
The runtime of a blockchain is the business logic that defines its behavior. In Substrate-based chains, the runtime is referred to as the "state transition function"; it is where Substrate developers define the storage items that are used to represent the blockchain's state as well as the functions that allow blockchain users to make changes to this state.
Since validator slots will be limited, most of those who wish to stake their Zentachain tokens and contribute economic security to the network will be nominators. Validators do most of the heavy lifting: they produce new block candidates in BABE, vote, and come to a consensus in GRANDPA. Nominators, on the other hand, do not need to do anything once they have bonded their Zentachain tokens.
Accounts that select a set of validators to nominate by bonding their Zentachain tokens. Nominators receive some of the validators' rewards but are also liable for slashing if their nominated validators misbehave.
Slashing will happen if a validator misbehaves (e.g. goes offline, attacks the network, or runs modified software) in the network. They and their nominators will get slashed by losing a percentage of their bonded/staked Zentachain. Any slashed Zentachain will be added to the Treasury.
The Treasury is a pot of funds collected through transaction fees, slashing, staking inefficiencies, etc. The funds held in the Treasury can be spent by making a spending proposal that, if approved by the Council, will enter a waiting period before distribution. This waiting period is known as the budget period, and its duration is subject to governance, with the current default set to 24 days.
The Council primarily serves as a body to optimize and check/balance the more inclusive referendum system. (Election and Proposals)
The Timestamp module allows the validators to set and validate a timestamp with each block. It uses inherents for timestamp data, which is provided by the block author and validated/verified by other validators. The timestamp can be set only once per block and must be set for each block. There could be a constraint on how much time must pass before setting the new timestamp.
The network information including what nodes are running the chain, what software versions they are running, and sync status.
A session is a Substrate implementation term for a period of time that has a constant set of validators. Validators can only join or exit the validator set at a session change.
Session keys are used by validators to sign consensus-related messages.
SessionKeysis a generic, indexable type that is made concrete in the runtime.
A subsystem in Substrate for managing keys for the purpose of producing new blocks.
A process by which tokens can be "frozen" in exchange for some other benefit. For example, staking is a form of bonding for which you receive rewards in exchange for securing the network.
State changes that come from the outside world, i.e. they are not part of the system itself.
Zentachain native token is called:
- Name: Zentachain
- Symbol: CHAIN
- Network: Zentanetwork
If you are unfamiliar with weights, the TL;DR is that Substrate blockchains have limited resources when it comes to producing new blocks. Most notably, there is a limited window for block producers to create a block, limited amount of data that can be included per block (
MaximumBlockLength), and an overall practical limit to the storage footprint of the blockchain.
The Substrate has introduced a Weight system that allows the runtime developer to tell the block production process how “heavy” an extrinsic is. Given some
MaximumBlockWeight, and the weight of the individual extrinsics in a transaction pool, we can select the set of extrinsics that allow us to saturate our block, while not going over the limits.
When a block author constructs a block, it must limit the block's execution time. A block body consists of a series of extrinsic. Since the resources needed to execute an extrinsic can vary, Substrate provides a flexible mechanism called "weights" to characterize the time it takes to execute an extrinsic. To be economically sustainable and to limit spam, some transactions --- primarily those dispatched by users --- require a fee prior to transaction execution.
To bring the weight system to the users of our blockchain, Substrate introduces a tightly coupled fee system. In short, users will pay a transaction fee proportional to the weight of the call they are making.
total_fee = base_fee + length_fee + weight_fee
Note: There is also a length_fee which takes into account the amount of data included in an extrinsic.
As the name of the Sudo pallet implies, it provides capabilities related to the management of a single
sudo("superuser do") administrator. In FRAME, the
RootOrigin is used to identify the runtime administrator; some of the FRAME's features, including the ability to update the runtime by way of the
set_codefunction, are only accessible to this administrator. The Sudo pallet maintains a single storage item: the ID of the account that has access to the pallet's dispatchable functions. The Sudo pallet's
sudofunction allows the holder of this account to invoke a dispatchable as the
Rootorigin. The Sudo rights will be removed after the main-network and given to the community.
By using Wasm in Substrate, the framework powering Polkadot, Kusama, and many connecting chains, the chains are given the ability to upgrade their runtime logic without hard forking. Hard forking is a standard method of upgrading a blockchain that is slow, inefficient, and error-prone due to the levels of offline coordination required, and thus the propensity to bundle many upgrades into one large-scale event. By deploying Wasm on-chain and having nodes auto-enact the new logic at a certain block height, upgrades can be small, isolated, and very specific.
WebAssembly, shortened to simply Wasm, is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications. WebAssembly is a platform-agnostic binary format, meaning that it will run the same instructions across whatever machine it is operating on. Blockchains need determinacy in order to have reliable state transition updates across all nodes in the peer-to-peer network without forcing every peer to run the same exact hardware. Wasm is a nice fit for reliability among the possibly diverse set of machines. Wasm is both efficient and fast. The efficiency means that it can be uploaded onto the chain as a blob of code without causing too much state bloat while keeping its ability to execute at near-native speeds.
Libp2p is a network framework that allows you to write decentralized peer-to-peer applications. Originally the networking protocol of IPFS, it has since been extracted to become its own first-class project.
The InterPlanetary File System is a peer-to-peer hypermedia protocol designed to make the web faster, safer, and more open.
Here are some of ink!'s key features:
- ink! provides a built-in test environment that can be used to perform off-chain unit testing with the Rust framework. This makes it simple and easy to ensure that your contract code functions as expected, without the need for third-party testing platforms. Learn more here.
FRAME provides an EVM execution pallet that allows unmodified EVM code to be executed in a Substrate-based blockchain. As a key part to Substrate's Ethereum compatibility layer, also known as Frontier, it works together with the Ethereum pallet and the Dynamic Fee pallet to enable the creation of runtimes capable of fully emulating Ethereum block production and transaction processing.
Contract calls are charged a gas fee to limit the amount of computational resources a transaction can use. When forming a contract transaction, a gas limit is specified. As the contract executes, gas is incrementally used up depending on the complexity of the computation. If the gas limit is reached before the contract execution completes, the transaction fails, contract storage is reverted, and the gas fee is not returned to the user.
$ git clone https://github.com/ZentaChain/Zentanetwork
$ cargo build --release
Check Runtime compiles:
cargo check -p zentachain-runtime
$ ./target/release/zentachain --dev
$ ./target/release/zentachain --local
$ ./target/release/zentachain --chain=local --alice -d /tmp/alice
$ ./target/release/zentachain ----chain=local --bob -d /tmp/bob --port 30334 --bootnodes '/ip4/127.0.0.1/tcp/30333/p2p/BOOTNODEID'
Zajin Network (Beta)
$ ./target/release/zentachain --zajin
Zentachain Mainnet (Main-net)
$ ./target/release/zentachain --zikaron
$ ./target/release/zentachain purge-chain --chain=ID
$ ./target/release/zentachain --help
Before you start the network in Docker please make sure you have installed Docker and Composer.
2.2 Install Docker
2.3 Install Docker Compose
2.4 Run in Docker
1.1 Launch the Frontend
- GPL V3
The reason for the split-licensing is to ensure that for the vast majority of teams using Substrate to create feature-chains, then all changes can be made entirely in Apache2-licensed code, allowing teams full freedom over what and how they release and giving licensing clarity to commercial teams.
In the interests of the community, we require any deeper improvements made to Substrate's core logic (e.g. Substrate's internal consensus, crypto or database code) to be contributed back so everyone can benefit.