CX Chain is a fork of Skycoin with the ability to run application-specific blockchains with smart-contracts written with CX.
Each CX Chain is identified by a genesis hash, which in turn reference a CX Chain Spec. The CX Chain Spec specifies the properties and genesis block of the specific CX Chain.
CX Chain requires Golang to compile (version 1.14+
). Detailed installation instructions can be found here: https://github.com/SkycoinProject/skycoin/blob/develop/INSTALLATION.md
To build cxchain
, the typical Golang binary build process applies. The following command builds cxchain
and cxchain-cli
into the target directory specified by the GOBIN
env.
$ git clone git@github.com:skycoin/cx-chains.git && cd cx-chains
$ go install ./cmd/...
The go install
command is also available as a Makefile
target.
$ make install
You will need to specify an address of a cx-tracker
for a cxchain
instance to function properly. A local cx-tracker
instance can be installed via this repository.
This local environment has two cxchain
instances and a cx-tracker
.
Start cx-tracker
.
$ cx-tracker -addr ":9091"
Generate new chain spec (assuming that the repository root is your working directory).
$ cxchain-cli new ./cx/examples/counter-bc.cx
Post chain spec to cx-tracker
.
$ export CXCHAIN_SK=$(cxchain-cli key -in skycoin.chain_keys.json -field "seckey")
$ cxchain-cli post -t "http://127.0.0.1:9091" -s skycoin.chain_spec.json
At this point, you can head to http://127.0.0.1:9091/api/specs to see whether the spec is posted to cx-tracker
.
Run publisher node with generated chain spec.
{coin}.chain_keys.json
file.
$ export CXCHAIN_SK=$(cxchain-cli key -in skycoin.chain_keys.json -field "seckey")
$ export CXCHAIN_HASH=$(cxchain-cli genesis -in skycoin.chain_spec.json)
$ cxchain -chain "tracker:$CXCHAIN_HASH" -tracker "http://127.0.0.1:9091" -enable-all-api-sets -data-dir ./master_node -port 6001 -web-interface-port 6421
Run client node with generated chain spec (use different data dir, and ports to publisher node).
CXCHAIN_SK
is provided, a random key pair is generated for the node.
$ export CXCHAIN_HASH=$(cxchain-cli genesis -in skycoin.chain_spec.json)
$ cxchain -chain "tracker:$CXCHAIN_HASH" -tracker "http://127.0.0.1:9091" -client -enable-all-api-sets -data-dir ./client_node -port 6002 -web-interface-port 6422
Run transaction against publisher node.
$ export CXCHAIN_HASH=$(cxchain-cli genesis -in skycoin.chain_spec.json)
$ cxchain-cli run -chain "tracker:$CXCHAIN_HASH" -tracker "http://127.0.0.1:9091" ./cx/examples/counter-tx.cx
Run transaction against client node and inject.
$ export CXCHAIN_GEN_SK=$(cxchain-cli key -in skycoin.genesis_keys.json -field "seckey")
$ export CXCHAIN_HASH=$(cxchain-cli genesis -in skycoin.chain_spec.json)
$ cxchain-cli run -chain "tracker:$CXCHAIN_HASH" -tracker "http://127.0.0.1:9091" -node "http://127.0.0.1:6422" -inject ./cx/examples/counter-tx.cx