Difference between revisions of "How to create your own cryptocurrency"

From CoinWiki
Jump to: navigation, search
(Start the Miner Process)
Line 76: Line 76:
 
<code>./miner --log-level 4 --daemon-address localhost:57576 --address FRHDYLQrQzVWUkKECnAF49NWRKkdJMpxgJDEehEBqmyySkvmK7exaRd7U4NEoKqRA2hWh3pvCmvoiVySDYokeraiAiat2MC</code>
 
<code>./miner --log-level 4 --daemon-address localhost:57576 --address FRHDYLQrQzVWUkKECnAF49NWRKkdJMpxgJDEehEBqmyySkvmK7exaRd7U4NEoKqRA2hWh3pvCmvoiVySDYokeraiAiat2MC</code>
 
Be sure to use your wallet address from above. OMG! You're mining.  
 
Be sure to use your wallet address from above. OMG! You're mining.  
*If this is a new blockchain you will have mined the genesis block and got all of your premined coins if there were any. You should see things like the following every time your miner finds a block:
+
*If this is a new blockchain you will have mined the genesis block and got all of your premined coins if there were any.  
 +
Your miner should output something like the following every time it successfully mines a block:
 +
<code>2018-Jan-07 18:17:07.596731 DEBUG  [MinerManager] got BLOCK_MINED event</code>
 +
In your simplewallet terminal window you should see things like the following every time your miner finds a block:
 
<code>2018-Jan-07 18:11:25.916959 INFO    Height 1, transaction 1356d72e2ae74c552954a976f398c66f9ab4fbb5b72323e24c02a8c2c0e801f4, received 70.368475742208</code>
 
<code>2018-Jan-07 18:11:25.916959 INFO    Height 1, transaction 1356d72e2ae74c552954a976f398c66f9ab4fbb5b72323e24c02a8c2c0e801f4, received 70.368475742208</code>
  

Revision as of 02:22, 8 January 2018

Getting Started

One of the easiest ways to get your own blockchain up and running is with ForkNote, a CryptoNote blockchain fork with easy to setup configuration files. In this tutorial I make a few assumptions; mostly that you are comfortable on the Linux command line, know how to use tools like SSH, and have a basic understanding of networking and computing terminology.

Creating your Seed Nodes

This section only applies if you are creating your own blockchain, not if you will only be mining an existing blockchain. Before you can create your blockchain you're going to need seed nodes, basically the place where all other nodes are going to look so that they can update their own chain and find other peers. You'll need a minimum to two seed nodes to start. For our purposes, we're going to be using $5 / month instances on Amazon Lightsail.

Create Your Instances

  • Go to Amazon's Lightsail, if you do not have an account you'll need to create one.
  • Click on the "Create Instance" button.

Screen Shot 2018-01-05 at 7.57.44 PM.png

  • Select "OS Only", name your instances something meaningful, and create two them.

Screen Shot 2018-01-05 at 8.01.44 PM.png

  • Now we'll need to configure some network options like opening up the ports our nodes will use and adding static IP addresses. Click on your first instance and create a static IP for it.

Screen Shot 2018-01-05 at 8.20.30 PM.png

  • Go back to your home screen, select the same instance, and go into networking. Open TCP port 57575. You can use whatever port you want but for this tutorial this is what we'll be using

Screen Shot 2018-01-05 at 8.24.15 PM.png

  • Now do the exact same thing to your other instance.
  • Make a note of the two static IP addresses because we will be needing those for our configuration file. You might also need to download your private key from the connect section of your instance because we will use that to login. You can also use the "Connect using SSH" button from the connect section if you'd rather not mess around with keys, SSH apps, etc.

Create Your Configuration File

