Install Rustup
curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs> | sh
Set vars
OR USE THIS ENDPOINT:
read -p "Enter json-rpc: " BLOCKCHAIN_RPC_ENDPOINT && echo "Current json-rpc: $BLOCKCHAIN_RPC_ENDPOINT" &&
ENR_ADDRESS=$(wget -qO- eth0.me)
echo "export ENR_ADDRESS=${ENR_ADDRESS}" >> ~/.bash_profile
echo 'export ZGS_LOG_DIR="$HOME/0g-storage-node/run/log"' >> ~/.bash_profile
echo 'export ZGS_LOG_SYNC_BLOCK="802"' >> ~/.bash_profile
echo 'export LOG_CONTRACT_ADDRESS="0x8873cc79c5b3b5666535C825205C9a128B1D75F1"' >> ~/.bash_profile
echo 'export MINE_CONTRACT="0x85F6722319538A805ED5733c5F4882d96F1C7384"' >> ~/.bash_profile
echo "export BLOCKCHAIN_RPC_ENDPOINT=\\"$BLOCKCHAIN_RPC_ENDPOINT\\"" >> ~/.bash_profile
source ~/.bash_profile
echo -e "\\n\\033[31mCHECK YOUR STORAGE NODE VARIABLES\\033[0m\\n\\nLOG_CONTRACT_ADDRESS: $LOG_CONTRACT_ADDRESS\\nMINE_CONTRACT: $MINE_CONTRACT\\nZGS_LOG_SYNC_BLOCK: $ZGS_LOG_SYNC_BLOCK\\nBLOCKCHAIN_RPC_ENDPOINT: $BLOCKCHAIN_RPC_ENDPOINT\\n\\n"
VERIFY THE JSON-RPC SYNC TO ENSURE IT’S AT THE LATEST BLOCK.
curl -s -X POST $BLOCKCHAIN_RPC_ENDPOINT -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' | jq -r '.result' | xargs printf "%d\\n"
Download binary
cd $HOME
git clone <https://github.com/0glabs/0g-storage-node.git>
cd $HOME/0g-storage-node
git fetch
git checkout tags/v0.3.3 --force
git submodule update --init
sudo apt install cargo
cargo build --release
Wallet private key export:
0gchaind keys unsafe-export-eth-key $WALLET
Save your private key in a variable:
read -sp "Enter your private key: " PRIVATE_KEY && echo
Update node configuration
sed -i '
s|^miner_key = ""|miner_key = "'"$PRIVATE_KEY"'"|
s|^\\s*#\\?\\s*network_dir\\s*=.*|network_dir = "network"|
s|^\\s*#\\?\\s*network_enr_address\\s*=.*|network_enr_address = "'"$ENR_ADDRESS"'"|
s|^\\s*#\\?\\s*network_enr_tcp_port\\s*=.*|network_enr_tcp_port = 1234|
s|^\\s*#\\?\\s*network_enr_udp_port\\s*=.*|network_enr_udp_port = 1234|
s|^\\s*#\\s*watch_loop_wait_time_ms\\s*=.*|watch_loop_wait_time_ms = 1000|
s|^\\s*#\\?\\s*network_libp2p_port\\s*=.*|network_libp2p_port = 1234|
s|^\\s*#\\?\\s*network_discovery_port\\s*=.*|network_discovery_port = 1234|
s|^\\s*#\\s*rpc_listen_address\\s*=.*|rpc_listen_address = "0.0.0.0:5678"|
s|^\\s*#\\s*rpc_listen_address_admin\\s*=.*|rpc_listen_address_admin = "0.0.0.0:5679"|
s|^\\s*#\\?\\s*rpc_enabled\\s*=.*|rpc_enabled = true|
s|^\\s*#\\?\\s*db_dir\\s*=.*|db_dir = "db"|
s|^\\s*#\\?\\s*log_config_file\\s*=.*|log_config_file = "log_config"|
s|^\\s*#\\?\\s*log_directory\\s*=.*|log_directory = "log"|
s|^\\s*#\\?\\s*network_boot_nodes\\s*=.*|network_boot_nodes = \\["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAkzRjxK2gorngB1Xq84qDrT4hSVznYDHj6BkbaE4SGx9oS","/ip4/18.167.69.68/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"]|
s|^\\s*#\\?\\s*log_contract_address\\s*=.*|log_contract_address = "'"$LOG_CONTRACT_ADDRESS"'"|
s|^\\s*#\\?\\s*mine_contract_address\\s*=.*|mine_contract_address = "'"$MINE_CONTRACT"'"|
s|^\\s*#\\?\\s*log_sync_start_block_number\\s*=.*|log_sync_start_block_number = '"$ZGS_LOG_SYNC_BLOCK"'|
s|^\\s*#\\?\\s*blockchain_rpc_endpoint\\s*=.*|blockchain_rpc_endpoint = "'"$BLOCKCHAIN_RPC_ENDPOINT"'"|
' $HOME/0g-storage-node/run/config.toml
Create service