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

From CoinWiki
Jump to: navigation, search
(Pool Configuration)
(Getting access via SSH)
 
(One intermediate revision by the same user not shown)
Line 28: Line 28:
 
=== Getting access via SSH ===
 
=== Getting access via SSH ===
 
* You can use the "Connect using SSH" button from the connect section if you'd rather not mess around with keys, [[SSH]] apps, etc.  But I found the [[Lightsail]] SSH more difficult to use.
 
* You can use the "Connect using SSH" button from the connect section if you'd rather not mess around with keys, [[SSH]] apps, etc.  But I found the [[Lightsail]] SSH more difficult to use.
* To use the OS/X Terminal interface, you will need to download your [[private key]] from the connect section of your instance because we will use that to login.  Open Terminal, go do the directory where the private key is stored, and then use a command like this, but customized using your lightsail location and IP Address.
+
* To use the OS/X [[Terminal]] interface, you will need to download your [[private key]] from the connect section of your instance because we will use that to login.  Open [[Terminal]], go do the directory where the private key is stored, and then use a command like this, but customized using your lightsail location and IP Address.
  
 
<code>ssh -i ./LightsailDefaultPrivateKey-us-west-2.pem ec2-user@<<IP address>></code>
 
<code>ssh -i ./LightsailDefaultPrivateKey-us-west-2.pem ec2-user@<<IP address>></code>
Line 166: Line 166:
  
 
== Creating a [[Mining Pool]] ==
 
