Skip to content

Commit 59fa84e

Browse files
committed
added local node deployment documentation
1 parent a028c00 commit 59fa84e

File tree

1 file changed

+186
-0
lines changed
  • docs/quick-start/advance-tutorials/local-node-deployment

1 file changed

+186
-0
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
sidebar_position: 2
3+
title: Local Node Deployment
4+
description: Deploy a local AElf node using Docker
5+
---
6+
7+
# Local Node Deployment
8+
9+
**Description**: This tutorial demonstrates how to deploy and run a local AElf node using Docker for testing and development purposes.
10+
11+
**Purpose**: Shows you how to set up your own local AElf blockchain node for development and testing.
12+
13+
**Difficulty Level**: Easy
14+
15+
<!-- <div class="video-container">
16+
<iframe src="https://www.youtube.com/embed/VIDEO_ID" title="AElf Local Node Deployment Tutorial" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
17+
</div> -->
18+
19+
## Step 1 - Setting up your development environment
20+
21+
### Prerequisites
22+
- Install [Docker](https://docs.docker.com/get-docker/)
23+
- Ensure you have at least 4GB of available RAM and 10GB of storage space
24+
- **Note for Apple Silicon users:**
25+
Ensure that Rosetta is installed, if it is not, use the following command:
26+
```bash
27+
softwareupdate --install-rosetta
28+
```
29+
- Install aelf deploy tool
30+
```bash
31+
dotnet tool install --global aelf.deploy
32+
```
33+
aelf.deploy is a utility tool for deploying smart contracts on the aelf blockchain. Please remember to export PATH after installing aelf.deploy.
34+
35+
:::info
36+
ℹ️ Note: If you have installed aelf.deploy and your terminal says that there is no such command available, please uninstall and install aelf.deploy.
37+
:::
38+
39+
- Install aelf-command
40+
<Tabs>
41+
<TabItem value="Linux and macOs" label="Linux and macOs" default>
42+
```bash title="Terminal"
43+
sudo npm i -g aelf-command
44+
```
45+
</TabItem>
46+
47+
<TabItem value="Windows" label="Windows">
48+
```bash title="Command Prompt"
49+
npm i -g aelf-command
50+
```
51+
</TabItem>
52+
</Tabs>
53+
54+
aelf-command is a CLI tool for interacting with the aelf blockchain, enabling tasks like creating wallets and managing transactions.
55+
Provide required permissions while installing aelf-command globally.
56+
57+
## Step 2 - Building the Docker Image
58+
59+
### Clone the AElf Developer Tools Repository
60+
Clone the AElf developer tools repository and navigate into the directory:
61+
62+
```bash
63+
git clone https://github.com/AElfProject/aelf-developer-tools.git
64+
cd aelf-developer-tools/local-test-node
65+
docker build -t aelf/standalone-testing-node .
66+
```
67+
68+
This will create a Docker image based on the AElf testnet node and include all necessary contract packages.
69+
70+
## Step 3 - Running the Node
71+
72+
Launch the node using Docker with the following command:
73+
74+
```bash
75+
docker run --name aelf-node --restart always \
76+
-e NODE_ACCOUNT="W1ptWN5n5mfdVvh3khTRm9KMJCAUdge9txNyVtyvZaYRYcqc1" \
77+
-e NODE_ACCOUNT_PASSWORD="admin123" \
78+
-itd -p 6801:6801 -p 8000:8000 -p 5001:5001 -p 5011:5011 \
79+
--platform linux/amd64 \
80+
--ulimit core=-1 \
81+
--security-opt seccomp=unconfined --privileged=true \
82+
aelf/standalone-testing-node
83+
```
84+
85+
This command:
86+
- Creates a container named `aelf-node`
87+
- Exposes necessary ports for node operation and API access
88+
- Configures appropriate system settings for the node
89+
- Runs the container in detached mode
90+
91+
### Port Mappings
92+
- 6801: P2P network communication
93+
- 8000: HTTP API endpoint
94+
- 5001: gRPC endpoint
95+
- 5011: Additional services
96+
97+
## Step 4 - Loading the Node Account
98+
99+
The node comes with a pre-configured account. Load it using aelf-command:
100+
101+
```bash
102+
aelf-command load 1111111111111111111111111111111111111111111111111111111111111111
103+
```
104+
105+
## Step 5 - Verifying Node Operation
106+
107+
1. Check if the node is running:
108+
```bash
109+
docker ps
110+
```
111+
112+
2. View node logs:
113+
```bash
114+
docker logs aelf-node
115+
```
116+
117+
3. Test the HTTP API:
118+
```bash
119+
curl http://localhost:8000/api/blockChain/chainStatus
120+
```
121+
122+
## Step 6 - Deploying Your Smart Contract
123+
124+
After building your smart contract DLL, you can deploy it locally using the following command:
125+
126+
```bash
127+
aelf-deploy -a $WALLET_ADDRESS -p $WALLET_PASSWORD -c $CONTRACT_PATH -e http://localhost:8000/
128+
```
129+
130+
Make sure to replace `$WALLET_ADDRESS`, `$WALLET_PASSWORD`, and `$CONTRACT_PATH` with your actual wallet address, wallet password, and the path to your compiled contract DLL, respectively.
131+
132+
For more detailed information on creating and deploying smart contracts, refer to the [Hello World Contract tutorial](https://docs.aelf.com/quick-start/developers/hello-world-contract/).
133+
134+
135+
## Configuration Details
136+
137+
The node uses several configuration files:
138+
139+
1. **appsettings.json**: Main configuration file containing:
140+
- Network settings
141+
- Consensus parameters
142+
- Database configurations
143+
- Logging settings
144+
145+
2. **appsettings.LocalTestNode.json**: Local environment specific settings
146+
- Logging levels
147+
- Database connections
148+
149+
3. **appsettings.MainChain.MainNet.json**: Chain-specific configurations
150+
- Economic parameters
151+
- Token settings
152+
- Cross-chain settings
153+
154+
:::tip
155+
ℹ️ Note: For development purposes, the node uses in-memory databases by default. For production environments, you should configure persistent storage.
156+
:::
157+
158+
## Common Issues and Solutions
159+
160+
1. **Docker Permission Issues**
161+
```bash
162+
# Add your user to the docker group
163+
sudo usermod -aG docker $USER
164+
# Then log out and back in
165+
```
166+
167+
2. **Port Conflicts**
168+
```bash
169+
# Check if ports are in use
170+
netstat -tulpn | grep -E '6801|8000|5001|5011'
171+
# Stop conflicting services or modify port mappings
172+
```
173+
174+
3. **Container Not Starting**
175+
```bash
176+
# Check detailed logs
177+
docker logs aelf-node
178+
# Remove and recreate container if needed
179+
docker rm -f aelf-node
180+
```
181+
182+
:::tip
183+
ℹ️ Remember to wait a few minutes after starting the node for it to fully initialize and begin producing blocks.
184+
:::
185+
186+
For more detailed information about node operation and configuration, please refer to the [AElf documentation](https://github.com/AElfProject/AElf).

0 commit comments

Comments
 (0)