• Stars
    star
    258
  • Rank 158,189 (Top 4 %)
  • Language
    Rust
  • License
    GNU Affero Genera...
  • Created almost 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CodeChain's official implementation in Rust.

CodeChain Build Status Gitter: CodeChain License: AGPL v3

CodeChain is a programmable open source blockchain technology optimal for developing and customizing multi-asset management systems.

Build

Download CodeChain code

git clone [email protected]:CodeChain-io/codechain.git
cd codechain

Build in release mode

cargo build --release

This will produce an executable in the ./target/release directory.

Setup

Using Docker

CodeChain supports the use of Docker to provide an easy and seamless installation process by providing a single package that gives the user everything he/she needs to get CodeChain up and running. In order to get the installation package, run the following command after installing Docker:

docker build -f docker/ubuntu/Dockerfile --tag kodebox/codechain:branch_or_tag_name .

WSL users may find difficulty in using Docker, and thus, it is highly recommended to use Ubuntu, or install Docker for Windows. When using Docker for Windows, it is necessary to enable Hyper-V in BIOS settings.

To see the Docker images created, run the following:

docker images

It will result in something like this:

REPOSITORY               TAG                  IMAGE ID            CREATED              SIZE
kodebox/codechain        branch_or_tag_name   6f8474d9bc7a        About a minute ago   1.85GB
ubuntu                   14.04                971bb384a50a        6 days ago           188MB

If you want to run the first image file, run the following command:

docker run -it kodebox/codechain:branch_or_tag_name

This should result in CodeChain running.

Making local database and keys persistent

CodeChain depends on the local database and keys commonly stored under the directories keys and db. A Docker container is independent of host environment and other Docker images. Therefore, when running a new Docker container with an image with a new CodeChain version or even with the same image, the database and keys are not persistent. To solve the problem, one can take advantage of the Docker's volume option. With the command below,

docker run -it -v codechain-db-vol:/app/codechain/db -v codechain-keys-vol:/app/codechain/keys kodebox/codechain:branch_or_tag_name

one can mount the volume codechain-db-vol into /app/db and the volume codechain-keys-vol into /app/keys in the container. This command will automatically create volumes if existing volumes with specified names do not exist. Because the default working directory specified in Dockerfile is /app/codechain, the default db and keys path are /app/codechain/db and app/codechian/keys. One can also customize the paths with CodeChain cli arguments base-path, key-path and db-path.

docker run -it -v codechain-db-vol:custom_base_path/db -v codechain-keys-vol:custom_base_path/keys kodebox/codechain:branch_or_tag_name --base-path custom_base_path
docker run -it -v codechain-db-vol:custom_db_path -v codechain-keys-vol:custom_keys_path kodebox/codechain:branch_or_tag_name --db-path custom_db_path --keys-path custom_keys_path

With the methods above, node organizers can manage their local persistent data using docker images.

Building From Source

Build Dependencies

CodeChain requires Rust version 1.40.0 to build. Using rustup is recommended.

  • For Linux Systems:

    • Ubuntu

      cmake, gcc, g++ and make are required for installing packages.

      $ curl https://sh.rustup.rs -sSf | sh
  • For Mac Systems:

    • MacOS 10.13.2 (17C88) tested

      cmake and clang are required for installing packages.

      $ curl https://sh.rustup.rs -sSf | sh
  • For Windows Systems:

    • Currently not supported for Windows. If on a Windows system, please install WSL to continue as Ubuntu.

Please make sure that all of the binaries above are included in your PATH. These conditions must be fulfilled before building CodeChain from source.

Download CodeChain's source code and go into its directory.

git clone [email protected]:CodeChain-io/codechain.git
cd codechain

Build as Release Version

cargo build --release

This will produce an executable in the ./target/release directory.

Using CodeChain SDK

Before starting to use the CodeChain SDK, please install node.js by going to this page.

Next, install the package with the following command:

npm install codechain-sdk or yarn add codechain-sdk

Run

To run CodeChain, just run

./target/release/codechain -c solo

You can create a block by sending a transaction through JSON-RPC or JavaScript SDK.

Formatting

Make sure you run rustfmt before creating a PR to the repo. You need to install the nightly-2019-12-19 version of rustfmt.

rustup toolchain install nightly-2019-12-19
rustup component add rustfmt --toolchain nightly-2019-12-19

To run rustfmt,

cargo +nightly-2019-12-19 fmt

Linting

You should run clippy also. This is a lint tool for rust. It suggests more efficient/readable code. You can see the clippy document for more information. You need to install the nightly-2019-12-19 version of clippy.

Install

rustup toolchain install nightly-2019-12-19
rustup component add clippy --toolchain nightly-2019-12-19

Run

cargo +nightly-2019-12-19 clippy --all --all-targets

Testing

Developers are strongly encouraged to write unit tests for new code, and to submit new unit tests for old code. Unit tests can be compiled and run with: cargo test --all. For more details, please reference Unit Tests.

License

