Creditcoin Miner's Manual

This guide will walk you through connecting to the Creditcoin blockchain and running your own Server and Client.

Prerequisites

Before connecting to the Creditcoin blockchain, you will need to set up the following:

  • An Ethereum private key

  • An Ethereum RPC mainnet node

  • A 256 bit SECP256K1 ECDSA private key

  • Docker Desktop

Get an Ethereum public address and private key

This section is for new Ethereum users who need to create a wallet. We recommend creating a wallet using MyEtherWallet (MEW), which is a free, open-source, client-side interface for generating Ethereum wallets & other functionality.

MEW offers two ways of creating an Ethereum wallet:

  • Using Keystore/JSON

  • Using a Mnemonic Phrase

Instructions for setting any of those up can be found here.

Once you know which method you want to use to create your wallet, click here. Upon logging in, you will be presented with a pop-up window with various addresses.

Choose an address by clicking on it and then check the box below to accept the terms and press 'Access My Wallet'

To find your private Ethereum key, click the 'print' icon on the top left of the screen. In the new window, you will be able to see your private key.

Set up an Ethereum RPC mainnet node

This section will cover how to set up an Ethereum RPC mainnet node using infura.io Alternatively, you can set up your own private RPC mainnet node.

  1. Go onto infura.io, create a new account and confirm your email address.

  2. In your infura account dashboard page, click on 'Create New Project' and name it accordingly.

  3. Click on 'View Project' and you will have access to your mainnet node (aka Endpoint).

Get a 256 bit SECP256K1 ECDSA key

You can use this ECDSA sample generator:

  • Click on 'generate EC pair'

  • Use the generated 'EC private key'

Configure Docker Desktop

Running a container launches your software with private resources, securely isolated from the rest of your machine.

  1. Create a Docker account and confirm your email address.

  2. Download Docker Desktop and install it.

  3. Once docker is installed, log in using your newly created account.

  4. Click on the Docker icon in your task bar and select 'Settings'

  5. Under the 'Shared Drives' tab, make sure you have the drive where the Creditcoin containers will be running

Creditcoin files configuration

To configure the Creditcoin files, you will need the following:

  • An Ethereum private key

  • Your Ethereum RPC mainnet node

  • A 256 bit SECP256K1 ECDSA key

Firstly, download the Creditcoin files. Afterwards, extract the files in a directory of your choice. You will need to configure the following:

  • Client > clientConfig.json

  • Server > gatewayConfig.json

  • Server > creditcoin-with-gateway.yaml

You can edit those files by opening them with your preferred text editor.

Client/clientConfig.json

{
"signer": "<256_bit_key_secp256k1_ECDSA>",
"creditcoinRestApiURL": "",
"bitcoin": {
"secret": "<bitcoin_private_key>",
"rpc": "<bitcoin_rpc_node_url>",
"credential": "<rpc_username:rpc_password>",
"fee": "10000"
},
"ethereum": {
"creditcoinContract": "0xa3ee21c306a700e682abcdfe9baa6a08f3820419",
"creditcoinContractAbi": "<creditcoinContractAbi",
"rpc": "<ethereum_node_url>",
"secret": "<ethereum_private_key_no_0x>",
"gasPriceInGwei": "<set_to_override_gas_price>"
}
}

