Do you want to create the future of money? Do you want to build a local currency for your city? Do you want to track the assets of your company? Do you want to add blockchain to your existing product? or just want to experiment building a cryptocurrency with its own blockchain? If so, this article is for you! I will explain a quick way to build a proof of stake cryptocurrency running on its own blockchain. It’s simple and very quick 🚀!
This article is part of my Learning challenge where I learn about one topic each month. As you can imagine, this month, I was learning about blockchain & cryptocurrencies. I based this studies on a Coursera MOOC, a few articles, some whitepapers and the building of my own Proof of Stake Cryptocurrency and Coin Generator. Click here, if you want to know more about my methodology.
Define the coin
Before starting to create your coin you should define its purpose and identity.
What problem are you solving? A coin needs to solve a problem, it needs a
purpose 💪. It can be anything, a local currency, a store of value, a platform for storing data.
Let’s imagine I want to create a cryptocurrency to facilitate the exchange of fruits and veggies produced in my garden 🏡! Now I have a purpose, for the example indeed, let’s think about its identity.
Before building a coin you need to find an identity and define a few technical details:
- Find a name — VegeNetwork
- Find a symbol, 3 to 4 letters — VEGE
- Peer port, a number between 1000 and 65535, it’s the port used to the nodes to communicate with each other — 6874
- Testnet peer port, same but for the testing network — 5874
- API Port, the port of the API of the nodes, this port will be used by the wallet, and also as an API to trigger actions — 6876
- A logo
- A website domain (or a github)
That’s all you need let’s see how to build it now.
Build it in a few minutes 🚀
The Cryptocurrency that will be a clone of Nxt Cryptocurrency (from Jelurida). It uses the Proof of Stake consensus. There is no mining needed so it’s energy efficient. Also, the source code is in Java which is very well written and very easy to understand!
It will be released under the JPL license: https://www.jelurida.com/jpl
This license requires you to:
- Give 10% of your coins to the Nxt holders (we will see how)
- Keep your cryptocurrency open source
First, you need to download the CoinGenerator:
- Go to the repository https://github.com/sandoche/Proof-of-Stake-Cryptocurrency-generator
- Fork it (optional)
- Download your fork, or better clone it to your computer
- Make sure you have Java, NodeJS and Yarn installed
- Go to the folder you cloned, and run
Sync the Nxt blockchain
Then you need to sync the Nxt blockchain (it can take a few hours), there is about 500 MB of data to download. This is required because of the JPL license that asks to share 10% of the coins with the NXT holders.
To sync it, run it with:
npm run nxt
Then open http://localhost:7876/index.html in your favorite browser. Create a NXT account and save the private keys securely. Copy your nxt address and also its public key.
Create the Genesis block
Once the NXT blockchain synced we can create the genesis block. This genesis block will contain 1 billion of coins. From these coins, 10% will go to the NXT holders and the 90% will be distributed to the addresses you want to, thanks to the following process:
Open the file
docs/config/newGenesisAccounts.json, this file will define the repartition of the coins you are creating:
- You have to put the list of accounts you want to credit in the first block (the genesis block) and its matching public key. The total of the amounts should be 90000000000000000, it equals to 90% of the coins
- If you don't know what to do, just put your NXT address your created previously and it's public key like this and save it. If you are not sure about what you are doing check this video: https://www.youtube.com/watch?v=6Wg3uv07GU4
"my nxt address here": 90000000000000000
"the public key of this nxt address"
- Go to http://localhost:7876/test?requestTag=ADDONS click on “downloadJPLSnapshot”
- Upload your file “newGenesisAccounts.json”
- Copy paste the height you can see in your wallet as in the screenshot below, then submit. A file will be generated after a few minutes
- Save it as “genesisAccounts.json” in the
The last thing to do is to set up the public key of the address which is going to generate the 1 billion of coins in the genesis block!
To do so, create another account (like you did previously), and save its public address in the file
templates/conf/data/genesisParameter.json, also edit the epochBeginning with the current date.
Build your crypto
Now we are done setting up the genesis block it’s time to create the cryptocurrency and the blockchain! It’s the easy part:
- Update the images from
templates/imgaccording to your blockchain images and the favicon in
- Then just run
npm run generateand answer the generator's questions. Based on the identity you defined previously. The generator will clone the nxt-clone-starter, it will automatically change the port and name in the source code.
- Once the cryptocurrency generated you can, of course, edit the interface inside the
<yourCrypto>/htmlfolder and find the java source in
<yourCrypto>/src/java, note that you can find many parameters that you can edit in the following file
- Run it ! Go to
<yourCrypto>folder compile with
sh ./compile.sh(or win-compile.sh for Windows) then run with
sh ./run.sh(or run.bat for Windows).
Tada 🎉!!! Your crypto is alive! But just on your computer, that’s already something!
What else should I do?
Now what is next to do is:
- Hosting your cryptocurrencies on different servers, to do so check step 4 of this documentation: https://github.com/sandoche/Proof-of-Stake-Cryptocurrency-generator/blob/master/README.md
- Build the binaries and installer to share it with your future users, check the build doc: https://github.com/sandoche/Proof-of-Stake-Cryptocurrency-generator/blob/master/BUILD-README.md
- Build a community to get your first users, you can even give some coins for free, and eventually create a faucet to automate this process!
- Create a website!
That’s it! You can have a look at Motive, a cryptocurrency built with this generator: https://motive.network
- Why Cryptocurrencies Matter?
- How Cryptocurrencies Work (Technical Guide)
- Proof of What? Understand the Distributed Consensuses in Blockchain
- How to Make Money with Cryptocurrencies?
- How I Integrated Blockchain to My Existing Product (Kanbanote)