Creating private test networks

This guide will walk you through the process of setting up your own private network using Symbol.

To run the network, we are going to use the package Symbol Bootstrap. To better understand how this package works it is recommended to read the Using Symbol Bootstrap guide.

The bootstrap preset

Symbol Bootstrap has a preset called bootstrap which instantiates a network with multiple nodes with the following architecture:

../../_images/four-layer-architecture1.png

Bootstrap network architecture

The nodes labelled “Internal” are the ones created by Symbol Bootstrap, and are accessible through the REST API:

  • peer-node (1 and 2): Peer nodes verify transactions once the API pushes them into the P2P network. They run the consensus algorithm, create new blocks, and propagate the changes through the network.
  • api-node: The API node stores data in the MongoDB database once transactions are validated. They also identify and store partial aggregate bonded transactions.
  • rest-gateway: Combines HTTP and WebSockets to perform read and write actions on the blockchain.

Instantiate the network

Use the start command (explained in the Using Symbol Bootstrap guide) using the bootstrap preset:

symbol-bootstrap start -p bootstrap

With a single command the network is created and booted. Now check that it is up and running by opening a new browser tab and going to:

localhost:3000/chain/info

You should get a response from the API node.

Retrieving the node accounts

Symbol Bootstrap has created multiple nodes with corresponding accounts. To interact with any of these accounts (to transfer mosaics to it, for example) you need its address or its public key. To fully control an account (to transfer mosaics from it, for example) you need its private key.

All this information can be retrieved from a YAML file in the target folder:

target/addresses.yml

As an example:

networkType: 152
nemesisGenerationHashSeed: 7BFC536990108CA923B2715DE6B8E47E6BB56C945293BF4FC22C5AF895F61E62
nodes:
    -
        signing:
            # Keys for the account of the peer-node-0
            privateKey: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
            publicKey: C2BD21E4F9261247A4CBE75DA8683978E0F1FFF34AAB17BEBC21E7B9E0E17A9F
            address: TAMEGYVY6GVGXCLBIEH72XU4D2OSTH2MIOOY4QQ
        vrf:
            privateKey: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
            publicKey: D67601AC6767F8A3C97FFDB0D9D737A943FFFA6E69C2C6527B0ED32A4E41B443
            address: TCR6ZWX3UP3TKJK3BSE6ARJ4WAF3KHFFUWJ7EWI
        voting:
            privateKey: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
            publicKey: 921ED0839EA3C8590CA1D6562DDD3BFEDA44CCE05DD82DF8C79DED2A3F816A1B
            address: TA77BJJJMRXR2OLJKZNUFTRMLHLQ4T2PPHZRX5I
        ssl:
            privateKey: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
            publicKey: 3d68cdaa4e48a14bd875d4ca18e044522be5f602e8c4f37c1c65eafdfaa19110
        type: peer-node
        name: peer-node-0
        friendlyName: peer-node-0

Note

Keep you Secret Keys secret at all times!

You can now import any of these accounts using the symbol-cli command-line tool for ease of access (Read the symbol-cli guide for more details):

symbol-cli profile import --private-key <PRIVATE_KEY> --network TEST_NET --url http://localhost:3000

After giving this new profile a name you will be ready to use it, for example, to retrieve the account’s balance:

symbol-cli account info --profile <PROFILE_NAME>

You should see that the nodes that Symbol Bootstrap has created for you already contain some currency (in different mosaics) to start experimenting with them:

Balance Information
┌──────────────────┬──────────────────┬──────────────────┬───────────────────┐
│ Mosaic Id        │ Relative Amount  │ Absolute Amount  │ Expiration Height │
├──────────────────┼──────────────────┼──────────────────┼───────────────────┤
│ 3ECBB73A05A147BC │ 1,124,874,999.75 │ 1124874999750000 │ Never             │
├──────────────────┼──────────────────┼──────────────────┼───────────────────┤
│ 2B19203C86F9A668 │ 3,000            │ 3000000          │ Never             │
└──────────────────┴──────────────────┴──────────────────┴───────────────────┘

Retrieving the test accounts

Symbol Bootstrap has also created several test accounts preloaded with mosaics. These accounts exist solely for development and learning purposes.

The keys to these accounts can be found in the target/addresses.yml file as described above, in the mosaics section:

mosaics:
    currency:
        -
            # This is an account containing the main currency
            privateKey: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
            publicKey: 2E10EE45517E04150B5701EDDCBBF95D5E7077CA6627E29CFA8B862BAE09A29F
            address: TCOKYEBOBNVFEPCEADZXFESZFFIWJH2LF245O3A
    harvest:
        -
            # This is an account containing the network currency used for harvesting
            privateKey: ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
            publicKey: 1467662C8FBE485FDDB792E36646AC935443B354D38A1DF9E4CE3DAAE5B6F107
            address: TA4B2EM3OJVYE7ZP426J3UVWPRRP4HDCKJHUXEI

Use the Private Keys to access these accounts, for example, using the symbol-cli command-line tool as described above.

Voting nodes

The block finalization process requires that network nodes vote about the correctness of blocks before they are added to the blockchain. Each node can decide whether to register as a voter or not.

All nodes created by the bootstrap preset are voters by default. If you don’t want this, provide a custom preset with these lines to disable voting for each node:

nodes:
- voting: false # peer-node-0
- voting: false # peer-node-1
- voting: false # api-node-0

Note

Without ANY voting node no finalization can occur. By taking a look at localhost:3000/chain/info you will see you chain height grow but the latestFinalizedBlock’s height will remain at zero.

Configuring network properties

Read the Configuring network properties guide for a list of network-related settings that can be customized.

Next steps

You now have a test network running and access to each node’s account. You can also interact with it through the API node serving at localhost:3000.

We recommend you continue reading the rest of the guides to keep learning more Symbol’s features!