Custom Network
This section will show you how to customize your node config and genesis file. This will allow you to create a private network for testing your dApp.
Prerequisites
You need an installed node.
Create a Custom Network
After you install the node, navigate into aion
folder, open an terminal and run:
This will create you a custom
network folder, which includes config, database, keystore and log for your customized network.
Customize Network Configuration
Go to your /custom/config
folder, there are two files to help you custom your network, config.xml and genesis.json.
config.xml
Following is the default config.xml
:
First, enable rpc connection so that your dApp can talk to this node via Json RPC by changing active="false"
to active=true
.
If you want to talk to this node remotely, change ip="127.0.0.1"
to ip="0.0.0.0"
.
If you are using minified aion web3.js
to interact with the network, update <cors-enabled>
to true
.
For example, if your dApp is talking to this node remotely with minified web3.js injected in your web application, your config should looks like:
Next thing you may want to update is the mining reward address. Change <miner-address>
to your address, so it can get AION through mining the blocks.
Last thing you can custom is how verbose you want your logs to be in <log>
section. Ranking from the least verbose to the most:ERROR < WARN < INFO < DEBUG < Trace
.
Note: You need to restart your kernel if you change anything in the config file.
genesis.json
genesis.json defines the genesis block of your network.
Here is the default genesis file:
Before you start the kernel for the first time, you can allocate your accounts with initial balances by add the account and the desired balance in alloc
block. By doing so, you can have multiple accounts with sufficient balance, instead of only have one account and waiting for mining reward.
You can also reset the kernel by deleting the database
folder for your custom network. Then restart the kernel with the new genesis file.