How to Build Your Own Cryptocurrency (PoS) in Just a Few Minutes

#9 — A step by step guide to build a Proof of Stake cryptocurrency with its own blockchain

Screen generator, the tool that will help us to generate a coin!

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.

The purpose

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.

The 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

Download CoinGenerator

First, you need to download the CoinGenerator:

  1. Go to the repository https://github.com/sandoche/Proof-of-Stake-Cryptocurrency-generator
  2. Fork it (optional)
  3. Download your fork, or better clone it to your computer
  4. Make sure you have Java, NodeJS and Yarn installed
  5. Go to the folder you cloned, and run npm install

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
{
    "balances": {
         "my nxt address here": 90000000000000000
     },
     "publicKeys": [
         "the public key of this nxt address"
     ]
 }

Once done:

  1. Go to http://localhost:7876/test?requestTag=ADDONS click on “downloadJPLSnapshot”
  2. Upload your file “newGenesisAccounts.json”
  3. 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
  4. Save it as “genesisAccounts.json” in the templates/conf/data folder.
The height is on the top left-hand corner: 1763825 in this case, the number of the last block, be sure that the blockchain is totally downloaded, unlike this screenshot!

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:

  1. Update the images from templates/img according to your blockchain images and the favicon in templates
  2. Then just run npm run generate and 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.
  3. Once the cryptocurrency generated you can, of course, edit the interface inside the <yourCrypto>/html folder and find the java source in <yourCrypto>/src/java, note that you can find many parameters that you can edit in the following file <yourCrypto>/src/java/nxt/Constants.java
  4. 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:

That’s it! You can have a look at Motive, a cryptocurrency built with this generator: https://motive.network

What’s next?

This article is part of my Learning Challenge about Blockchain & Cryptocurrencies. Like this one, I made 5 others article related to the topic.

If you liked this post, please click the clap 👏button below a few times to show your support! Also, feel free to comment and give any kind of feedback. Don’t forget to follow me!


How to Build Your Own Cryptocurrency (PoS) in Just a Few Minutes was originally published in Learning Lab on Medium, where people are continuing the conversation by highlighting and responding to this story.