You need to edit the following elements:

  • signer: Your 256 bit SECP256K1 ECDSA key

  • ethereum:

    • rpc: RPC mainnet node (e.g. https://mainnet.infura.io/v3/xxxxxxxxxxxx) or your own personal mainnet node (e.g. http://localhost:8545 )

    • secret: Your ethereum private key without the 0x prefix

You can use the Bitcoin section to loan/fundraise Bitcoin. Otherwise, you can leave it blank.

Server/gatewayConfig.json

{
"bindIP": "0.0.0.0",
"bitcoin": {
"rpc": "<bitcoin_rpc_node_url>",
"credential": "<rpc_username:rpc_password>"
},
"ethereum": {
"creditcoinContract": "0xa3ee21c306a700e682abcdfe9baa6a08f3820419",
"creditcoinContractAbi": <creditcoinContractAbi>,
"rpc": "<ethereum_node_url>"
}
}

You need to edit the following element:

  • rpc: RPC mainnet node (e.g. https://mainnet.infura.io/v3/xxxxxxxxxxxx) or your own personal mainnet node (e.g. http://localhost:8545 )

Server/creditcoin-with-gateway.yaml

--endpoint tcp://<insert.your.ip>:8800 \`

Replace <insert.your.ip> on lines 51 and 61 with your IP address. Do not include the < > signs.

Connecting to the Creditcoin Blockchain

Now that you've got Docker Desktop installed and you've updated your Creditcoin configuration files, you're ready to start the Docker containers and get connected to the Creditcoin Blockchain!

Opening Command Prompt on Windows

  1. Open a PowerShell by right-clicking the icon and pressing 'Run as administrator'.

  2. Change the directory to the folder containing the Creditcoin documentation.

Set-location "C:/My Folder"

Opening Command Prompt on MAC

  1. Open Terminal by pressing cmd + spacebar and searching for 'Terminal'.

  2. Change the directory to the folder containing the Creditcoin documentation.

cd ~/Documents

Start the Creditcoin Client

  1. Run the command:

    docker-compose -f Client/creditcoin-client.yaml up -d

Get your Client sighash

Make sure the client is running before executing the below commands.

  1. Access the Creditcoin Client bash using this command: docker exec -it creditcoin-client bash

  2. Get your client sighash by typing ./ccclient sighash into the Creditcoin Client bash

Stop the Creditcoin Client

Run the command:

docker-compose -f Client/creditcoin-client.yaml down

Start the Creditcoin Server

Run the command:

docker-compose -f Server/creditcoin-with-gateway.yaml up

Upon running the above command, the blockchain will start downloading and messages such as the following will be displayed:

sawtooth-validator | [2020-01-01 11:22:33.444 DEBUG permission_verifier] Chain head is not set yet. Permit all.
sawtooth-validator | [2020-01-01 11:22:33.444 DEBUG completer] Request missing predecessor

Stop the Creditcoin server

Run the command:

docker-compose -f Server/creditcoin-with-gateway.yaml down

Get your miner sighash and balance:

You will firstly need to get your miner key and edit the clientConfig.json file in order to retrieve your miner balance and sighash.

Get your miner key

  1. Run the Server

  2. While the shell window is populated with messages, open a new instance of the command prompt / terminal

  3. In the new command prompt window, get the validator private key by running the following command:

    docker exec sawtooth-validator-default cat /etc/sawtooth/keys/validator.priv

  4. Copy the outputted key of the above

  5. Open the Client/clientConfig.json file

  6. Paste the copied key into the signer value

  7. Set the creditcoinRestApiURL as follows:

creditcoinRestApiURL: ''

Retrieve your miner sighash and balance

  1. Start the Creditcoin client:

    docker-compose -f Client/creditcoin-client.yaml up -d

  2. Access the Creditcoin Client bash by running the following command: docker exec -it creditcoin-client bash

  3. Get your sighash by running the following command: ./ccclient sighash

  4. Check your balance by running the following command: ./ccclient show Balance 0

Check your balance on the Creditcoin Explorer website

You can check your miner balance by following the link below and replacing the {insert_sighash} with your miner sighash. This is useful for checking your balance without having to run any Docker containers or start the Creditcoin client.

https://www.creditcoinexplorer.com/address-detail?address={sighash_here}

If upon running command to check your balance you are getting error 404, then the address has not mined any blocks yet and there are no records in the blockchain API relating to that address.

Block successfully mined

Upon successfully mining a block, the following message will be displayed:

sawtooth-validator | [2020-01-01 12:34:56.789 INFO publisher] Claimed Block: [block id] (block_num:[block number], state:[state id], previous_block_id:[previous block id])

Troubleshooting

Recovering from an incorrectly formatted command

From time-to-time, the Creditcoin client may get ‘stuck’ on an improperly formatted command line. To recover from this run the command rm plugins/progress.txt, then retype the command correctly.

The purpose of progress.txt is to rerun an interrupted command. For example while waiting for sufficient confirmation on Ethereum network, a user can stop the Creditcoin Client, then later run the Creditcoin Client command (./ccclient) again without parameters. Here we're removing the invalid command to prevent it from automatically rerunning.