Fullnode
This guide provides step-by-step instructions for setting up a NEAR Protocol full node on Mainnet. A full node keeps a complete copy of the blockchain and is essential for network health and decentralization.
Step 1: Prepare Your Environment
Hardware Requirements
Ensure your server meets the recommended hardware specifications for a reliable node.
Install Dependencies & Rust
Update your system and install the necessary packages for building nearcore
.
sudo apt update && sudo apt upgrade -y
sudo apt install -y git cmake gcc g++ python3 protobuf-compiler libssl-dev pkg-config clang llvm jq ccze
Next, install Rust and Cargo. When prompted, select the default installation option.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
Step 2: Install NEAR CLI
Install the NEAR Command Line Interface (CLI), which is used to interact with the NEAR network.
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
source $HOME/.cargo/env
Step 3: Compile the NEAR Node Software
Clone the nearcore
repository, check out the latest stable version, and compile the binary. This process is resource-intensive and may take some time.
cd ~
git clone https://github.com/near/nearcore
cd nearcore
NEARCORE_VERSION=$(curl -s https://api.github.com/repos/near/nearcore/releases/latest | jq -r .tag_name)
git checkout $NEARCORE_VERSION
make release
Set your shell environment to use mainnet
by default for all subsequent commands.
echo 'export NEAR_ENV=mainnet' >> ~/.bashrc
source ~/.bashrc
Step 4: Initialize the Node
Run the initialization command to create the necessary configuration files and directory structure (~/.near
).
cd ~/nearcore
./target/release/neard init --chain-id mainnet --download-genesis --download-config
Step 5: Run the Node as a Service
To ensure your node runs continuously, set it up as a systemd
service.
-
Create the service file:
sudo nano /etc/systemd/system/neard.service
-
Paste the following configuration. Remember to replace
[USER]
with your actual Linux username.[Unit]
Description=NEARd Daemon Service
[Service]
Type=simple
User=[USER]
WorkingDirectory=/home/[USER]/.near
ExecStart=/home/[USER]/nearcore/target/release/neard run
Restart=on-failure
RestartSec=30
KillSignal=SIGINT
TimeoutStopSec=45
KillMode=mixed
[Install]
WantedBy=multi-user.target -
Enable and start the service:
sudo systemctl enable neard
sudo systemctl start neard
Step 6: Sync the Node
Your node will now begin syncing with the network using the recommended Epoch Sync method. This can take several hours.
You can monitor the sync progress by watching the logs:
journalctl -n 100 -f -u neard | ccze -A
The node is fully synced when the last block number in your logs matches the latest block height on a network explorer like NearBlocks.
Congratulations! You now have a fully synced Mainnet full node. To become a validator and earn rewards, proceed to the Validator Setup Guide.