Compile and Run Node

Building Executables

Switch to the bytom repository root directory.

$ cd $GOPATH/src/
$ make bytomd    # build bytomd
$ make bytomcli  # build bytomcli

When successfully building the project, the bytom and bytomcli binary should be present in cmd/bytomd and cmd/bytomcli directory, respectively.


First of all, initialize the node:

$ cd ./cmd/bytomd
$ ./bytomd init --chain_id testnet

There are two options for the flag --chain_id:

  • testnet: connect to the testnet.
  • mainnet: standalone mode.

After that, you'll see .bytomd generated in current directory, then launch the node.


$ ./bytomd node --mining

available flags for bytomd node:

      --auth.disable                Disable rpc access authenticate
      --mining                      Enable mining
      --p2p.dial_timeout int        Set dial timeout (default 3)
      --p2p.handshake_timeout int   Set handshake timeout (default 30)
      --p2p.laddr string            Node listen address.
      --p2p.max_num_peers int       Set max num peers (default 50)
      --p2p.pex                     Enable Peer-Exchange
      --p2p.seeds string            Comma delimited host:port seed nodes
      --p2p.skip_upnp               Skip UPNP configuration
      --prof_laddr string           Use http to profile bytomd programs
      --wallet.disable              Disable wallet
      --web.closed                  Lanch web browser or not

Given the bytomd node is running, the general workflow is as follows:

  • create key, then you can create account and asset.
  • send transaction, i.e., build, sign and submit transaction.
  • query all kinds of information, let's say, avaliable key, account, key, balances, transactions, etc.


Testing one library:

go test -v ./account 

Using options -v (logging even if no error) is recommended.

Testing only some methods:

go test -v ./account -run TestCreateAccount

Note: here all tests with prefix TestMethod will be run, so if you got TestMethod, TestMethod1, then both!

Running benchmarks, eg.:
switch to test directory.

cd $GOPATH/src/
go test -v -bench=. -benchtime=3s -run=none

Using options -bench to specify test directory, and -benchtime to specify the test time.

for more see go test flags