CodeChain is licensed under the AGPL License - see the LICENSE file for details

More Repositories

1

codechain-explorer

Block Explorer for CodeChain
TypeScript
49
star
2

intertrait

A library providing direct casting among trait objects implemented by a type
Rust
39
star
3

foundry

A programmable open source blockchain engine
Rust
38
star
4

codechain-dashboard

CodeChain network management and monitoring tool
Rust
26
star
5

codechain-sdk-js

CodeChain JavaScript SDK
TypeScript
26
star
6

codechain-indexer

A blockchain data indexing tool for CodeChain
TypeScript
21
star
7

codechain-web-wallet

CodeChain Web Wallet
TypeScript
20
star
8

rust-cuckoo

A memory-bound graph-theoretic proof-of-work system written in Rust
Rust
18
star
9

codechain-exchange

A decentralized exchange platform for CodeChain
TypeScript
17
star
10

rust-iblt

Invertible bloom lookup table implementation in Rust
Rust
16
star
11

codechain-faucet

CodeChain testnet faucet
JavaScript
15
star
12

codechain-keystore-cli

A command line key management tool for CodeChain
JavaScript
15
star
13

codechain-miner

Mining worker for PoW algorithms in CodeChain.
Rust
15
star
14

codechain-cuckoo-miner

The CodeChain CPU miner for cuckoo hashing
Rust
15
star
15

remote-trait-object

A simple and powerful Rust remote method invocation library based on trait objects
Rust
14
star
16

rust-codechain-crypto

The crypto library used by CodeChain.
Rust
14
star
17

rust-merkle-trie

Merkle trie for CodeChain
Rust
14
star
18

codechain-keystore-js

A private key management library for CodeChain
TypeScript
14
star
19

codechain-helicopter

An airdrop tool for CodeChain
TypeScript
13
star
20

rust-codechain-primitives

Primitive types used by CodeChain.
Rust
13
star
21

rust-codechain-db

Databases that CodeChain uses
Rust
13
star
22

codechain-test-helper-js

CodeChain test helper library for JavaScript
TypeScript
12
star
23

codechain-keystore-server

A private key management server for CodeChain
TypeScript
12
star
24

codechain-blake-miner

The CodeChain miner for blake_pow
Rust
12
star
25

codechain-proxy

An RPC proxy server for CodeChain
Python
12
star
26

codechain-agent-server

CodeChain management and monitoring tool
Rust
11
star
27

proof-of-ownership-demo

Proof of Ownership Demo
TypeScript
11
star
28

codechain-primitives-js

JavaScript functions and classes for CodeChain primitives
TypeScript
11
star
29

codechain-agent-client

CodeChain monitoring tool
Rust
11
star
30

codechain-indexer-types-js

CodeChain elastic search
TypeScript
9
star
31

codechain-cuckoo-cuda-miner

The CodeChain CUDA miner for cuckoo hashing
8
star
32

codechain-stakeholder-sdk-js

A JavaScript implementation for CodeChain stake token related custom actions and custom transactions
TypeScript
7
star
33

codechain-sdk-python

Python Software Development Kit for CodeChain
Python
6
star
34

codechain-config-generator

CodeChain Config Generator
JavaScript
6
star
35

rlp-debugger

A static web page to debug RLP encoded bytes
TypeScript
6
star
36

foundry-rpc-js

A thin wrapper of Foundry RPC
TypeScript
5
star
37

codechain-sdk-go

Go Software Development Kit for CodeChain
Go
5
star
38

rust-token-generator

A token generator.
Rust
5
star
39

module-rt

A runtime for a Foundry application module written in Rust
Rust
4
star
40

cron-jobs

Cron jobs using CodeChain network
TypeScript
4
star
41

codechain-rpc-js

A thin wrapper of CodeChain RPC
TypeScript
4
star
42

rust-multimap

Multimap
Rust
4
star
43

jsonrpc-filter

A proxy server that allows the only subsets of the RPCs
Rust
4
star
44

rust-finally-block

Final block that is executed at the last
Rust
4
star
45

rust-limited-table

Size limited table.
Rust
4
star
46

lowdb-session-storage-adapter

JavaScript
4
star
47

codechain-docs

CodeChain Documentation
4
star
48

foundry-sandbox

Sandbox implementation for the module of Foundry
Rust
3
star
49

codechain-change-common-params

A static web page to create a CodeChains "ChangeCommonParams" transaction
TypeScript
3
star
50

foundry-primitives-js

Primitive types used by Foundry
TypeScript
3
star
51

rust-never-type

This library is an alternative implementation of never type for stable rust.
Rust
3
star
52

foundry-keystore-cli

A command line key management tool for Foundry
JavaScript
2
star
53

foundry-keystore-js

A private key management library for Foundry
TypeScript
2
star
54

trie-standardmap

Standard test map for profiling merkle tries
Rust
2
star
55

codechain-rpc-python

1
star
56

codechain-crypto-python

1
star
57

codechain-sdk-java

CodeChain Java SDK
1
star