Basic Usage

Running a node

To get started, you must download the binary file from this link.

In order to run CodeChain, run


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

Connecting to the network

You can participate in the Corgi or Main network.

You could get information about Corgi at this link. In order to participate in the Corgi network, you should use the command below:

codechain --chain corgi --no-miner --bootstrap-addresses "" "" "" "" ""

In order to participate in the Main network, you should use the command below:

codechain --no-miner --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({ server: "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({ server: "http://localhost:8080" }); (response) {console.log("Ping response:", response); }).catch(console.error);'

You should receive the following response:

Ping response: pong