All projects mentioned here INCLUDING the ChaosMiner are all still under development and in an early public beta phase. All NotioCoin your ChaosMiner mines during this beta phase should be considered as a valueless test token, though it will allow you to stake and replicate Ideas on our testnet. Learn More at https://decentracorp.co

A ChaosMiner built from this tutorial will be able to mine real NotioCoin once the project Launches its own MainNet later this year!

We are currently looking for other developers to help out on this project. Anyone interested should send an email to decentracorp@pm.me. The only requirement to help out is a willingness to learn!

Any and all questions can be sent to this email as well.

To understand what the ChaosMiner is we will first have to briefly cover the projects that spawned and facilitate its existence.

DecentraCorp is the worlds first Decentralized Autonomous Corporation(DAC), an extension of the Decentralized Autonomous Organizastion(DAO) concept. Anyone anywhere can become a member of DecentraCorp and begin operating their own DC Facility where they produce DecentraCorp products powered by the CryptoPatent Blockchain.

The CryptoPatent Blockchain is the worlds first copy-left patent system for open-source Ideas. The CryptoPatent Blockchain is governed by the members of DecentraCorp who have the ultimate say in what ideas are patented to the CryptoPatent Blockchain(this is done via community vote through our dApp). Ideas approved by the community are stored in what are called IdeaBlocks which mine the inventor of an Idea 1000 NotioCoin when mined. All applicable Ideas must be open source!

Once patented to an IdeaBlock, an Idea can be replicated by all other members of DecentraCorp and those replications can be activated for mining status for the cost of 100 NotioCoin. An activated replication can then mine UseBlocks when the replication is used. A UseBlock's block reward is dependent upon the Idea it was replicated from and a pre-chosen percent of what a replication mines when it mines a UseBlock is sent to the Ideas Inventor as a royalty.

Now that we have a cursory understanding of DecentraCorp and the CryptoPatent Blockchain and how they work I am going to move on the ChaosMiner. DecentraCorp operates under what is called the Decentralized Facility model. This model allows DecentraCorp members to petition the community for funding for their individual facilities. This is where the ChaosCasino was born.

The ChaosCasino is a Blockchain based multiplayer suit of CasinoGames operated by DecentraCorp that allows users to play games like poker against each other. The ChaosCasino gets a small cut from each table it hosts which is then put under the control of DecentraCorp for facility funding requests.

With this long and probably confusing backstory out of the way we can finally get to what the ChaosMiner is and how it works. It is a well known problem in the blockchain space(specifically the smart-contract space) that random numbers cannot be securely generated from within a contract itself. This is due to the fact that every transaction made to a smart contract must be processed from start to finish by every node on the network. This means if a smart-contract produces a random number, every node will produce a different out-come from the same transaction resulting in each node effectively holding a different slightly altered version of the blockchain. If your not familiar with blockchains...this is a big No-No.

The ChaosMiner solves this problem of random number generation by turning the random entropy of the universe detected by its antenna into use-able random numbers for the ChaosCasino(which uses them to determine the outcome of games like which card is drawn next).

To reward the operation of the ChaosMiner, it has been patented as the first idea on the CryptoPatent Blockchain, meaning it mines a UseBlock containing a small amount of NotioCoin for its owner every time it generates a random number.

Hopefully this all makes since, but if it doesn't...no worries! We have WhitePapers for the projects mentioned above that can be found on our github page here as well as an information section on our website http://decentracorp.now.sh.

Alright, lets get down to business and build a ChaosMiner.

The first thing you will need to do is become a member of DecentraCorp using its beta phase dApp from a desktop using a browser plugin called metamask which can be downloaded here for chrome or firefox. Follow the steps for creating a wallet before continuing.

Once metamask is installed you should see a plug-in icon with a drop down menu that looks like this:

Now you are ready to connect to the DecentraCorp Proof of Authority Network!

click the network select drop down button:

Select Custom RPC at the very bottom:

Enter the Network information as seen here:

Once connected to the PoA node through metamask you can visit https://DecentraCorp.now.sh. There you will find a Profile creation page where you can sign up to become a DecentraCorp Member. A membership comes with 1000 NotioCoin to be used for staking replications like the ChaosMiner (Any Open-Source Idea Can be patented and used to mine NotioCoin!).

Now that you are a member, you will be able to stake some of your test NotioCoin to activate your ChaosMiner replication!

Now for the build steps:

The first step in this build is to strip off one side of each of your three wires, leaving one side with the GPIO connectors intact. Connect the three stripped sides to your antenna reasonably spaced apart. They can be affixed however you like(wrapping the wire, electrical tape or even solder).

If you hold your raspberry pi with the USB ports facing down you will have a GPIO pin layout that matches this diagram:

Connect the other ends of your wires to GPIO4, GPIO17 and GPIO27

Thats it! Where done with the build (easy right?).

In these final steps we will go through setting up the ChaosMiner software on your ChaosMiner.

If you havnt already, install raspbian on the pi following the instructions found here.

At this point you will need a way of communicating with the pi. This can be done by hooking it up to a tv or other monitor using an HDMI cable as well as a mouse and keyboard

OR

via ssh following the instructions here.

Once you are able to communicate with the pi, open a terminal and clone the ChaosMiner repo with the command:

git clone https://github.com/DecentraCorp/ChaosMiner.git

then in a terminal run:

sudo pip3 install RPi.GPIO

then

sudo pip3 install web3

To edit the password file to hold your password:

cd ChaosMiner/Parity_on_pi/sudo nano chaos.pwd

-replace word chaos with a password of your choosing -hit ctrl x , then y, then enter to save the files

once saved run the command:

./parity-arm --config chaos.toml account new

-this will create a new account on the DCPoA and produce a public key -copy this public key

Open up the chaos.toml file and replace the address's in unlock AND engine_signer with the address generated on the pi. Make sure to remove the # in front of both #unlock and #engine_signer

command to edit chaos.toml:

sudo nano chaos.toml

ctrl x to save and y to confirm and you'll find yourself back in the terminal. Run this command to start your node and make sure it connects to the PoA network:

./parity-arm --config chaos.toml

you should see something similar to this:

To Activate this replication run the following commands in another terminal:

chmmod -x Activate.py

then:

./Activate.py

You will be asked to enter the username you input when you created your membership. This script should spit out the nodes account address. if there are no errors you should be able to run the ChaosMiner script.

The ChaosMiner script can be run with these commands in the ChaosMiner directory:

chmmod -x MineChaos.py

chmmod -x MineChaos.py

followed by

./MineChaos.py

If you are doing all this on the raspberry pi and you've done everything right your screen should look something like this(or similar if you ssh'd):

Your replications account address should start appearing in between each random number that is generated.

Congratulations! Your ChaosMiner is now mining NotioCoin and sending random numbers to the ChaosCasino for use in Chaos Games!

You can now check your NotioCoin wallet to make sure you are earning NotioCoin through the DecentraCorp dApp by clicking the tiny figure of a person next to the drop down menu(this will produce a different drop down with the wallet as a selection near the top). You should also notice that your account now only holds 900 or so NotioCoin. This is because the ChaosMiners stake was deducted from your account upon activation.

I would love to say thats it and you are done but unfortunately your ChaosMiner will not continue running forever without a few additional steps(this is actively being worked on however and wont be necessary in the future).

Due to the current necessity to run parity on the pi itself(in the future this wont be the case) we run into a bit of a problem. After running for some time, this arm compatible version of parity has a tendency to crash due to a memory issue. to combat this we have designed additional steps that utilize crontab to periodically restart all of these processes and the pi itself every hour.

These lines will need to be added to crontab on the ChaosMiner in order for it to auto restart

run this command in the home directory:

sudo crontab -e -u root

if prompted choose #2 to edit the crontab file using nano

once open, add the following lines to the bottom of the crontab file:

@reboot sh /home/pi/ChaosMiner/launcher.sh >/home/pi/logs/cronlog 2>&1

@reboot sleep 200; sh /home/pi/ChaosMiner/miner.sh >/home/pi/logs/cronlog2 2>&1

@reboot sleep 3600; sh /home/pi/ChaosMiner/rebooter.sh >/home/pi/logs/cronlog3 2>&1

the first line tell crontab to run launcher.sh and store its logs in logs under the filename cronlog. launcher.sh starts a local parity node

the second line runs miner.sh and starts the ChaosMiner script. The logs of this should appear in logs under the file name cronlog2

the third line reboots the ChaosMiner once every hour to ensure the node doesn't time out for any longer than a minute and a half....this is necessary at the moment as parity has some error where it likes to crash for no reason. Future plans are to utilize external AWS based PoA nodes for a connection though this is still under development.

If you've made it this far and built your own ChaosMiner, or if you are stuck and need help, please consider joining us on our discord channel using the link here or emailing me directly at decentracorp@pm.me! We would be more than happy to help AND have you aboard!