Search

Build Your Own Chaosminer!

Made by Stan36

About the project

The Chaos Miner is a raspberry pi powered radio receiver that converts the entropy of the universe into use-able random numbers for the ChaosCasino! The ChaosMiner earns .5 NotioCoin for its owner when a random number is generated! The ChaosCasino is a blockchain powered Casino dApp operated by DecentraCorp.

Project info

Difficulty:

Platforms:

Estimated time:

1 hour

Published:

23rd March 2019

Items used in this project


Hardware components

Raspberry Pi 3 Model B

any full sized model should work, pi zero support coming soon

x 1
GPIO compatible wires

this can be any type of wire as long as one end can connect to the pi's GPIO pins

x 3
Micro SD Phison industrial card 4Gb

min 4Gb

x 1
metal antenna

this can be anything metal from a coat hanger to a tent stake or even the copper in a breadboard

x 1

Software app and online services

raspbian OS

This should work on just about any OS for the pi but has only been tested on raspbian

web3.py

used by the ChaosMiner scripts to communicate with the blockchain

python3

ChaosMiner scripts are written in python3

Story


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.

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 set up a local node and connect to the DecentraCorp Proof of Authority Network!

Steps to run a parity node on the DecentraCorp PoA network: (Instructions are for Linux, steps should be similiar on windows/OSX and steps for installing parody on those platforms can be found here, all other steps are the same).

install parity with this command:

bash <(curl https://get.parity.io -L) -r stable

open a terminal and clone the DecentraCorpPoA repo wherever you would like it:

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

go do the new directory:

cd DecentraCorpPoA

edit password file to hold your password:

sudo nano pass.pwd

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

once saved run the command:

parity --config config.toml account new

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

the address is the long hash starting with 0x94 in the above picture 

open up the config.toml file and replace the address's in unlock AND engine_signer with your address. make sure to remove the # infront of both #unlock and #engine_signer. 

run the command:

parity --config config.toml

You should see see the node begin to sync and download the PoA Blockchain.

From here, you can open up metamask and connect to localhost:8545 by clicking the drop-down at the top in metamask that currently says Main Ethereum Network next to a green dot

Once connected to the PoA node through metamask you can visit https://DecentraCorp.now.sh. In the drop down menu at the top select "become a member". A membership can be obtained by creating and submitting a profile on this page. A membership comes with 1000 NotioCoin to be used for staking replication like the ChaosMiner.

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 cinfimr and youll 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:

ctrl c to exit paridy

The ChaosMiner script can be run on a raspberry pi by running this command in the ChaosMiner directory:

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 ChaosMiner is now producing random numbers from the Entropy of the Universe! Now lets do something with em.

The final step in this process is for you to stake your newly built Chaosminer so it can mine.

back on your desktop,  make sure your metamask is still connected to the PoA network through localhost:8545 and navigate to the DecentraCorp dApp(or reload the page if you are still on it). As a member you will see a very different set of menu from non members. Navigate to the CryptoPatent Blockchain 

as seen here:

 

This will bring you to a page showing the Original ChaosMiner and its associated Information. Click the button at the bottom labeled "click here to view this idea".

This will bring you to the information page for the ChaosMiner. Scroll to the bottom and click the "Replicate this Idea" 

Enter the address produced on the pi into the provided  text field and click "Activate Replication". 

Once activated, the pi's screen(or your ssh terminal) should look something like this:

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).

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!

Schematics


Code


This repository is in an early beta phase and is under constant updates

This repo is still in its beta phase and subject to frequent updates

Credits


Stan36

I am the founder of DecentraCorp and inventor of the CryptoPatent Blockchain. I am a full time stay at home father and owner of a small electronics repair business known as DC Genesis.


Leave your feedback...