Forknote uses a configuration file that must be the same on all nodes. Creating a configuration file is easy when you use the online config file creator.

  • Blockchain Name: Be unique and creative. Your blockchain name should be all lowercase.
  • Address Prefix: All of your coins public addresses will start with this. It's not that important.
  • Money Supply: This number in conjunction with "Coin Decimal Point" will determine how many coins can exist on your blockchain. 18446744073709551615 is the maximum value allowed.
  • Coin Decimal Point: The number of decimal points your coin is allowed to have.
  • Percent of Premined Coins: The percentage of coins that will issued upon mining the genesis block.
  • Emission Speed Factor: CryptoNote rewards smaller and smaller rewards with each block mined. This value defines the emission curve slope.
  • Difficulty Target: This is the ideal amount of time that should go by between mined blocks. If blocks are being mined quicker, difficulty will go up. Transaction confirmation and emission speed both go up when this value is increased. The lower this number is the higher the orphan rate will be.
  • Genesis Coinbase Transaction Hex: Leave this blank, it will be generated for you.
  • Seed Nodes: Add the two IP addresses along with the port number we opened up for the two seed nodes that were created using Lightsail. The format should be IP:PORT, 52.88.81.50:57575 for example.

One you have filled in the require fields click the "View Config" button. Copy and save your config file somewhere as we will be using it to setup both seed and local nodes.

Install and Configure Forknote

  • Log into your Lightsail instance via SSH.
  • Download the Linux CLI version of Forknote from the Forknote download page. You can use wget from the command line like so:

wget https://github.com/forknote/forknote/releases/download/2.1.2/forknote-linux.tar.gz

  • Extract the archive. You can use tar from the command line like so:

tar -xzf forknote-linux.tar.gz

  • Change into the forknote-linux directory:

cd forknote-linux

  • Create a config file with your favorite text editor, paste the contents of the config file we generated earlier, and save it. I use nano:

nano sweetonium.conf

In your config file, change the value of p2p-bind-port to 57575 and the value of rpc-bind-port to 57576.

  • Start up your node in the background. You can specify your config and line file from the command line:

/home/ec2-user/forknote-linux/forknoted --no-console --log-level 4 --config-file ./sweetonium.conf --log-file ./sweetonium.log > /dev/null &

If you tail your log file you should see output:

tail -f ./sweetonium.log

You can do control+c to exit the tail command.

  • Now do the exact same thing on your other node. If you tail your log file you should see information about connecting to your other peer node. Yay!

Setting Up Your Local Node

Creating your local node is exactly the same as setting up your seed nodes, except this is where we will also be creating our wallet and doing our mining. If you're connecting to an existing blockchain, you just need its config file for this section. If you're creating your own we will be using the same config file we used on your seed nodes.

  • We will be opening three terminal windows for this part of the tutorial. One for the foknoted process, another for the simplewallet process, and the third for the miner process. In one terminal window download, extract, and create the configuration file exactly the same as above. Be sure to download the appropriate version for whatever OS you are using. For this tutorial we will be using a Mac.

Start the Forknoted Process

  • Run forknoted:

./forknoted --config-file configs/sweetonium.conf You should see some info about your now being synchronized with the network. You can type in "help" and then enter to see some commands that can be ran. "print_pl" is an interesting one that should show the peers you're currently connected to.

Start the Simplewallet Process

  • In another terminal window startup simplewallet:

./simplewallet --config-file configs/sweetonium.conf

  • Type in "G" and enter to create a new wallet. You can select whatever name you want but we'll be using sweetonium1 for this tutorial. The address next to "Generated new wallet:" is your public wallet address. Make a note of this as you will use it to mine. If your wallet hangs and doesn't output something that starts with "[wallet", kill forknoted in the other window (control+c) and restart it. Your wallet should re-connect properly. You can enter "help" here as well to see some commands, like checking your balance and transferring coins to another wallet.

Start the Miner Process

  • In another terminal window startup miner:

./miner --log-level 4 --daemon-address localhost:57576 --address FRHDYLQrQzVWUkKECnAF49NWRKkdJMpxgJDEehEBqmyySkvmK7exaRd7U4NEoKqRA2hWh3pvCmvoiVySDYokeraiAiat2MC Be sure to use your wallet address from above. OMG! You're mining.

  • If this is a new blockchain you will have mined the genesis block and got all of your premined coins if there were any.

Your miner should output something like the following every time it successfully mines a block: 2018-Jan-07 18:17:07.596731 DEBUG [MinerManager] got BLOCK_MINED event In your simplewallet terminal window you should see things like the following every time your miner finds a block: 2018-Jan-07 18:11:25.916959 INFO Height 1, transaction 1356d72e2ae74c552954a976f398c66f9ab4fbb5b72323e24c02a8c2c0e801f4, received 70.368475742208

Creating a Mining Pool