Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
181 lines (129 sloc) 7.48 KB Chain Chain

Build Status codecov Gitter

This repository contains the pre-alpha version prototype implementation of Chain. The current repository consists of the following Rust sub-crates:

  • chain-abci: the Tendermint ABCI application that currently does the transaction validation etc.

  • chain-core: the library that contains the main type definitions and any utility code (such as serialization), so that it can be used in chain-abci and other applications.

  • dev-utils: currently a minimal development tool for generating genesis.json

  • signer-[cli|core|rpc]: work-in-progress infrastructure for client code, such as wallet implementations and third party integrations.

  • client-[common|index|core|rpc]: Client backend implementation for transaction creation and wallet management. Follow these links for more details:


Please abide by the Code of Conduct in all interactions, and the contributing guidelines when submitting code.


Apache 2.0



Rust tooling (cargo + cmake):

(TODO: In the future, the build tooling may be migrated to Bazel / Nix etc. for reproducible builds.)

How to build it

Before building, add the following lines to ~/.cargo/config

rustflags = ["-Ctarget-feature=+aes,+ssse3"]

Then build the executables

$ cargo build

The built executables will be put inside folder /target/debug/ by default.

How to run the test suite

$ cargo test

To measure code coverage, one can run

$ cargo tarpaulin

This only works on x86_64 processors running Linux. On different platforms,

$ docker run --security-opt seccomp=unconfined -v "$PWD:/volume" xd009642/tarpaulin

How to run a full node

  1. generate address -- currently, there is a signer cli for this purpose (TODO / NOTE: signer-cli is going to be deprecated in favor of client-client )
$ signer-cli -- address generate --name <NAME>

This command will create an address with name . After entering the passphase, the address is generated.

$ signer-cli -- address get -n <NAME>

Enter passphrase:
Spend address: <ETH_ADDRESS_HEX_BYTES>
  1. generate initial state -- currently, a very naive way is in dev-utils. The chain_id will be used in Tendermint configuration later. At this point, just use two hex digits.

2a. prepare a "mapping" / snapshot file (each line contains the address and the amount):


Note that the sum of amounts needs to equal to the total supply in base units.

2b. run the dev-utils command:

$ dev-utils -- genesis generate --base_fee <x.xxxx> --chain-id <CHAIN_ID> --launch_incentive_from <SOME_ETH_ADDRESS_HEX_BYTES> --launch_incentive_to <SOME_ETH_ADDRESS_HEX_BYTES> --long_term_incentive <SOME_ETH_ADDRESS_HEX_BYTES> --mapping_file_path <PATH_TO_MAPPING_FILE> --per_byte_fee <x.xxxx>

Note that launch_incentive_from, launch_incentive_to and long_term_incentive need to be present in the mapping file (their amounts will be put in the initial rewards pool).

In the end, you should get two pieces of data:

"app_hash": "<APP_HASH_HEX_BYTES>",
"app_state": {"distribution":{"0x<ETH_ADDRESS_HEX_BYTES_1>":<AMOUNT_1>,...},"launch_incentive_from":"<SOME_ETH_ADDRESS_HEX_BYTES>","launch_incentive_to":"<SOME_ETH_ADDRESS_HEX_BYTES>","long_term_incentive":"<SOME_ETH_ADDRESS_HEX_BYTES>","initial_fee_policy":{"constant":xxxx,"coefficient":xxxx}}

"app_hash" is the initial application hash -- currently, it's computed as a hash of the initial rewards pool state and a root of a merkle tree of initial transaction IDs.

  1. initialize a Tendermint node:
$ tendermint init

If you previously initialized a Tendermint node, you may need to run before it:

$ tendermint unsafe_reset_all
  1. configure a Tendermint node:

One thing to change would be the change genesis.json to have app_hash and app_state obtained in step 1. Also, make sure reusing the chain_id we come up earlier, which should ends with two hex digits (e.g. test-chain-mafL4t-AA).

  1. run CRO ABCI process, e.g.:
$ chain-abci -g "<APP_HASH_HEX_BYTES>" -c <FULL_CHAIN_ID>

The string passed to -g is the genesis app_hash obtained in step 1 and configured in the previous step. The string passed to -c is the full_chain_id that ends with two hex digits (e.g. test-chain-mafL4t-AA).

If you need backtraces or logging, set the environment variables before it:

  1. run a Tendermint process: in a different terminal:
$ tendermint node

How to run a basic lite node

$ tendermint lite

How to send TX, query, etc.

See Tendermint RPC documentation:

Currently, there's a rough command-line application in signer/app for testing purposes.

Its workflow is the following:

  1. Generate a new keypair: signer address generate -n <NAME> (you can view hex-encoded addresses of corresponding key with signer address get -n <NAME>)

  2. Generate a signed TX with:

$ signer-cli transaction generate -n <NAME> -c <CHAIN_ID>

Right now there is no concept of fee, you must spend the whole input in the output(s).

After entering all the required data, this will print out a hex-encoded TXID (blake2s hash) and a hex-encoded SCALE-serialized TX structure / content. You can decode it and transform it as necessary, e.g. into base64.

  1. You can then send a TX using the broadcast_tx Tendermint RPC command (e.g. JSONRPC over HTTP or websockets). For example, for the URI/HTTP option, it can look like this:

Useful links

You can’t perform that action at this time.