Mining
Getting Started with Mining
Overview
The SCDO mainnet consists of four shards and has a PoW consensus algorithm. Each shard acts like a single blockchain. While users can send transactions within a shard or between two different shards, a mining node (which is a piece of executable) can only mine in one shard. In order to mine SCDO tokens, you need an executable, named node, and a configuration file in json format. The configuration file has two key elements: coinbase - an address to receive tokens of reward, and a unique privateKey for the SCDO p2p network connection. In the next few sections, we will illustrate how to create a pair of address and private key, a p2p privateKey, and a configuration file. Once created, you are ready to mine SCDO.
For a complete guide of mining, please go to A complete guide
Download
Download the newest executables and configuration templates . The extracted directory has the following structure:
Our focus in the next section is on how to edit the json configuration template to create a configuration file. This file is necessary for running a mining node. We use a linux environment, and shard 1, node1.json configuration template for our illustration (Mac/windows command prompt execution is very similar) .
Let $PATH_TO_NODE_CLIENT denote the path to the directory where these template files and the executables "node" and "client" are.
Creating a configuration file
Open the configuration template node1.json in a text editor. The content is or similar to:
For the time being, we only need to replace the coinbase in the basic section and the privateKey in the p2p section in order to create a configuration file.
To generate them, execute the following command:
The output is:
Use 1S0113339046e140620a05ab98abdfadedbbd99191 to replace the coinbase in the basic section. Please store the private key in a safe place. You will need the private key when you make a transaction later.
Then execute the same command again:
The output is:
Use 0x442603781c5ea6993aa880cd991fefb167bc4fe9e68c25d9e7148b9872f07d5b to replace the privateKey in the p2p section. Discard the account string 1S018274d26bea7144a3d235620bc2ac6094e4f9d1.
Now we have:
Save the file as node1_1.json or a different name as you like in json format. For simplicity, let‘s save it in the $PATH_TO_NODE_CLIENT directory.
Note: each execution of ./client key --shard # gives you a different outcome.
You can create the configuration file for mining other shards in a similar way. For more detailed instructions go to Create configuration file
Run a miner
Before running a mining node, your computer has to be connected to the internet.
Execute the command:
After the node is up and running, logs will be printed out on your computer screen.
Note: the number 8 means that there are 8 threads to do mining in parallel. A user can change the number based on his machine. For example if his machine's CPU has 16 cores, then the number may be 16 or larger.
When the node is up and running and has connected to the SCDO network, it may take a couple of hours to synchronize its data with SCDO network. After the data of the node is in sync with that of the SCDO network, the node will start to mine blocks and compete with other nodes in SCDO network.
Check connection to SCDO network
After your node is up and running, you may want to check if the node is connected to the SCDO network in order to win SCDO tokens. The following command will do that:
The string after "- -address" indicates the ip and port of the node. In this example, you can use "- -address 0.0.0.0:8027". The default ports are 8027 for shard 1, 8028 for shard 2, 8029 for shard 3 and 8026 for shard 4. Since the node is mining in shard 1, the following lines are the output message. If "PeerCnt" is not zero, then the node is connected to the SCDO network. The (3 3 1 3) indicates how many nodes from the SCDO network in each shard are connected to your mining node. For example, there are 3 nodes in shard 1,1 node in shard 3, etc, connected to your node.
After the mining node has connected to at least one other node in the same shard, the synchronization of the SCDO network/blockchain data will start. It may take a couple of hours dependent on your internet connection speed to complete the sync. After this the real mining will start. You will understand it when you see the output messages from the running node.
Later we will show the option of running a node just for data synchronization.
Check account balance
After your mining node has been up for a period of time, you want to check that if any SCDO tokens (named SCDO) have been awarded to your account. In this section, we explain how to check the account balance.
The the hex format string after "coinbase:" in the configuration file is the address of your mining account. In our example, it is 1S0113339046e140620a05ab98abdfadedbbd88191.
Execute the following command:
The output will be like:
The actual balance may be different. Note: The balance unit is Wen. 100,000,000 Wen = 1 SCDO. So 400,000,000 Wen = 4 SCDO in the above output.
A Complete Guide of Mining
A basic introduction of SCDO network and mining
The SCDO network is a peer-to-peer (p2p) network, and the network nodes are partitioned into 4 shards. The SCDO blockchain has a PoW consensus algorithm named ZPoW, which is based on random matrix generation and determinant computation. ZPoW is CPU friendly. From the testing results of ZPoW, we do not observe any advantage from GPU/ASIC chips. So any one with a computer can mine the SCDO blockchain. The rewarding token is named SCDO. The minimum unit of SCDO is WEN, and 1 SCDO =100,000,000 WENS.
For a mining node in shard n: it keeps one local chain and 3 light chains for storing information or data. The local chain stores all transactions which involve accounts in the shard. Each light chain stores the hashes of blocks in a related local chain. For example, if the mining node is in shard 1, then it has a local chain to store all blocks of transactions from and to the accounts in shard 1. It uses a light chain for each of other 3 shards. For example, the light chain 2 stores all block hashes from the local chain of shard 2, etc. With the local chain and the light chains, the SCDO blockchain can work correctly.
Since the SCDO network nodes are partitioned into 4 shards, so are the accounts. An account has a unique pair of address and private key. The address is used for holding the balance and the private key is used for signing off out-bounded transactions.
In order to mine SCDO, one needs to create an account (or several).
A mining node can only mine in one shard when it is running and is configured by the json configuration file.
To summarize the above, in order to run a mining node, one needs
An account (a pair of address and private key),
A configuration file.
Again, all illustrations in the following are in a linux/unix environment. We assume that readers have a basic understanding about the operating system. The executions of commands in MAC, Windows are very similar to linux/unix.
Download the executables
Download the newest [executables and configuration templates] . The extracted directory has the following structure:
For mining, one only needs the executables of node and client, and creates his own configuration files from these templates. If one mines in shard 1, please use node1.json as a template. Use node2.json for shard 2, node3.json for shard 3, etc.
Dowload SCDO project source codes and compile
You may want to build the executables by yourself from the source codes. Here it is. Download the source codes from https://github.com/scdoproject and follow the instructions in README.md or go to Compile node section.
The configuration file templates shall be in the project source code directory $PROJECTRDIR/scdoproject/go-scdo/cmd/node/config where $PROJECTRDIR is the path to scdoproject in your local machine.
Create an account
An account is identified by a unique pair of address and private key. The first 4 characters of the address indicate which shard the account belongs to.
Let's assume that we are already in the directory which contains the executable node and client.
By executing the command,
The option can be any of 1,2,3,4.
For example, execute the following:
the output is like,
Account: 1S014f574f8b5749eff6d24f18640d820327c5daf1
Private key:0x1c18aaa42429e903aa4aba753e500e3e0061f7dbca6d1a2c6499b2226b72a0ec
Note the address is also labeled as "Account" in the output. The first 4 chars indicates which shard the account belongs to.
Note: each run of the same command line will produce a different outcome.
The output is
Account: 2S0215ac0412394ec2fa4215b72602a70724bf9b11
Private key: 0x4e19191ed142c5fb9af0425b16399a09e35ef1e913d68e4fd1cbbb538de74d7d
One can create in any shard as many accounts as he wants.
In general, an address and a private key has one-to-one correspondence. Since there are 4 shards, SCDO let you use only one private key to control four different accounts/addresses, one for each shard. Here is how:
Executing the command without shard option will always give a pair of address and private key in shard 1 :
The output is
Account: 1S01f18fd1317001c81d9cb8346521cdd9f486bb41
Private key: 0xa94c7bb78579585a8b1d3346034fc124ace2e79ba80c3107fbb3d72be86dcb8f
One may be already note that the first 4 chars in the Account string indicate which shard the account belongs to.
If one edits the account string in the output:
1S01f18fd1317001c81d9cb8346521cdd9f486bb41
to create the following
2S02f18fd1317001c81d9cb8346521cdd9f486bb41
3S03f18fd1317001c81d9cb8346521cdd9f486bb41
4S04f18fd1317001c81d9cb8346521cdd9f486bb41
then there will be four different pairs:
Account: 1S01f18fd1317001c81d9cb8346521cdd9f486bb41
Private key: 0xa94c7bb78579585a8b1d3346034fc124ace2e79ba80c3107fbb3d72be86dcb8f
Account:2S02f18fd1317001c81d9cb8346521cdd9f486bb41
Private key: 0xa94c7bb78579585a8b1d3346034fc124ace2e79ba80c3107fbb3d72be86dcb8f
Account: 3S03f18fd1317001c81d9cb8346521cdd9f486bb41
Private key: 0xa94c7bb78579585a8b1d3346034fc124ace2e79ba80c3107fbb3d72be86dcb8f
Account: 4S04f18fd1317001c81d9cb8346521cdd9f486bb41
Private key: 0xa94c7bb78579585a8b1d3346034fc124ace2e79ba80c3107fbb3d72be86dcb8f
These are all valid accounts in SCDO and with the same private key 0xa94c7bb78579585a8b1d3346034fc124ace2e79ba80c3107fbb3d72be86dcb8f. However we prefer to generate an account by executing the command line one by one.
Now you know how to generate a pair of public and private keys. Let's move on to the next.
Create a configuration file
A configuration file is a must in order to start a mining node. We will start from a configuration template and explain each of its sections. Then users can edit the template file to create configuration files of their own.
A configuration file template
Explanation of the configuration template file
basic section
"name": the name of the node, just for your information. This name indicates which shard the node belongs to.
"version": The version number of SCDO release. It is the version number of node you are running.
"dataDir": The directory for storing the data produced by the node, such as blockchain data, the network connection data file, etc. One can use the same as the "name" string.
"address": ip address and port number -- your local ip address and the port number to the mining node. This information will be used when executing the "client" command. For a mining node in shard 1, the port number is set to 8027 (actually it can be any port number as long as there is no conflict)
"coinbase": The address of your account. Please refer to the section Create an account to create it.
"algorithm": "zpow" -- no change is needed.
p2p section
The "privatekey": It is a unique network identifier for your running node. You need to create one to replace the one in the example. It is created by command "./client key ", also see Create an account. you can use the private key in the output of the command to replace the privateKey and cast the account string away. This private key has nothing to do with your account private key.
"staticNodes": These ip addresses are the starting nodes that your mining node tries to connect. In general, you do not need to replace them from the templates (you may add more later). The port numbers: 8057 is for shard 1, 8058 shard 2, 8059 shard 3, 8056 shard 4. These static nodes are usually managed by the SCDO project team. And they are for data synchronization of the SCDO blockchain.
"address": the local ip address and port number of your node. If you mine in shard 1, the port number shall be 8057, etc. If other mining nodes want to connect your node, that is the port number to be used.
"networkID": This is the id of the SCDO network. No modification is needed, otherwise it will prevent your mining node from joining the SCDO network.
The other sections
No changes are needed.
After editing the configuration template, you can save it to a file in json format, example node1_1.json (or any name can work as long as you know for which shard).
Run mining node
Execute the following command
For example, using the configuration file we created earlier, the command will be:
If this is your first time executing the command, it may take a few hours to synchronize all data, you will be better off if using the following option:
This will speed up the synchronization of data.
You will see the logs line by line on your screen. These are information messages which you can "pipe" and save to a file. It shall start to synchronize the data with the SCDO network shortly if the connections of your node to the SCDO network are established.
Check connections to SCDO network
After your mining node is up and running, in order to have a chance to win some reward tokens, the node has to be connected to the SCDO network. In addition, it shall have connections to nodes in each shard in order to maintain robust connections to the network.
For getting the general connection information, use
The string after "- -address" indicates the ip and port of the node. In this example, you can skip it because the default value is 0.0.0.0:8027 (for shard 1). The outcome will be like
"BlockAge": 23 indicates the age of the most recent block in the shard mined.
"Coinbase": "1S011c9dab11f953875fafc374a641bdaf58488771", your mining address.
"CurrentBlockHeight": 3339035, the height of the most recent block.
"HeaderHash": "0x53edbf3f80e3ffeefcb28cf6070939df7ea46926e94502f5e60a96e7459790b0", the hash of the header of the most recent block of the shard, which is shard 1 in our example.
"MinerStatus": "Running", the status of the miner.
"PeerCnt": "10 (3 3 1 3)", indicates the total peers connected are 10, 3 in shard 1, shard 2, and shard 4 respectively, and 1 in shard 3. If you see no zero, that is good!
"Shard": 1, mining is in shard 1.
If you want to learn more about the connections, please execute the following:
The outcome will be similar to the following:
In the above illustration, the mining node is in shard 1. Let's try to understand the messages. The outcome consists of multiple sections of the same data structure as
The above tells that the connected remote node belongs to shard 1 which has the IP address "74.208.207.184:8057". You can ignore the other part of the message for now.
The following section tells that the connected remote node belongs to shard 4.
The other similar sections have similar meanings.
Check your balance
Even if your mining node is fully connected to the SCDO network, winning some rewards is not a sure thing. The number of SCDO that you win will depend on your machine's computing power. For example, an Intel i5 processor will be slower than an i9 most likely.
This is the command you execute to check the balance:
you will see the balance from the outcome.
Note:
1S01cf0b32593068f2ace7c472d5f127d3422d3b61 -- this shall be replaced by the coinbase in your configuration file
0.0.0.0:8027 -- this is the default ip address for your mining node in shard 1. It can be replaced by a static node's ip address in shard 1, you will get the same result if your local node is in sync with the static node.
Compile Node
First you need to install git, gcc, go (linux/mac/windows) packages on your machine.
git version 2.17.1 or newer.
gcc version 7.3.0 or newer.
go version 1.12.7 (this has to be the exact version due to some linked libraries being used)
create the path go/src/github.com/scdoproject in the home directory
Download go-scdo
Compile go-scdo:
The following is for linux/mac
All executables shall be in ./build
For Windows, instead of "make all", execute "buildall.bat" in a command prompt.
Last updated