-
Notifications
You must be signed in to change notification settings - Fork 38
Mining
Webchaind is three-in-one : node of global webchain network, wallet and miner
You can make solo block mining with webchaind node or download Miner binaries and mine by pool. Also you can download Wallet binaries with GUI version
At first we need to run webchaind and create our wallet on which we will get mining rewards
Step 1. Downloading webchaind daemon/wallet and creating wallet number
Download webchaind according to your operating system from here - https://github.com/webchain-network/webchaind/releases and unpack it
From CMD, PowerShell or your preferred console, go to the route where you stored webchaind.exe.
Let’s say you stored webchain.exe in the recommended directory *$HOME\AppData\Roaming\Webchain/*
<~ where $home is your C:\Users\UserName
path
Input the following command: cd c:\users\UserName\AppData\Roaming\Webchain
and hit enter
Once you’re there, you can write all the commands that webchaind.exe can execute!
Now we need to run console command, which create wallet in webchain network. Run from console:
webchaind.exe account new
For example you unpack it to /opt/webchaind/
in linux shell go to this folder by command cd /opt/webchaind/ run command from linux shell in this folder:
./webchaind account new
Result of command same for windows and linux , you will be prompted for password (enter it and save it in safe place!) and you will see you account wallet number:
Your new account is locked with a password. Please give a password. Do not forget this password. Passphrase: Repeat passphrase: Address: {918e173c8426593bd37d5bc7d03f17dcc154cd5b}
So 918e173c8426593bd37d5bc7d03f17dcc154cd5b is your wallet number.
Step 2. Running webchaind daemon/wallet console
Run command
webchain console (on Linux)
or
webchaind.exe console (Windows )
From same dir you stored webchaind binary
You will see initial screen from webchain.network and console prompt like
2018-05-10 21:40:54 webchaind version: v0.1.0 2018-05-10 21:40:54 Blockchain: Webchain Mainnet 2018-05-10 21:40:54 Chain database: /root/.webchain/mainnet/chaindata ..... coinbase: 0x918e173c8426593bd37d5bc7d03f17dcc154cd5b at block: 13041 (Thu, 10 May 2018 12:19:30 EEST) datadir: /root/.webchain/mainnet modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
>
So in this console you can run all commands to communicate with webchain network.
For example:
> webchain.coinbase "0x918e173c8426593bd37d5bc7d03f17dcc154cd5b"
will show you your based wallet number in system
web3.fromWei(webchain.getBalance(webchain.coinbase), "ether")
0
Will show your actual balance of your wallet, currently its 0 , but we will mine and it will grow up
Step 3. Mining
Mining is math process of confirmation next block with transactions in system. Approximately new block in webchain created every 10 minutes. Its no need to know much more even previous information to get money to wallet by mining :)
CPU Mining with Webchains
NOTE: Ensure your blockchain is fully synchronised with the main chain before starting to mine, otherwise you will not be mining on the main chain.
When you start up your webchain node with webchaind it is not mining by default. To start it in mining mode, you use the --mine command line option. The -minerthreads parameter can be used to set the number parallel mining threads (defaulting to the total number of processor cores).
webchaind --mine --minerthreads=4
You can also start and stop CPU mining at runtime using the console. miner.start takes an optional parameter for the number of miner threads.
> miner.start(8)
true
> miner.stop()
true
Note that mining for WEBs only makes sense if you are in sync with the network (since you mine on top of the consensus block). Therefore the wechain blockchain downloader/synchroniser will delay mining until syncing is complete, and after that mining automatically starts unless you cancel your intention with miner.stop().
In order to earn WEBs you must have your etherbase (or coinbase) address set. This etherbase defaults to your primary account. If you don't have an etherbase address, then webchain--mine will not start up.
You can set your etherbase on the command line:
webchain --etherbase 1 --mine 2>> webchain.log // 1 is index: second account by creation order OR webchain --etherbase '0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff' --mine 2>> webchain.log
You can reset your etherbase on the console too:
miner.setEtherbase(webchain.accounts[2])
Note that your etherbase does not need to be an address of a local account, just an existing one.
There is an option to add extra Data (32 bytes only) to your mined blocks. By convention this is interpreted as a unicode string, so you can set your short vanity tag.
miner.setExtra("ΞTHΞЯSPHΞЯΞ")
...
debug.printBlock(131805) BLOCK(be465b020fdbedc4063756f0912b5a89bbb4735bd1d1df84363e05ade0195cb1): Size: 531.00 B TD: 643485290485 { NoNonce: ee48752c3a0bfe3d85339451a5f3f411c21c8170353e450985e1faab0a9ac4cc Header: [ ... Coinbase: a4d8e9cae4d04b093aac82e6cd355b6b963fb7ff Number: 131805 Extra: ΞTHΞЯSPHΞЯΞ ... }
See also this proposal
You can check your hashrate with miner.hashrate, the result is in H/s (Hash operations per second).
> miner.hashrate 712000
After you successfully mined some blocks, you can check the WEBs balance of your etherbase account. Now assuming your etherbase is a local account:
> webchain.getBalance(webchain.coinbase).toNumber(); '34698870000000'
In order to spend your earnings on gas to transact, you will need to have this account unlocked.
> personal.unlockAccount(webchain.coinbase) Password true
You can check which blocks are mined by a particular miner (address) with the following code snippet on the console:
function minedBlocks(lastn, addr) { addrs = []; if (!addr) { addr = webchain.coinbase } limit = webchain.blockNumber - lastn for (i = webchain.blockNumber; i >= limit; i--) { if (webchain.getBlock(i).miner == addr) { addrs.push(i) } } return addrs } // scans the last 1000 blocks and returns the blocknumbers of blocks mined by your coinbase // (more precisely blocks the mining reward for which is sent to your coinbase). minedBlocks(1000, webchain.coinbase); //[352708, 352655, 352559]
Note that it will happen often that you find a block yet it never makes it to the canonical chain. This means when you locally include your mined block, the current state will show the mining reward credited to your account, however, after a while, the better chain is discovered and we switch to a chain in which your block is not included and therefore no mining reward is credited. Therefore it is quite possible that as a miner monitoring their coinbase balance will find that it may fluctuate quite a bit.
The logs show locally mined blocks confirmed after 5 blocks. At the moment you may find it easier and faster to generate the list of your mined blocks from these logs.
Mining success depends on the set block difficulty. Block difficulty dynamically adjusts each block in order to regulate the network hashing power to produce a 10 second blocktime. Your chances of finding a block therefore follows from your hashrate relative to difficulty. The time you need to wait you are expected to find a block can be estimated with the following code:
INCORRECT...CHECKING
etm = webchain.getBlock("latest").difficulty/miner.hashrate; // estimated time in seconds Math.floor(etm / 3600.) + "h " + Math.floor((etm % 3600)/60) + "m " + Math.floor(etm % 60) + "s"; // 1h 3m 30s
Given a difficulty of 3 billion, a typical CPU with 800KH/s is expected to find a block every ....?
We download miner binary for your system from here https://github.com/webchain-network/webchain-miner/releases
Then unpack it and in dir of unpacked miner we see file config.json , which is our miner configuration file, which contains main mining setting, like wallet number, threads , max-cpu-usage , etc.
The main thing we need to do is to set your wallet number where we will get reward to config.json
So we put our wallet number created by webchaind to "user" field of config.json, it shoud be set like this:
"user": "0x918e173c8426593bd37d5bc7d03f17dcc154cd5b",
Now we can save config.json , start mining and get rewards
We ready to start miner, it done by command:
./webchain-miner
(Linux)
or
webchain-miner.exe
(Windows)
Now we will see screen like that:
./webchain-miner
- VERSIONS: webchain-miner/2.6.2 libuv/1.20.3-dev gcc/6.3.0
- CPU: Intel(R) Xeon(R) CPU D-1521 @ 2.40GHz (1) x64 AES-NI
- CPU L2/L3: 1.0 MB/6.0 MB
- THREADS: 5, cryptonight-webchain, av=1, donate=5%
- POOL #1: pool2.webchain.network:2222
- COMMANDS: hashrate, pause, resume
[2018-05-10 16:54:36] use pool pool2.webchain.network:2222 212.32.255.73
[2018-05-10 16:54:36] new job from pool2.webchain.network:2222 diff 5000 algo cn-web/1
[2018-05-10 16:54:36] READY (CPU) threads 5(5) huge pages 0/5 0% memory 10.0 MB
[2018-05-10 23:26:02] speed 2.5s/60s/15m 14.6 14.8 13.6 H/s max: 20.3 H/s
[2018-05-10 23:26:23] accepted (1/0) diff 5000 (170 ms)
Short description:
Pool is service which devide block finding task from webchain network between all miners in pool and also divide reward based on miners hashrate
Job is mining block finding task from network H/s is how much hashes in second your CPU can generate to find correct solution of block task accepted means your CPU found correct solution of task , send it to pool and it can be one of multiply correct block solution for what network will reward pool by 50 WEB, which will divide between miners based on their hasrate
So all you need is to run miner and wait some time (maybe 5 min, maybe 1 hour) when your miner find accepted shares and pool will give some part of reward coins to your account.
Step 4. Pool and payments
Currently we have official pool - pool.webchain.network:3333
So we start mining and then open https://pool.webchain.network/
in search string below "Your Stats & Payment History" we put our wallet number:
0x918e173c8426593bd37d5bc7d03f17dcc154cd5b
and after miner send his first accepted share we will see realtime stats on top of page
First of all you will get coins in Immature Balance, it means you got coins from network, but they need confirmation. Pending Balance is your money already which wait pool payment schedule to pay to your wallet Total Paid: is how much money already sent from pool to your wallet Last Share Submitted means how much time ago your miner(s) submit accepted share to pool Workers Online means how much computers mine with the same wallet Hashrate (30m) and (3h) shows your common average from all your computers where you mining with this wallet number Blocks Found means how much block was found by your share solution Total payments means how much payment schedules was completed from pool with payment to your wallet Your round share is how much job of block solution your miner(s) do in comparison with all miners in pool
So when you will see some amount in Total paid, you can go back to your webchaind console and write command again:
web3.fromWei(webchain.getBalance(webchain.coinbase), "ether")
5
You will see other amount then 5 but it will be different from 0
If not, there can be some reason. First - your webchaind not synchronizing with network. So you need some time to wait (maybe about 1 hour) Also you can try to run
webchaind --fast console
or you can download blockchain file here: https://webchain.network/blockchain.raw and import it by executing:
$ webchaind --fakepow import <path where you downloaded the blockchain>/blockchain.raw
and retry to get balance, or wait some time and try again
Second - your local time is not correct
Check please your OS for how to resync your clock (example sudo ntpdate -s time.nist.gov
) because even 12 seconds too fast can lead to 0 peers.
Also you can see your real time balance of coins at https://explorer.webchain.network, enter you wallet number at the right top of page and you will how much coins you have for now
How to transer funds you can see at Transfers