How to Install and Use Node.js: The Ideal Choice for Developers!
Saturday, Jan 11, 2025 | 9 minute read
Revolutionize your development experience with a streamlined platform that offers efficiency, non-blocking features, and a robust infrastructure, perfect for building fast and responsive applications in the booming DeFi landscape! β‘οΈπ
“In the wave of decentralized finance (DeFi), developers are in dire need of more efficient infrastructure to support their innovations.”
π Unveiling Ink Node: The Developer’s Preferred Choice!
Node.js is a renowned name in modern web development! β¨ With its efficiency and non-blocking features, it allows developers to easily build fast-responsive applications. As decentralized finance rises, the demand for a well-integrated node to facilitate the development and operation of various complex financial applications has become even more urgent for developers. Ink Node is a remarkable specialized blockchain in the DeFi domain that offers developers a comprehensive set of robust infrastructure support! βοΈπ‘
1. Ink Node: What is this Emerging DeFi Engine? π
Ink Node is a dedicated blockchain crafted by Kraken specifically for decentralized finance (DeFi). It provides developers and users with comprehensive infrastructure, making it simple and efficient to choose between the mainnet and testnet. In the blockchain world, Ink Node is praised for its high performance and ease of operation, allowing every user to navigate the sea of DeFi with ease! π
2. The Unique Appeal of Ink Node: Key Distinctive Features π
The appeal of Ink Node is truly astounding! First of all, its hardware requirements are relatively high; the mainnet requires at least 16GB of RAM and 2TB of SSD storage, while the testnet needs 16GB of RAM and 500GB of SSD storage. π» Moreover, maintaining a 100mb/s internet speed or higher is essential for Ink Node to run smoothly. It supports Docker and Docker Compose, offering flexible node management tools that simplify the installation and configuration process. Thanks to Docker, users can easily deploy, upgrade, and manage Ink Node instances, significantly enhancing deployment convenience! βοΈ
3. Ensuring Success: Why are Developers Turning to Ink Node? π
There are myriad reasons why developers are flocking to Ink Node! First, its strong community support is a vital guarantee for problem-solving and resource sharing. π οΈ The installation process is straightforward; users can easily set up and start by following just a few commands, greatly speeding up the onboarding process. The process for configuring environment variables is clear and understandable, helping developers quickly set their network and node types. β¨ In addition, Ink Node provides an array of management commands, including Docker notes and shell scripts, enabling users to start, stop, and monitor node status. π Its robust network monitoring capabilities, combined with the Grafana dashboard, ensure transparency and visual management of node operational status, enhancing the management experience for developers! π
The outstanding features and community support of Ink Node rapidly make it the preferred platform for modern developers in the blockchain arena. πͺ
How to Install and Use π§
Before we begin, we need to ensure that the software packages in the system are up to date for a smooth installation of Docker and other related tools. So, first execute the following commands to update and upgrade your Ubuntu system:
# Update and upgrade packages
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get update
checks for available package updates.sudo apt-get upgrade -y
upgrades all installed packages to the latest version. The-y
parameter auto-confirms all prompts, saving you from typing “yes”.
Prerequisites for Docker and Docker Compose π¦
Before installing Docker, we need to install some essential tools and libraries to ensure a smooth process:
# Docker and docker compose prerequisites
sudo apt-get install -y curl
sudo apt-get install -y gnupg
sudo apt-get install -y ca-certificates
sudo apt-get install -y lsb-release
curl
is a tool used to download files or data from the command line.gnupg
provides data encryption and signing features to ensure security.ca-certificates
includes the certifications required for SSL certification, safeguarding data security.lsb-release
helps identify information about the Linux distribution, aiding in system configuration.
Download the Docker GPG File π
Next, we need to download Docker’s GPG key file to securely install Docker:
# Download the Docker GPG file to Ubuntu
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo mkdir -p /etc/apt/keyrings
creates a directory to store the GPG key.curl -fsSL ...
downloads Docker’s GPG public key, and then thegpg
tool decodes and stores it.
Add Docker to Ubuntu’s Package List π
To allow Ubuntu to recognize Docker’s packages, we need to add it to the system’s source list:
# Add Docker support to the Ubuntu's packages list
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- The
echo
command writes Docker’s source address to a file. $(dpkg --print-architecture)
retrieves the system’s architecture, such as amd64.$(lsb_release -cs)
retrieves the current system’s version codename, like focal.
After that, π€ update the package list again:
sudo apt-get update
Install Docker and Docker Compose π³
Now we can officially install Docker and Docker Compose. Are you ready? Let’s get started:
# Install Docker and Docker Compose on Ubuntu
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
docker-ce
is the community edition of Docker, which is essential!docker-ce-cli
is the command-line tool for interacting with Docker.containerd.io
is the runtime for containers.docker-compose-plugin
is a plugin for managing multiple Docker containers.
Add User to Docker Group π₯
To run Docker without root permissions, youβll need to add the current user to the Docker group:
sudo usermod -aG docker $(whoami)
usermod -aG
adds the current user to the Docker group so you donβt have to use sudo every time!
After completing this step, log out and log back in for the changes to take effect. Then test whether Docker has been installed successfully:
# Verify the Docker and Docker Compose install on Ubuntu
sudo docker run hello-world
This command will pull and run the hello-world
image in a Docker container; if everything is correct, you’ll see a successful message!
If you’d like to test Docker again after logging out and back in, you can use the command:
docker ps
Clone the Project Repository ποΈ
Now, let’s clone the Node project repository from GitHub and get ready to dive in:
# Clone the Repository
git clone https://github.com/inkonchain/node
cd node
- The
git clone
command is used to clone the code from the remote repository. cd node
switches to the cloned project directory.
Copy the .env.example File π
Next, we need to copy the .env.example
file to .env
, which is an important file for saving various configuration parameters:
# Copy .env.example to .env
cp .env.example .env
Essential Configurations βοΈ
Open the .env
file and adjust or configure the necessary parameters:
- NETWORK_NAME: Choose the Optimism network you wish to use; it can be
ink-sepolia
orink-mainnet
. - NODE_TYPE: Select the node type, such as
full
orarchive
. - OP_NODE__RPC_ENDPOINT: Enter the RPC endpoint URL for Layer 1.
- OP_NODE__L1_BEACON: Enter the Layer 1 beacon port; you can use QuickNode services for this.
- OP_NODE__RPC_TYPE: Select the service provider for the RPC endpoint, such as
alchemy
,quicknode
,erigon
, orbasic
.
Start the Node π
Use the following command to start the Node and get ready for a new world:
# Start
docker compose up -d --build
This command will start the node in the background and build it!
View Logs π
To view the logs of the running node, use the following command:
# View Logs
docker compose logs -f --tail 10
Want to view logs for a specific container? You can use this command:
docker compose logs <CONTAINER_NAME> -f --tail 10
Common <CONTAINER_NAME>
options include:
op-geth
op-node
bedrock-init
Stop the Node π
To stop the node, use this command:
# Stop
docker compose down
This command will shut down the node but will not clear any data volumes.
Restart the Node π
To restart the node, you can use the command:
# Restart
docker compose restart
This command safely restarts the node while minimizing downtime.
Upgrade the Node β¬οΈ
If you want to pull the latest updates and rebuild the node, use these commands:
# Upgrade
git pull
docker compose pull
docker compose up -d --build
Wipe Data [Danger] β οΈ
If you need to completely wipe out all data, be very careful with this operation:
# Wipe [DANGER]
docker compose down -v
This command will terminate the node and delete all data, so think carefully before executing.
Estimate Remaining Sync Time β±οΈ
Run the progress.sh
script to estimate the remaining time for synchronization:
# Estimate Remaining Sync Time
./progress.sh
After running, it will show the sync speed and the time required for completion to help you keep track of your progress!
Grafana Dashboard π
You can access Grafana at http://localhost:3000 with the following login credentials:
- Username:
admin
- Password:
ink
Navigate to Dashboards > Manage > Simple Node Dashboard
to monitor node status clearly!
Troubleshooting π§
Errors Related to L1Block
If you encounter errors related to L1Block, try these quick fixes:
- Wait a few minutes to see if the issue resolves itself.
- Restart Docker Compose:
docker compose down
docker compose up -d --build
- If the issue persists, try setting
OP_GETH__SYNCMODE
in the.env
file tofull
and restart Docker Compose.
Additional Example Code π
Here are some handy example codes for interacting with smart contracts and handling RPC requests, definitely worth saving!
// Example code to deploy a smart contract
const contract = await ContractFactory.deploy(); // Deploy the contract
await contract.deployed(); // Wait for the contract to be deployed
console.log("Contract deployed to:", contract.address); // Print the contract address
This is a simple example of deploying a smart contract and printing out its address, easy to understand!
await hre.run('verify:verify', {
address: contract.address,
constructorArguments: [], // Constructor parameters used during deployment
});
This code is for verifying a deployed smart contract to ensure the process went smoothly.
Want to install the ethers library? This command will do the trick:
npm install ethers@6
You can also use yarn:
yarn add ethers@6
Next, here’s how to connect to an RPC:
import { ethers } from 'ethers';
const rpcUrl = 'https://rpc-gel-sepolia.inkonchain.com'; // RPC link
const provider = new ethers.JsonRpcProvider(rpcUrl, 763373); // Create RPC provider
This example shows how to create a JSON RPC provider using ethers, simple and efficient!
const blockNumber = await provider.getBlockNumber(); // Get current block number
console.log(blockNumber); // Print the current block number
The above code requests the current block number and outputs it, so give it a try!
To install the viem library, use:
npm install viem
Or:
yarn add viem
The following configuration is quite straightforward:
import { createPublicClient, http } from 'viem'
import { inkSepolia } from 'viem/chains' // Import chain information
const client = createPublicClient({
chain: inkSepolia,
transport: http(),
});
Getting the current block number is easy with this code:
const blockNumber = await client.getBlockNumber(); // Request current block number
console.log(blockNumber); // Print current block number
Lastly, to connect to your endpoint using the QuickNode SDK, follow this:
// Import QuickNode SDK
import { Core } from '@quicknode/sdk'
// Create connection
const core = new Core({
endpointUrl: "https://docs-demo.quiknode.pro/", // QuickNode endpoint
})
// Call getBlockNumber method
core.client.getBlockNumber();
Want to install the Foundry tool? Just use the following command:
curl -L https://foundry.paradigm.xyz | bash
That’s the detailed beginner’s guide for the Node project. Follow these steps to smoothly kick off your development journey! π Wishing you all the best in your development endeavors! π