Basic Usage

Run Built Executable

To get started, you must first run the built executable of CodeChain.

In order to run CodeChain, run


You can create a block by sending a parcel through JSON-RPC. In order to utilize JSON-RPC, you can use Curl or JavaScript SDK.

Blockchain Configuration

When configuring CodeChain’s blockchain type, you can set it to either Solo or Tendermint.

Solo Configuration

CodeChain uses this configuration as default. In order to change it into another configuration, such as tendermint, run:

--chain tendermint

Tendermint Configuration

In order to properly get Tendermint to get going, you need to have 4 nodes up and running. To do this, first run a single node by running the following:

codechain --db-path db/db0 --port 3485 --jsonrpc-port 8080 --engine-signer 0x84137e7a75043bed32e4458a45da7549a8169b4d -c tendermint

This creates a node in db0 (database 0) at port 3485(used for nodes to communicate with each other) and jsonRPC port 8080(port used for external access) with engine signer of 0x84137e7a75043bed32e4458a45da7549a8169b4d(used to sign the block).

Then create more nodes, and allocate each node with a secret key that corresponds to one of the four public keys listed in Tendermint’s validator property. When creating new nodes, the db, port and jsonRPC port all must be configured as a different value. So for example, the next node should be set up like this:

codechain --db-path db/db1 --port 3486 --jsonrpc-port 8081 --engine-signer 0x9f194cba03ecc7004646414e795957ceca32cd20 -c tendermint

Once each public key has a corresponding node with a corresponding secret key, use the boostrap address command to interlink all the nodes together. The way each node is connected does not matter, as long as each node is connected to another node. For example, in order to make a certain node connect to the node with a secret key of 1, use this command:

codechain --db-path db/db1 --port 3486 --jsonrpc-port 8081 --engine-signer 0xcfd28c1279645febb7cf8802993291ef433a21f3 -c tendermint --bootstrap-addresses

Checking if CodeChain is Configured Properly

JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.

Using Curl

First, check whether CodeChain’s RPC port is listening for RPC connections. By default it should be PORT 8080.

In order to check whether CodeChain is configured properly or not, send a ping to check whether CodeChain’s RPC server is actually responding. To do this, do the following:

curl \
    -H 'Content-Type: application/json' \
    -d '{"jsonrpc": "2.0", "method": "ping", "params": [], "id": null}' \

You should get the following response, or something similar:


Using JavaScript SDK

In order to use this method, first install the sdk by running the following:

npm install codechain-sdk


yarn add codechain-sdk

Then, make sure that your CodeChain RPC server is listening. In the examples, we assume it is localhost:8080

If you run the following code, your should receive a ping response:

// ping.js (javascript)
var SDK = require("codechain-sdk");

var sdk = new SDK("http://localhost:8080"); (response) {
    console.log("Ping response:", response);

If you want to run the above example in the command line, first install nvm by running the following:

wget -qO- | bash

Then run the following:

node -e 'var SDK = require("codechain-sdk"); var sdk = new SDK("http://localhost:8080"); (response) {console.log("Ping response:", response); }).catch(console.error);'

You should receive the following response:

Ping response: pong