Node¶
If you already know something about aelf blockchain and want to get deeply involved, you can proceed with the following and run your own node.
If you are a beginner or you want to deploy contracts onto aelf, please click here to learn more.
Why Should I Run a Node
- Full node: A full node stores the complete blockchain data and you can view all the info. It also enables you to deploy DApps and contracts on aelf or interact with its contracts.
- BP: To run a full node that produces blocks, the node needs to participate in the election. If ranked among the top 2N+1 (N=8 in the first year and increases by 1 every year. Currently the threshold is 17), it can get involved in the governance of aelf.
Next, we will show you how to deploy nodes.
Single Node¶
macOS¶
Follow this doc to run an aelf single node on a macOS device and this will take around 20 minutes to complete.
Install aelf-command¶
Execute this command to install aelf-command:
npm i aelf-command -g
The following output suggests successful installation:
+ aelf-command@0.1.44
added 314 packages from 208 contributors in 25.958s
Besides, you might see warnings like this due to differences in system configuration. Please ignore it.

If it shows error Permission denied @ apply2files
, then there is a
permission issue. You can solve it using the following command and then
redo the installation with the above command:
sudo chmod 755 /usr/local/lib/node_modules
Clone and Build aelf’s Code¶
Create a directory. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir ~/Desktop/Code
- Execute this command to change the directory:
cd ~/Desktop/Code
- Execute this command to clone aelf’s code:
git clone https://github.com/AElfProject/AElf.git
- Execute this command to change to aelf’s directory:
cd AElf
- Execute this command to restore aelf’s files:
dotnet restore AElf.All.sln
- Execute this command to build aelf’s code (this will take several minutes):
dotnet build AElf.All.sln
The following output suggests successful building:
xx Warning(s)
0 Error(s)
Time Elapsed 00:15:59.77
If contract_csharp_plugin fails to be called, it may be because you don’t have Rosetta 2 installed. Please execute this command and then retry:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Create an aelf Account¶
Execute this command:
aelf-command create
An aelf account will be automatically created and you will see info like:
AElf [Info]: Your wallet info is :
AElf [Info]: Mnemonic : mirror among battle muffin cattle plunge tuition buzz hip mad surround recall
AElf [Info]: Private Key : 4bf625afea60e21aa5afcab5ea682b3dfb614941245698632d72a09ae13*****
AElf [Info]: Public Key : 04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****
AElf [Info]: Address : 21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****
You will then be asked whether you want the account data stored as a
json file. Enter y
to confirm and the file will be stored in
/Users/{username}/.local/share/aelf/keys/
.
Please make sure you remember the account data or the json file’s location.
You will be required to set a password (referred to as * here):
Enter a password: ********
Confirm password: ********
For the sake of convenience, you are encouraged to keep this Terminal on the account info interface and open another Terminal to continue the following.
Run a Single Node¶
A single node runs aelf blockchain on one node. It is usually used to test the execution of contracts only.
- Execute this command to start a Redis instance (skip this step if redis-server is already started):
redis-server
- Open another Terminal and execute this command to change to aelf’s directory:
cd ~/Desktop/Code/AElf
- Execute this command to change to the
AElf.Launcher
directory:
cd src/AElf.Launcher
- Modify the
appsettings.json
file: for novices, you can go to desktop -> Code -> AElf -> src -> AElf.Launcher and open theappsettings.json
file in the editor to modify it (or, if you are familiar with Linux commands, you can run thevim appsettings.json
command and modify the file in the command-line interface).
Find the account data you just created using aelf-command create
.
AElf [Info]: Your wallet info is :
AElf [Info]: Mnemonic : mirror among battle muffin cattle plunge tuition buzz hip mad surround recall
AElf [Info]: Private Key : 4bf625afea60e21aa5afcab5ea682b3dfb614941245698632d72a09ae13*****
AElf [Info]: Public Key : 04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****
AElf [Info]: Address : 21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****
Fill in the NodeAccount
and NodeAccountPassword
under
Account
using the Address
and password
you set in
appsettings.json
:
"Account": {
"NodeAccount": "",
"NodeAccountPassword": ""
}
It may look like this when you complete it:
"Account": {
"NodeAccount": "21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****",
"NodeAccountPassword": "********"
},
Fill in the InitialMineList
under Consensus
using Public Key:
"Consensus": {
"InitialMinerList": [],
"MiningInterval": 4000,
"StartTimestamp": 0,
"PeriodSeconds": 604800,
"MinerIncreaseInterval": 31536000
}
It may look like this when you complete it (make sure to add “”):
"Consensus": {
"InitialMinerList": ["04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****"],
"MiningInterval": 4000,
"StartTimestamp": 0,
"PeriodSeconds": 604800,
"MinerIncreaseInterval": 31536000
}
If the IP and port for Redis have been changed, you can modify them
under ConnectionStrings
in appsettings.json
(skip this step if
they are not changed):
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
}
- Execute
dotnet run
:
sudo dotnet run
The following output suggests successful execution:
2022-11-29 16:07:44,554 [.NET ThreadPool Worker] INFO AElf.Kernel.SmartContractExecution.Application.BlockExecutionResultProcessingService - Attach blocks to best chain, best chain hash: "f396756945d9bb883f81827ab36fcb0533d3c66f7062269700e49b74895*****", height: 177
If you want to check the node’s block height and other block info, you can visit this page where you can access the API docs and interact with this single node.
To shut the node down, please use control + c on your keyboard.
If you don’t want to save the data, you can execute this command to delete all:
redis-cli flushall
Linux and Codespaces¶
Follow this doc to run an aelf single node in Linux and Codespaces and this will take around 20 minutes to complete.
Install aelf-command¶
Execute this command to install aelf-command:
npm i aelf-command -g
The following output suggests successful installation:
+ aelf-command@0.1.44
added 314 packages from 208 contributors in 25.958s
You might see warnings like this due to differences in system configuration. Please ignore it:

