WRITING SMART CONTRACTS ON PHAETON SIDECHAINS

Phaeton Technology
4 min readAug 22, 2021

Smart contracts are imperative for building highly scalable dApps on the Phaeton blockchain. However, it doesn’t work like Ethereum, where you can write smart contracts the platform. Instead, you can write smart contracts on Phaeton as a sidechain in JavaScript.

Understanding the sidechains

  • A sidechain works like a regular blockchain. Genesis block in the sidechain that determines its initial state. Authorized parties add blocks to the blockchain, and private agents on the network validate it. Supported transaction types are defined in the sidechain protocol. The sidechain is linked to the blockchain, but the design is such that the subsequent changes on a sidechain do not affect the main blockchain, which is running parallel. Speed and security issues on the main network do not affect the sidechains.
  • Phaeton smart contracts work as an independent sidechain. Therefore, it can work exclusively on the mainchain on its own. However, it is only used for moving funds and not for other purposes, unlike the usual smart contracts.

Sidechains make transactions cost-efficient.

  • It is done for a specific purpose. Payments through the mainchains such as Ethereum are too expensive and is deterring people from using their blockchains. Sometimes, the cost of moving funds could be more than the fund itself! Phaeton sidechain eliminates such a situation, providing people with a better option, where the transactions are a fraction of the usual costs.

Backend of dApps

  • Smart contracts on Phaeton may be functioning as the backend of dApps, while the front-end is what the user sees. The smart contract is the brain behind this system allowing developers to code the whole function in JavaScript.
  • As a platform, Phaeton can deploy and manage decentralised applications with clinical efficiency. It, however, should be limited to transfer to funds as the sidechain has been designed only for this purpose. These sidechains compliment the main blockchain.

Participation

  • Participants will have to join a smart contract on the Phaeton sidechain separately from the mainchain. They will also have to keep a copy of the smart contracts in their local machines.

Specifications

  • On the Phaeton blockchain, the network generates blocks every 5 seconds. If a block is not forged correctly, the transactions are flushed to the next block of the round, which will extend the transaction time by 5 seconds. Compared to many other blockchains, this is significantly less. The total cycle time is 17 minutes, and the consensus system is Delegated Proof of Stake (DPoS).

Super-quick hashing

  • Hashing algorithm on Phaeton is faster than competition like MD5 and SHA-3. Moreover, it is parallelizable on multi-core architecture and secures against length extension attacks. The job of a hash function is to take an input string which could be alphabets, numbers, and media files of any length and turn it into a fixed length. Length of the fixed bit might differ, such as 32-bit or 64-bit or 128-bit or 256-bit, in line with the specific hash function used in the sidechain or mainchain. The fixed-length cryptographic output emanating out of the process is called a hash.

Understanding delegated proof of stake.

  • Delegated Proof Of Stake (DPoS) is a refined type of Proof of Stake consensus algorithm. Delegated Proof of Stake (DPoS) was developed in 2014 by Daniel Larimer, founder of BitShares, Steemit and EOS. In this system, one needs to stake the required number of tokens to be allowed to the mintage process.
  • Anyone who stakes the tokens has the opportunity to select layer two nodes that would further validate blocks. These validators are rewarded in the native currency for their participation in addition to blocks. Nodes are assigned randomly for block verification.

Public or isolated sidechain network

  • With Phaeton, you might choose to go for a public or isolated network, depending on your requirements. A public sidechain is permissionless, meaning anyone can join and read, write, or participate. In addition, once the data has been validated, it is not possible to modify the data.
  • A private sidechain is permissioned, meaning only the people allowed access can participate in the network. Thus, one or more entities are controlling the network.

JS vs other computer languages

  • JavaScript (JS) has had a reputation for being a front-end language, though it can be efficiently used for backend applications, like writing smart contracts on Phaeton sidechains. Though there were options like Solidity, Phaeton has chosen to work with JS for specific reasons. JavaScript is an interpreted language, while Solidity is compiled. As a result, it can have significant differences in execution.
  • Apart from the technical differences, experienced JavaScript developers are easier to find than Solidity or any other blockchain-based language.

Wrapping up

  • Developers can use JavaScript to create smart contracts on Phaeton as sidechains. These contracts are, however, limited to the movement of funds. Phaeton sidechains considerably bring down the cost of transactions and also make it faster. You might choose to set up a public or isolated sidechain network, depending on your requirements.

For more information visit www.phaeton.io

--

--

Phaeton Technology

Phaeton utlilises Blockchain Technology to create sustainable communities for future generations using our own independent Blockchain platform.