== Creating a [[Mining Pool]] ==
Setting a mining pool is similar to setting up one of your seed nodes. For the pool, we will be using a $10 / month instance on [https://lightsail.aws.amazon.com/ Amazon Lightsail].
+
Now that you have created your own cryptocurrency and can then [[create a mining pool for your new coin]].
 
 
=== Create Pool Instance ===
 
* Click on the "Create Instance" button.
 
[[File:Screen_Shot_2018-09-03_at_11.12.28_AM.png|500px]]
 
* Select "OS Only", choose Ubuntu and name your instance something meaningful.
 
[[File:Screen_Shot_2018-09-03_at_11.12.47_AM.png|500px]]
 
* Click on the instance for your pool and create a static IP for it.
 
* Open the following ports under networking:
 
[[File:Screen_Shot_2018-09-03_at_11.18.35_AM.png|500px]]
 
 
 
=== Install Dependancies ===
 
<code>sudo apt-get install aptitude </code>
 
 
 
<code>sudo aptitude update</code>
 
 
 
<code>sudo aptitude install –with-recommends build-essential autotools-dev autoconf automake libcurl3 libcurl4-gnutls-dev git make cmake libssl-dev pkg-config libevent-dev libunbound-dev libminiupnpc-dev doxygen supervisor jq libboost-all-dev htop</code>
 
 
 
<code>apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev </code>
 
 
 
<code>apt-get install libboost-all-dev git npm nodejs nodejs-legacy libminiupnpc-dev redis-server</code>
 
 
 
<code>add-apt-repository ppa:bitcoin/bitcoin</code>
 
 
 
<code>apt-get update</code>
 
 
 
<code>apt-get install libdb4.8-dev libdb4.8++-dev</code>
 
 
 
<code>curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh -o install_nvm.sh</code>
 
 
 
<code>bash install_nvm.sh</code>
 
 
 
* After npm is installed you will have to log out and then back into your instance and continue installing dependancies.
 
 
 
<code>source ~/.profile</code>
 
 
 
<code>nvm install 0.10.48</code>
 
 
 
<code>nvm use 0.10.48</code>
 
 
 
<code>nvm alias default 0.10.48</code>
 
 
 
<code>nvm use default</code>
 
 
 
* Install Apache2 for hosting the front end.
 
 
 
<code>sudo apt-get update</code>
 
 
 
<code>sudo apt-get install apache2</code>
 
 
 
* Adjust firewall to allow Apache full.
 
 
 
<code>sudo ufw app list</code>
 
 
 
<code>sudo ufw allow 'Apache Full'</code>
 
 
 
=== Install Forknote ===
 
*Download the Linux CLI version of Forknote from the [http://forknote.net/download/ Forknote download page]. You can use wget from the command line like so:
 
 
 
<code>wget https://github.com/forknote/forknote/releases/download/2.1.2/forknote-linux.tar.gz</code>
 
 
 
*Extract the archive.
 
 
 
<code>tar -xzf forknote-linux.tar.gz</code>
 
 
 
*Change into the forknote-linux directory:
 
 
 
<code>cd forknote-linux</code>
 
 
 
* Copy your config file into 'sweetonium.conf'
 
<code>nano sweetonium.conf</code>
 
 
 
=== Start Forknoted ===
 
<code>./forknote-linux/forknoted --no-console --log-level 4 --config-file ./sweetonium.conf --log-file ./sweetonium.log > /dev/null &</code>
 
 
 
=== Start Simplewallet ===
 
* Create a new wallet and make note of the wallet address and view key.
 
<code>./simplewallet --config-file ./sweetonium.conf</code>
 
 
 
* Type 'exit' and run the following code
 
<code>./simplewallet --config-file ./sweetonium.conf --wallet-file <wallet_name> --password <wallet_password> --rpc-bind-port 57577</code>
 
 
 
=== Setup and install pool software ===
 
<code>git clone https://github.com/forknote/cryptonote-universal-pool.git pool</code>
 
 
 
<code>cd pool</code>
 
 
 
<code>npm update</code>
 
 
 
=== Pool Configuration ===
 
* Copy config_example.json to config.json
 
<code>cp config_example.json config.json</code>
 
* Edit config.json to match your coin's configuration
 
This is important! Damon port must equal your rpc-bind-port and wallet port must equal the port you started simplewallet with. You can leave the API port alone.
 
[[File:Screen_Shot_2018-09-03_at_12.12.26_PM.png|500px]]
 
 
 
=== Start Pool ===
 
<code>node init.js</code>
 
 
 
=== Host the front end ===
 
To host the front end we will need to copy everything in the website directory into the html directory
 
 
 
<code>sudo cp -rf admin.html config.js custom.css custom.js index.html pages/ themes/ /var/www/html</code>
 
 
 
You can see your website by looking up your pool's IP address in a browser
 
 
 
=== Customizing your website ===
 
* Go into the html directory and edit config.js with your pool's IP
 
<code> cd /var/www/html</code>
 
 
 
<code>sudo nano config.js</code>
 
 
 
[[File:Screen_Shot_2018-09-03_at_12.26.19_PM.png|500px]]
 
 
 
* Go into index.html to change the name of your mining pool
 
<code>sudo nano index.html</code>
 
 
 
[[File:Screen_Shot_2018-09-03_at_12.52.22_PM.png|500px]]
 
 
 
Optional
 
* Edit custom.css to create your own pool's style
 
* Edit custom.js for changing the functionality of your pool's website
 
 
 
This is an example of what your website can look like:
 
 
 
[[File:Screen_Shot_2018-08-30_at_8.42.09_PM_copy.png|500px]]
 

Latest revision as of 04:43, 14 January 2019

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

Opening up a port that our nodes will use

Click on your first instance, go to "Networking" 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

Adding a Static IP address

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

Make a note of the static IP addresses because we will be needing those for our configuration file.

Second Instance

Now do the exact same thing to your other instance.

Getting access via SSH

  • You can use the "Connect using SSH" button from the connect section if you'd rather not mess around with keys, SSH apps, etc. But I found the Lightsail SSH more difficult to use.
  • To use the OS/X Terminal interface, you will need to download your private key from the connect section of your instance because we will use that to login. Open Terminal, go do the directory where the private key is stored, and then use a command like this, but customized using your lightsail location and IP Address.

ssh -i ./LightsailDefaultPrivateKey-us-west-2.pem ec2-user@<<IP address>>

Install 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 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.
  • Addresses for the premined coins (only if you elect to premine some coins)
  • 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. The sweetonium config file I just created looks like so:

seed-node=52.88.81.50:57575
seed-node=54.212.229.202:57575
EMISSION_SPEED_FACTOR=18
DIFFICULTY_TARGET=120
CRYPTONOTE_DISPLAY_DECIMAL_POINT=12
MONEY_SUPPLY=18446744073709551615
GENESIS_BLOCK_REWARD=0
DEFAULT_DUST_THRESHOLD=1000000
MINIMUM_FEE=1000000
CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW=10
CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE=100000
MAX_TRANSACTION_SIZE_LIMIT=100000
CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX=86
DIFFICULTY_CUT_V1=60
DIFFICULTY_CUT_V2=60
DIFFICULTY_CUT=0
DIFFICULTY_LAG_V1=15
DIFFICULTY_LAG_V2=15
DIFFICULTY_LAG=0
DIFFICULTY_WINDOW_V1=720
DIFFICULTY_WINDOW_V2=720
DIFFICULTY_WINDOW=17
ZAWY_DIFFICULTY_V3=1
ZAWY_DIFFICULTY_DIFFICULTY_BLOCK_VERSION=3
p2p-bind-port=57575
rpc-bind-port=57576
BYTECOIN_NETWORK=ec205c96-d86d-d432-faf0-61b59b013dd0
CRYPTONOTE_NAME=sweetonium
GENESIS_COINBASE_TX_HEX=010a01ff0001ffffffffffff0f029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd0880712101121c395752e39611ed126c7e5f4f09aca288cdecf4f877bd2d9d319d0bc69712
MAX_BLOCK_SIZE_INITIAL=100000
UPGRADE_HEIGHT_V2=1
UPGRADE_HEIGHT_V3=30
  • Create a config file with your favorite text editor, paste the contents of the config file we just generated, 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:

example

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

generic

./forknoted --no-console --log-level 4 --config-file ./<<yourname>>.conf --log-file ./<<yourname>>.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

or if your config file is in the same directory

./forknoted --config-file ./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

If you left DIFFICULTY_TARGET set to 120, and you're the only one mining, it should be about every two minutes after the first couple of blocks.

Transferring Coins to Another Wallet

You can transfer coins to another of your own wallets or someone else's by issuing the transfer command to the simplewallet process:

transfer 0 WALLET_ADDRESS COIN_AMOUNT

The first number is the mixin_count, a security mechanism to hide which transaction is the real transaction. For a new blockchain it's easier to just use 0 until there are more peers, then you can use more. The next argument is the wallet address where you'd like to send the coins, this can be another of your own wallets or someone else's. You can create more of your own wallets by running the simplewallet process like we did above. The last argument is the amount of coins you with to transfer. There is a small fee that goes to the miner when transferring so you must take this into account, you can also only transfer your available (confirmed) amount.

Creating a Mining Pool

Now that you have created your own cryptocurrency and can then create a mining pool for your new coin.