Clone and Build aelf’s Code¶
Create a directory. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir ~/Desktop/Code
- Execute this command to change the directory:
cd ~/Desktop/Code
- Execute this command to clone aelf’s code:
git clone https://github.com/AElfProject/AElf.git
- Execute this command to change to aelf’s directory:
cd AElf
- Execute this command to restore aelf’s files:
dotnet restore AElf.All.sln
- Execute this command to build aelf’s code (this will take several minutes):
dotnet build AElf.All.sln
The following output suggests successful building:
xx Warning(s)
0 Error(s)
Time Elapsed 00:15:59.77
Create an aelf Account¶
Execute this command:
aelf-command create
An aelf account will be automatically created and you will see info like:
AElf [Info]: Your wallet info is :
AElf [Info]: Mnemonic : mirror among battle muffin cattle plunge tuition buzz hip mad surround recall
AElf [Info]: Private Key : 4bf625afea60e21aa5afcab5ea682b3dfb614941245698632d72a09ae13*****
AElf [Info]: Public Key : 04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****
AElf [Info]: Address : 21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****
You will then be asked whether you want the account data stored as a
json file. Enter y
to confirm and the file will be stored in
/root/.local/share/aelf/keys/
.
Please make sure you remember the account data or the json file’s location.
You will be required to set a password (referred to as * here):
Enter a password: ********
Confirm password: ********
For the sake of convenience, you are encouraged to keep this Terminal on the account info interface and open another Terminal to continue the following.
Run a Single Node¶
A single node runs aelf blockchain on one node. It is usually used to test the execution of contracts only.
- Execute this command to start a Redis instance (skip this step if redis-server is already started):
redis-server
- Open another Terminal and execute this command to change to aelf’s directory:
cd ~/Desktop/Code/AElf
- Execute this command to change to the
AElf.Launcher
directory:
cd src/AElf.Launcher
- Modify the
appsettings.json
file: for novices, you can go to desktop -> Code -> AElf -> src -> AElf.Launcher and open theappsettings.json
file in the editor to modify it (or, if you are familiar with Linux commands, you can run thevim appsettings.json
command and modify the file in the command-line interface).
Find the account data you just created using aelf-command create
.
AElf [Info]: Your wallet info is :
AElf [Info]: Mnemonic : mirror among battle muffin cattle plunge tuition buzz hip mad surround recall
AElf [Info]: Private Key : 4bf625afea60e21aa5afcab5ea682b3dfb614941245698632d72a09ae13*****
AElf [Info]: Public Key : 04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****
AElf [Info]: Address : 21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****
Fill in the NodeAccount
and NodeAccountPassword
under
Account
using the Address
and password
you set in
appsettings.json
:
"Account": {
"NodeAccount": "",
"NodeAccountPassword": ""
}
It may look like this when you complete it:
"Account": {
"NodeAccount": "21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****",
"NodeAccountPassword": "********"
},
Fill in the InitialMineList
under Consensus
using Public Key:
"Consensus": {
"InitialMinerList": [],
"MiningInterval": 4000,
"StartTimestamp": 0,
"PeriodSeconds": 604800,
"MinerIncreaseInterval": 31536000
}
It may look like this when you complete it (make sure to add “”):
"Consensus": {
"InitialMinerList": ["04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****"],
"MiningInterval": 4000,
"StartTimestamp": 0,
"PeriodSeconds": 604800,
"MinerIncreaseInterval": 31536000
}
If the IP and port for Redis have been changed, you can modify them
under ConnectionStrings
in appsettings.json
(skip this step if
they are not changed):
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
}
Save the changes and keep them in the AElf.Launcher
directory.
- Execute
dotnet run
:
sudo dotnet run
The following output suggests successful execution:
2022-11-29 16:07:44,554 [.NET ThreadPool Worker] INFO AElf.Kernel.SmartContractExecution.Application.BlockExecutionResultProcessingService - Attach blocks to best chain, best chain hash: "f396756945d9bb883f81827ab36fcb0533d3c66f7062269700e49b74895*****", height: 177
If you want to check the node’s block height and other block info, you can visit this page where you can access the API docs and interact with this single node.
To shut the node down, please use control + c on your keyboard.
If you don’t want to save the data, you can execute this command to delete all:
redis-cli flushall
Windows¶
Follow this doc to run an aelf single node on a Windows device and this will take around 20 minutes to complete.
Install aelf-command¶
Execute npm command to install aelf-command:
npm i aelf-command -g
The following output suggests successful installation:
+ aelf-command@0.1.44
added 314 packages from 208 contributors in 25.958s
You might see warnings like this due to differences in system configuration. Please ignore it:

