Fork the Waves blockchain
In this article, Inal Kardanov, Waves developer advocate, explains how to better study the Waves protocol by creating your own chain.
This headline probably prompted you to think that the article will be centered on the Waves blockchain’s issues and a need to create a new network. You may rest assured that the Waves network is doing fine, but forking a blockchain is a good opportunity to study all of its specifics.
Earlier, in the article “Why join Gravity development,” I talked about two best ways to learn how different blockchain protocols work:
- Developing explorers and wallets
- Developing integration modules for Gravity.
One reader commented that I had missed another important option: launching your own network and experimenting with it. This is one of the most complicated ways, but it guarantees that you’ll learn all the specifics of a protocol.
The Waves protocol
Waves is primarily a protocol with its specifics and consensus algorithms, and chains built on that protocol come secondary. In addition to the mainnet, testnet and stagenet, the Waves protocol is partially or fully used by such projects as Turtle Network, Waves Enterprise and LTO Network.
These projects made a copy of the protocol’s source code, adding their own features. Some of these projects help develop the Waves protocol by suggesting improvements or reporting issues.
In the blockchain space, the word “fork” has a negative connotation due to past divisions of blockchains and their communities, such as Bitcoin and Bitcoin Cash, Ethereum and Ethereum Classic. But, speaking about a fork, I mean something else: the creation of your own copy of repositories with Waves node software source code.
Few blockchains can boast protocol implementation in various languages and stacks. Meanwhile, Waves has versions in Scala and Go. You can make a fork of the repositories and start experimenting, changing blockchain settings, assembling your own version and launching chains.
If you don’t have development experience in either Go or Scala, I suggest starting with Go as this language and its ecosystem are more beginner-friendly.
You can start with the node catalog, which features the modules:
- miner, which describes the mining and leader selection process under the Leased Proof of Stake (LPoS) consensus algorithm
- ride contains logic for the implementation of smart contracts in Ride. The simplicity of Ride makes studying this module’s source code a very interesting endeavor
- p2p is responsible for blockchain node interaction within a p2p network operating under rules, differing from those for other protocols, and you can come across interesting stuff here, as well.
Each module is sufficiently simple for modifying and experimentation. But if you have questions on protocol operation or, for instance, on how to compile a modified version, you can always ask them in the developer chat Waves Dev Jedi on Telegram.
Make your own blockchain!
If, for whatever reason, you’ve decided that you are not yet ready to study Waves protocol source code, I can suggest an equally interesting alternative of launching your own chain on the Waves protocol.
The simplest — yet least exciting — way to do it is by launching a Docker container: https://hub.docker.com/r/wavesplatform/waves-private-node. If you have a Docker module installed, by launching one command, you’ll have a one-node blockchain. Of course, blockchain’s main principle of decentralization is not observed here, but sometimes a network like that can be useful for development purposes.
To understand how a network operates and view all network interactions, you’ll still need several nodes. To launch a chain of that kind, you’ll need to take several simple steps.
- Install a relevant version of Java
- Create a genesis block
- Set network parameters, such as network byte and transaction genesis
- Sequentially launch nodes.
A detailed guide on launching a network can be found in the documentation: https://docs.waves.tech/en/waves-node/private-waves-network#setup-jar-node-with-custom-blockchain
For a Waves-based chain, you can also launch auxiliary services, such as Waves Explorer, data services and a matcher. And, of course, you can develop, test and use decentralized apps (dApps). Learn more about it in the article “How to Build, Deploy and Test a Waves RIDE dApp.”