Skip to content

Running a private blockchain

hihiben edited this page Jul 31, 2017 · 20 revisions

Running a private blockchain


Remove all the addnode in ~/.gcoin/gcoin.conf . Then move to ~/.gcoin/main directory and remove block and chainstate directory, and all dat file except wallet.dat. This step guarantees Gcoin can be started under a clean state. Finally, execute gcoin daemon again. ./gcoind -daemon -zapwallettxes=2 If you haven't run daemon before, just simply execute ./gcoind -daemon

For Gcoin 1.1

After you start a private chain, use ./gcoin-cli setgenerate true 1 so the mining procedure can begin. Since that Gcoin only mines when there is transaction broadcasted, you need to create transaction to actually mine the first block, ex. mint 1 0

For Gcoin 1.2

After you start a private chain, you should import all key you set in gcoin.conf to initialize the chain.(Please reference https://github.com/OpenNetworking/gcoin-community/wiki to set gcoin.conf and initialize chain. You can replace alliance and miner in gcoin.conf to your own pubkey(must transfer to redeem script) and address).

Getting a License


In order to issue your own token, one must first get a license. Only alliance can issue a license, so if you are joining other Gcoin networks, you should ask alliances for help. Or if you are running your own chain, then for sure you are an alliance. Once you are an alliance, here are the steps to issue a license. First, mint 1 0 or mintforlicense after Gcoin 1.2. (color 0 is saved for administrative use among alliance in Gcoin 1.1) Second, create a license information via RPC encodelicenseinfo, which encodes the license information into a heximal value. The command should looks like

encodelicenseinfo '{"version":1,"name":"Gcoin","description":"testing","i
ssuer":"Gcoin","divisibility":true,"fee_type":"fixed","fee_rate":0.0,"upp
er_limit":0,"fee_collector":"1AjJ6zXAH2jw1azy4Zd7r3fdANLiZjsh83","mint_sc
hedule":"free","member_control":false,"metadata_link":"http://g-coin.org"
,"metadata_hash":"9df8088af07cb269bb9a33478c1a281199c6cd5ab317ff82929201e
d1501f0c1"}'

Finally, send the license to receiver. sendlicensetoaddress one's_address colorID_of_license hexValue. It will look something like

sendlicensetoaddress 16tKEmMzBejBKeEixC4zWCdXnzoWxWVZnG 3333 721101000477
696c6c047465737422314b5534337a3464454375644b546e4742705566714737454669736
971394544426f0100000000000000000000000022314b5534337a3464454375644b546e47
42705566714737454669736971394544426f0000000000000000000000000009687970657
26c696e6b0000000000000000000000000000000000000000000000000000000000000000

Note that colorID_of_license is alliance's choice, it is irrelevant of the license_info. You can view a license by getlicenseinfo colorID_of_license or getlicenselist to see all license you own.

Note that issuing license is protected by multi-sig mechanism after Gcoin 1.2. So you should use signrawtransaction to complete all needed signature of this transaction by each alliance and use sendrawtransaction to broadcast completed transaction.

Alliance


There are two jobs of an alliance:

  1. Issue licenses
  2. Mining (Not available after 1.2)

getmemberlist to view alliances in the network

For Gcoin 1.1

The node who mines the first block will be the first member of alliance. Member of the alliance can vote to elect new member to join in the alliance. sendvotetoaddress to vote a new alliance. It will take more than 67% of the members' approval to elect a new member as default. Note that the address you send to must be a fixed address.

For Gcoin 1.2

The initial alliance must be defined in the configuration file. Member of the alliance can vote to elect new member to join in the alliance. addalliance to vote a new alliance. This vote process is implemented by multi-sig mechanism. Therefore, you should use signrawtransaction to complete all the needed signature of this transaction by each alliance, then use sendrawtransaction to broadcast completed transaction to finish this round of vote. It will take more than 67% of the members' approval to elect a new alliance member as default. Note that the pubkey you send to must be a valid pubkey.

Miner (After 1.2)


Mining function is separated from alliance member's authority after 1.2. The initial miner must be defined in the configuration file. Member of the alliance can vote to elect new miner. mintforminer to mint a voting token. addminer to add a new miner. This vote process is implemented by multi-sig mechanism. Therefore, you should use signrawtransaction to complete all the needed signature of this transaction by each alliance, then use sendrawtransaction to broadcast completed transaction to finish this round of vote. It will take more than 67% of the members' approval to add a new miner as default. Note that the pubkey you send to must be a valid pubkey.