Clone and Build aelf’s Code¶
Create a directory. This tutorial uses a directory on the desktop for reference.
- Execute this command in cmd or PowerShell to create a directory:
mkdir C:/Users/${username}/Desktop/Code
- Execute this command to change the directory:
cd C:/Users/${username}/Desktop/Code
- Execute this command to clone aelf’s code:
git clone https://github.com/AElfProject/AElf.git
- Execute this command to change to aelf’s directory:
cd AElf
- Execute this command to restore aelf’s files:
dotnet restore AElf.All.sln
- Execute this command to build aelf’s code (this will take several minutes):
dotnet build AElf.All.sln
The following output suggests successful building:
xx Warning(s)
0 Error(s)
Time Elapsed 00:15:59.77
Create an aelf Account¶
Execute this command:
aelf-command create
An aelf account will be automatically created and you will see info like:
AElf [Info]: Your wallet info is :
AElf [Info]: Mnemonic : mirror among battle muffin cattle plunge tuition buzz hip mad surround recall
AElf [Info]: Private Key : 4bf625afea60e21aa5afcab5ea682b3dfb614941245698632d72a09ae13*****
AElf [Info]: Public Key : 04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****
AElf [Info]: Address : 21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****
You will then be asked whether you want the account data stored as a
json file. Enter y
to confirm and the file will be stored locally.
Please make sure you remember the account data or the json file’s location.
You will be required to set a password (referred to as * here):
Enter a password: ********
Confirm password: ********
For the sake of convenience, you are encouraged to keep this cmd or PowerShell on the account info interface and open another cmd or PowerShell to continue the following.
Run a Single Node¶
A single node runs aelf blockchain on one node. It is usually used to test the execution of contracts only.
- Execute this command to start a Redis instance (skip this step if redis-server is already started):
redis-server
- Open another cmd or PowerShell and execute this command to change to aelf’s directory:
cd C:/Users/${username}/Desktop/Code
- Execute this command to change to the
AElf.Launcher
directory:
cd src/AElf.Launcher
- Modify the
appsettings.json
file: for novices, you can go to desktop -> Code -> AElf -> src -> AElf.Launcher and open theappsettings.json
file in the editor to modify it (or you can run thestart appsettings.json
command and open the appsettings.json file in the editor).
Find the account data you just created using aelf-command create
.
AElf [Info]: Your wallet info is :
AElf [Info]: Mnemonic : mirror among battle muffin cattle plunge tuition buzz hip mad surround recall
AElf [Info]: Private Key : 4bf625afea60e21aa5afcab5ea682b3dfb614941245698632d72a09ae13*****
AElf [Info]: Public Key : 04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****
AElf [Info]: Address : 21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****
Fill in the NodeAccount
and NodeAccountPassword
under
Account
using the Address
and password
you set in
appsettings.json
:
"Account": {
"NodeAccount": "",
"NodeAccountPassword": ""
}
It may look like this when you complete it:
"Account": {
"NodeAccount": "21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****",
"NodeAccountPassword": "********"
},
Fill in the InitialMineList
under Consensus
using Public Key:
"Consensus": {
"InitialMinerList": [],
"MiningInterval": 4000,
"StartTimestamp": 0,
"PeriodSeconds": 604800,
"MinerIncreaseInterval": 31536000
}
It may look like this when you complete it (make sure to add “”):
"Consensus": {
"InitialMinerList": ["04f9bb56a9eca921bd494e677307f0279c98f1d2ed6bdeaa6dd256878272eabd14e91ec61469d2a32ce5e63205930dabdc0b9f13fc80c1f4e31760618d182*****"],
"MiningInterval": 4000,
"StartTimestamp": 0,
"PeriodSeconds": 604800,
"MinerIncreaseInterval": 31536000
}
If the IP and port for Redis have been changed, you can modify them
under ConnectionStrings
in appsettings.json
(skip this step if
they are not changed):
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
}
Save the changes and keep them in the AElf.Launcher
directory.
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
}
- Execute
dotnet run
:
sudo dotnet run
The following output suggests successful execution:
2022-11-29 16:07:44,554 [.NET ThreadPool Worker] INFO AElf.Kernel.SmartContractExecution.Application.BlockExecutionResultProcessingService - Attach blocks to best chain, best chain hash: "f396756945d9bb883f81827ab36fcb0533d3c66f7062269700e49b74895*****", height: 177
If you want to check the node’s block height and other block info, you can visit this page where you can access the API docs and interact with this single node.
To shut the node down, please use control + c on your keyboard.
If you don’t want to save the data, you can execute this command to delete all:
redis-cli flushall
Multi Nodes¶
macOS¶
Follow this doc to run aelf multi-nodes on a macOS device and this will take around 20 minutes to complete.
Run Multi-Nodes¶
This tutorial will guide you through how to run three nodes.
Publish aelf’s Code¶
Create a directory. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir ~/Desktop/Out
- Execute this command to change the directory:
cd ~/Desktop/Code/AElf
- Execute this command to publish aelf’s code (this will take several minutes):
sudo dotnet publish AElf.All.sln /p:NoBuild=false --configuration Debug -o ~/Desktop/Out
Configure Three Nodes¶
- Execute this command three times to create three accounts: A, B, and C.
aelf-command create
Please make sure you remember their Public Keys and Addresses.
Create a directory for node configuration. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir ~/Desktop/Config
- Execute this command to change the directory:
cd ~/Desktop/Config
- Execute this command to create three new directories:
bp1
,bp2
, andbp3
in the “Config” directory and create their respective “keys” directories.
mkdir -p ~/Desktop/Config/bp1/keys
mkdir -p ~/Desktop/Config/bp2/keys
mkdir -p ~/Desktop/Config/bp3/keys
- Copy account A, B, and C from
/Users/{username}/.local/share/aelf/keys/
tobp1/keys
,bp2/keys
, andbp3/keys
respectively (If you can’t find.local
, you can use cmd + shift + g in Finder to designate the directories). - Execute this command to create
appsettings.json
files andappsettings.MainChain.MainNet.json
files in directoriesbp1
,bp2
, andbp3
:
cd ~/Desktop/Config/bp1;touch appsettings.json;touch appsettings.MainChain.MainNet.json
cd ~/Desktop/Config/bp2;touch appsettings.json;touch appsettings.MainChain.MainNet.json
cd ~/Desktop/Config/bp3;touch appsettings.json;touch appsettings.MainChain.MainNet.json
For appsettings.json
:
{
"Logging": {
"LogLevel": {
"Default": "Debug"
}
},
"AllowedHosts": "*",
"CorsOrigins": "*",
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
},
"ChainId": "AELF",
"IsMainChain" : true,
"NetType": "MainNet",
"Account": {
"NodeAccount": "21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****",
"NodeAccountPassword": "********"
},
"Network": {
"BootNodes": [],
"ListeningPort": 7001,
"NetAllowed": "",
"NetWhitelist": []
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:8001/"
}
}
},
"Runner": {
"BlackList": [],
"WhiteList": []
},
"DeployServiceUrl": "",
"Consensus": {
"InitialMinerList" : [
"04884d9563b3b67a589e2b9b47794fcfb3e15fa494053088dd0dc8a909dd72bfd24c43b0e2303d631683acaed34acf87526dd489e3805211cba710d956718*****",
"045670526219d73154847b1e9367be9af293601793c9f7e34a96336650c9c1104a4aac9aaee960af00e775dcd88048698629891b0617ab605e646ae78961c*****",
"046a5913eae5fee3da9ee33604119f025a0ad45575dfed1257eff5da2c24e629845b1e1a131c5da8751971d545cc5c03826b3eb2b7109b5141679a1927338*****"
],
"MiningInterval" : 4000,
"StartTimestamp": 0,
"PeriodSeconds": 120
},
"BackgroundJobWorker":{
"JobPollPeriod": 1
}
}
For appsettings.MainChain.MainNet.json
:
{
"ChainId": "AELF",
"TokenInitial": {
"Symbol": "ELF",
"Name": "elf token",
"TotalSupply": 1000000000,
"Decimals": 2,
"IsBurnable": true,
"DividendPoolRatio": 0.2
},
"ElectionInitial": {
"LockForElection": 100000,
"TimeEachTerm": 2,
"BaseTimeUnit": 2,
"MinimumLockTime": 1,
"MaximumLockTime": 2000
}
}
Modify the
appsettings.json
files in directorybp1
,bp2
, andbp3
as instructed:Change the numbers following
db=
inBlockchainDb
andStateDb
underConnectionStrings
:bp1
: redis://localhost:6379?db=1bp2
: redis://localhost:6379?db=2bp3
: redis://localhost:6379?db=3
Replace
NodeAccount
andNodeAccountPassword
underAccount
withAddress
andpassword
in account A, B, and C.Fill in all three
InitialMineList
underConsensus
using account A, B, and C’sPublic Key
, keys separated with,
:"Consensus": { "InitialMinerList" : [ "04884d9563b3b67a589e2b9b47794fcfb3e15fa494053088dd0dc8a909dd72bfd24c43b0e2303d631683acaed34acf87526dd489e3805211cba710d956718*****", "045670526219d73154847b1e9367be9af293601793c9f7e34a96336650c9c1104a4aac9aaee960af00e775dcd88048698629891b0617ab605e646ae78961c*****", "046a5913eae5fee3da9ee33604119f025a0ad45575dfed1257eff5da2c24e629845b1e1a131c5da8751971d545cc5c03826b3eb2b7109b5141679a1927338*****" ],
In
bp1
,BootNodes
is blank andListeningPort
is 7001. Inbp2
,BootNodes
is127.0.0.1:7001
(make sure to add “”), andListeningPort
is 7002. Inbp3
,BootNodes
are127.0.0.1:7001
and127.0.0.1:7002
(make sure to add “” and separate them with,
) andListeningPort
is 7003.Change the port numbers in
Kestrel-EndPoints-Http-Url
to 8001, 8002, and 8003 respectively (to ensure there is no conflict of ports).
Execute this command to start a Redis instance:
redis-server
Run Three Nodes¶
In this tutorial, code is published in ~/Desktop/Out
and the three
nodes are configured in ~/Desktop/Config
.
Use redis-server
to start a Redis instance.
We recommend you open three new Terminals to monitor the nodes’ operation.
Execute this command to launch node 1:
cd ~/Desktop/Config/bp1;dotnet ~/Desktop/Out/AElf.Launcher.dll
Execute this command to launch node 2:
cd ~/Desktop/Config/bp2;dotnet ~/Desktop/Out/AElf.Launcher.dll
Execute this command to launch node 3:
cd ~/Desktop/Config/bp3;dotnet ~/Desktop/Out/AElf.Launcher.dll
The three nodes run successfully if all Terminals show the following output:
2022-11-30 20:51:04,163 [.NET ThreadPool Worker] INFO AElf.Kernel.Miner.Application.MiningService - Generated block: { id: "12f519e1601dd9f755a186b1370fd12696a8c080ea04465dadc*********2463", height: 25 }, previous: 5308de83c3585dbb4a097a9187a3b2f9b8584db4889d428484ca3e4df09e2860, executed transactions: 2, not executed transactions 0
To shut the nodes down, please use control + c on your keyboard.
If you don’t want to save the data, you can execute this command to delete all:
redis-cli flushall
Linux and Codespaces¶
Follow this doc to run aelf multi-nodes in Linux and Codespaces and this will take around 20 minutes to complete.
Run Multi-Nodes¶
This tutorial will guide you through how to run three nodes.
Publish aelf’s Code¶
Create a directory. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir ~/Desktop/Code
- Execute this command to change the directory:
cd ~/Desktop/Code/AElf
- Execute this command to publish aelf’s code (this will take several minutes):
sudo dotnet publish AElf.All.sln /p:NoBuild=false --configuration Debug -o ~/Desktop/Out
Configure Three Nodes¶
- Execute this command three times to create three accounts: A, B, and C.
aelf-command create
Please make sure you remember their Public Keys and Addresses.
Create a directory for node configuration. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir ~/Desktop/Config
- Execute this command to change the directory:
cd ~/Desktop/Config
- Execute this command to create three new directories:
bp1
,bp2
, andbp3
in the “Config” directory and create their respective “keys” directories.
mkdir -p ~/Desktop/Config/bp1/keys
mkdir -p ~/Desktop/Config/bp2/keys
mkdir -p ~/Desktop/Config/bp3/keys
- Copy account A, B, and C from
/root/.local/share/aelf/keys/
tobp1/keys
,bp2/keys
, andbp3/keys
respectively (If you can’t find.local
, you can use cmd + shift + g in Finder to designate the directories). - Execute this command to create
appsettings.json
files andappsettings.MainChain.MainNet.json
files in directoriesbp1
,bp2
, andbp3
:
cd ~/Desktop/Config/bp1;touch appsettings.json;touch appsettings.MainChain.MainNet.json
cd ~/Desktop/Config/bp2;touch appsettings.json;touch appsettings.MainChain.MainNet.json
cd ~/Desktop/Config/bp3;touch appsettings.json;touch appsettings.MainChain.MainNet.json
Copy the following templates to each file:
For appsettings.json
:
{
"Logging": {
"LogLevel": {
"Default": "Debug"
}
},
"AllowedHosts": "*",
"CorsOrigins": "*",
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
},
"ChainId": "AELF",
"IsMainChain" : true,
"NetType": "MainNet",
"Account": {
"NodeAccount": "21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****",
"NodeAccountPassword": "********"
},
"Network": {
"BootNodes": [],
"ListeningPort": 7001,
"NetAllowed": "",
"NetWhitelist": []
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:8001/"
}
}
},
"Runner": {
"BlackList": [],
"WhiteList": []
},
"DeployServiceUrl": "",
"Consensus": {
"InitialMinerList" : [
"04884d9563b3b67a589e2b9b47794fcfb3e15fa494053088dd0dc8a909dd72bfd24c43b0e2303d631683acaed34acf87526dd489e3805211cba710d956718*****",
"045670526219d73154847b1e9367be9af293601793c9f7e34a96336650c9c1104a4aac9aaee960af00e775dcd88048698629891b0617ab605e646ae78961c*****",
"046a5913eae5fee3da9ee33604119f025a0ad45575dfed1257eff5da2c24e629845b1e1a131c5da8751971d545cc5c03826b3eb2b7109b5141679a1927338*****"
],
"MiningInterval" : 4000,
"StartTimestamp": 0,
"PeriodSeconds": 120
},
"BackgroundJobWorker":{
"JobPollPeriod": 1
}
}
For appsettings.MainChain.MainNet.json
:
{
"ChainId": "AELF",
"TokenInitial": {
"Symbol": "ELF",
"Name": "elf token",
"TotalSupply": 1000000000,
"Decimals": 2,
"IsBurnable": true,
"DividendPoolRatio": 0.2
},
"ElectionInitial": {
"LockForElection": 100000,
"TimeEachTerm": 2,
"BaseTimeUnit": 2,
"MinimumLockTime": 1,
"MaximumLockTime": 2000
}
}
Modify the
appsettings.json
files in directorybp1
,bp2
, andbp3
as instructed:Change the numbers following
db=
inBlockchainDb
andStateDb
underConnectionStrings
:bp1
: redis://localhost:6379?db=1bp2
: redis://localhost:6379?db=2bp3
: redis://localhost:6379?db=3
Replace
NodeAccount
andNodeAccountPassword
underAccount
withAddress
andpassword
in account A, B, and C.Fill in all three
InitialMineList
underConsensus
using account A, B, and C’sPublic Key
, keys separated with,
:"Consensus": { "InitialMinerList" : [ "04884d9563b3b67a589e2b9b47794fcfb3e15fa494053088dd0dc8a909dd72bfd24c43b0e2303d631683acaed34acf87526dd489e3805211cba710d956718*****", "045670526219d73154847b1e9367be9af293601793c9f7e34a96336650c9c1104a4aac9aaee960af00e775dcd88048698629891b0617ab605e646ae78961c*****", "046a5913eae5fee3da9ee33604119f025a0ad45575dfed1257eff5da2c24e629845b1e1a131c5da8751971d545cc5c03826b3eb2b7109b5141679a1927338*****" ],
In
bp1
,BootNodes
is blank andListeningPort
is 7001. Inbp2
,BootNodes
is127.0.0.1:7001
(make sure to add “”), andListeningPort
is 7002. Inbp3
,BootNodes
are127.0.0.1:7001
and127.0.0.1:7002
(make sure to add “” and separate them with,
) andListeningPort
is 7003.Change the port numbers in
Kestrel-EndPoints-Http-Url
to 8001, 8002, and 8003 respectively (to ensure there is no conflict of ports).
Execute this command to start a Redis instance:
redis-server
Run Three Nodes¶
In this tutorial, code is published in ~/Desktop/Out
and the three
nodes are configured in ~/Desktop/Config
.
Use redis-server
to start a Redis instance.
We recommend you open three new Terminals to monitor the nodes’ operation.
Execute this command to launch node 1:
cd ~/Desktop/Config/bp1;dotnet ~/Desktop/Out/AElf.Launcher.dll
Execute this command to launch node 2:
cd ~/Desktop/Config/bp2;dotnet ~/Desktop/Out/AElf.Launcher.dll
Execute this command to launch node 3:
cd ~/Desktop/Config/bp3;dotnet ~/Desktop/Out/AElf.Launcher.dll
The three nodes run successfully if all Terminals show the following output:
2022-11-30 20:51:04,163 [.NET ThreadPool Worker] INFO AElf.Kernel.Miner.Application.MiningService - Generated block: { id: "12f519e1601dd9f755a186b1370fd12696a8c080ea04465dadc*********2463", height: 25 }, previous: 5308de83c3585dbb4a097a9187a3b2f9b8584db4889d428484ca3e4df09e2860, executed transactions: 2, not executed transactions 0
To shut the nodes down, please use control + c on your keyboard.
If you don’t want to save the data, you can execute this command to delete all:
redis-cli flushall
Windows¶
Follow this doc to run aelf multi-nodes on a Windows device and this will take around 20 minutes to complete.
Run Multi-Nodes¶
This tutorial will guide you through how to run three nodes.
Publish aelf’s Code¶
Create a directory. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir C:/Users/${username}/Desktop/Out
- Execute this command to change the directory:
cd C:/Users/${username}/Desktop/Code/AElf
- Execute this command to publish aelf’s code (this will take several minutes):
Note: Be sure to replace ${username}
here with your user name.
sudo dotnet publish AElf.All.sln /p:NoBuild=false --configuration Debug -o C:/Users/${username}/Desktop/Out
Configure Three Nodes¶
- Execute this command three times to create three accounts: A, B, and C.
aelf-command create
Please make sure you remember their Public Keys and Addresses.
Create a directory for node configuration. This tutorial uses a directory on the desktop for reference.
- Execute this command to create a directory:
mkdir C:/Users/${username}/Desktop/Config
- Execute this command to change the directory:
cd C:/Users/${username}/Desktop/Config
- Execute this command to create three new directories:
bp1
,bp2
, andbp3
in the “Config” directory and create their respective “keys” directories.
mkdir -p C:/Users/${username}/Desktop/Config/bp1/keys
mkdir -p C:/Users/${username}/Desktop/Config/bp2/keys
mkdir -p C:/Users/${username}/Desktop/Config/bp3/keys
- Copy account A, B, and C from their json files to
bp1/keys
,bp2/keys
, andbp3/keys
respectively. - Execute this command to create
appsettings.json
files andappsettings.MainChain.MainNet.json
files in directoriesbp1
,bp2
, andbp3
:
cd C:/Users/${username}/Desktop/Config/bp1;touch appsettings.json;touch appsettings.MainChain.MainNet.json
cd C:/Users/${username}/Desktop/Config/bp2;touch appsettings.json;touch appsettings.MainChain.MainNet.json
cd C:/Users/${username}/Desktop/Config/bp3;touch appsettings.json;touch appsettings.MainChain.MainNet.json
Copy the following templates to each file:
For appsettings.json
:
{
"Logging": {
"LogLevel": {
"Default": "Debug"
}
},
"AllowedHosts": "*",
"CorsOrigins": "*",
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=1",
"StateDb": "redis://localhost:6379?db=1"
},
"ChainId": "AELF",
"IsMainChain" : true,
"NetType": "MainNet",
"Account": {
"NodeAccount": "21qciGwcaowwBttKMjMk86AW6WajhcodSHytY1vCyZb7p*****",
"NodeAccountPassword": "********"
},
"Network": {
"BootNodes": [],
"ListeningPort": 7001,
"NetAllowed": "",
"NetWhitelist": []
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:8001/"
}
}
},
"Runner": {
"BlackList": [],
"WhiteList": []
},
"DeployServiceUrl": "",
"Consensus": {
"InitialMinerList" : [
"04884d9563b3b67a589e2b9b47794fcfb3e15fa494053088dd0dc8a909dd72bfd24c43b0e2303d631683acaed34acf87526dd489e3805211cba710d956718*****",
"045670526219d73154847b1e9367be9af293601793c9f7e34a96336650c9c1104a4aac9aaee960af00e775dcd88048698629891b0617ab605e646ae78961c*****",
"046a5913eae5fee3da9ee33604119f025a0ad45575dfed1257eff5da2c24e629845b1e1a131c5da8751971d545cc5c03826b3eb2b7109b5141679a1927338*****"
],
"MiningInterval" : 4000,
"StartTimestamp": 0,
"PeriodSeconds": 120
},
"BackgroundJobWorker":{
"JobPollPeriod": 1
}
}
For appsettings.MainChain.MainNet.json
:
{
"ChainId": "AELF",
"TokenInitial": {
"Symbol": "ELF",
"Name": "elf token",
"TotalSupply": 1000000000,
"Decimals": 2,
"IsBurnable": true,
"DividendPoolRatio": 0.2
},
"ElectionInitial": {
"LockForElection": 100000,
"TimeEachTerm": 2,
"BaseTimeUnit": 2,
"MinimumLockTime": 1,
"MaximumLockTime": 2000
}
}
Modify the
appsettings.json
files in directorybp1
,bp2
, andbp3
as instructed:Change the numbers following
db=
inBlockchainDb
andStateDb
underConnectionStrings
:bp1
: redis://localhost:6379?db=1bp2
: redis://localhost:6379?db=2bp3
: redis://localhost:6379?db=3
Replace
NodeAccount
andNodeAccountPassword
underAccount
withAddress
andpassword
in account A, B, and C.Fill in all three
InitialMineList
underConsensus
using account A, B, and C’sPublic Key
, keys separated with,
:"Consensus": { "InitialMinerList" : [ "04884d9563b3b67a589e2b9b47794fcfb3e15fa494053088dd0dc8a909dd72bfd24c43b0e2303d631683acaed34acf87526dd489e3805211cba710d956718*****", "045670526219d73154847b1e9367be9af293601793c9f7e34a96336650c9c1104a4aac9aaee960af00e775dcd88048698629891b0617ab605e646ae78961c*****", "046a5913eae5fee3da9ee33604119f025a0ad45575dfed1257eff5da2c24e629845b1e1a131c5da8751971d545cc5c03826b3eb2b7109b5141679a1927338*****" ],
In
bp1
,BootNodes
is blank andListeningPort
is 7001. Inbp2
,BootNodes
is127.0.0.1:7001
(make sure to add “” ), andListeningPort
is 7002. Inbp3
,BootNodes
are127.0.0.1:7001
and127.0.0.1:7002
(make sure to add “” and separate them with,
) andListeningPort
is 7003.Change the port numbers in
Kestrel-EndPoints-Http-Url
to 8001, 8002, and 8003 respectively (to ensure there is no conflict of ports).
Execute this command to start a Redis instance:
redis-server
Run Three Nodes¶
In this tutorial, code is published in
C:/Users/${username}/Desktop/Out
and the three nodes are configured
in C:/Users/${username}/Desktop/Config
.
Use redis-server
to start a Redis instance.
We recommend you open three new terminals to monitor the nodes’ operation.
Execute this command to launch node 1:
cd ~/Desktop/Config/bp1;dotnet ~/Desktop/Out/AElf.Launcher.dll
Execute this command to launch node 2:
cd ~/Desktop/Config/bp2;dotnet ~/Desktop/Out/AElf.Launcher.dll
Execute this command to launch node 3:
cd ~/Desktop/Config/bp3;dotnet ~/Desktop/Out/AElf.Launcher.dll
The three nodes run successfully if all Terminals show the following output:
2022-11-30 20:51:04,163 [.NET ThreadPool Worker] INFO AElf.Kernel.Miner.Application.MiningService - Generated block: { id: "12f519e1601dd9f755a186b1370fd12696a8c080ea04465dadc*********2463", height: 25 }, previous: 5308de83c3585dbb4a097a9187a3b2f9b8584db4889d428484ca3e4df09e2860, executed transactions: 2, not executed transactions 0
To shut the nodes down, please use control + c on your keyboard.
If you don’t want to save the data, you can execute this command to delete all:
redis-cli flushall