Lite-nodes are a simplified node option that allows developers to perform lightweight tasks on a local node. This page covers how to spin up a lite node on your local machine.
In this guide, we will use the Lotus Filecoin implementation to install a lite-node on MacOS and Ubuntu. For other Linux distributions, check out the Lotus documentation. To run a lite-node on Windows, install WLS with Ubuntu on your system and follow the Ubuntu instructions below.
Prerequisites
Lite-nodes have relatively lightweight hardware requirements. Your machine should meet the following hardware requirements:
At least 2 GiB of RAM
A dual-core CPU.
At least 4 GiB of storage space.
To build the lite-node, you’ll need some specific software. Run the following command to install the software prerequisites:
Using the value returned from the previous command, checkout to the latest release branch:
gitcheckoutv1.29.0
If your processor was released later than an AMD Zen or Intel Ice Lake CPU, enable SHA extensions by adding these two environment variables. If in doubt, ignore this command and move on to the next section.
The last thing we need to do to get our node setup is to build the package. The command you need to run depends on which network you want to connect to:
Remove or delete any existing Lotus configuration files on your system:
mv~/.lotus~/.lotus-backup
Make the Lotus binaries and install them:
makecleanallsudomakeinstall
Once the installation finishes, query the Lotus version to ensure everything is installed successfully and for the correct network:
lotus--version
This will output something like:
lotus version 1.29.0+mainnet+git.1ff3b360b
Remove or delete any existing Lotus configuration files on your system:
mv~/.lotus~/.lotus-backup
Make the Lotus binaries and install them:
makeclean&&makecalibrationnetsudomakeinstall
Once the installation finishes, query the Lotus version to ensure everything is installed successfully and for the correct network:
lotus--version
This will output something like:
lotus version 1.29.0+calibnet+git.1ff3b360b
Start the node
Let's start the lite-node by connecting to a remote full-node. We can use the public full-nodes from glif.io:
Create an environment variable called FULLNODE_API_INFO and set it to the WebSockets address of the node you want to connect to. At the same time, start the Lotus daemon with the --lite tag:
2023-01-26T11:18:54.251-0400 INFO main lotus/daemon.go:219 lotus repo: /Users/johnny/.lotus
2023-01-26T11:18:54.254-0400 WARN cliutil util/apiinfo.go:94 API Token not set and requested, capabilities might be limited.
...
The Lotus daemon will continue to run in this terminal window. All subsequent commands we use should be done in a separate terminal window.
Create an environment variable called FULLNODE_API_INFO and set it to the WebSockets address of the node you want to connect to. At the same time, start the Lotus daemon with the --lite tag:
2023-01-26T11:18:54.251-0400 INFO main lotus/daemon.go:219 lotus repo: /Users/johnny/.lotus
2023-01-26T11:18:54.254-0400 WARN cliutil util/apiinfo.go:94 API Token not set and requested, capabilities might be limited.
...
The Lotus daemon will continue to run in this terminal window. All subsequent commands we use should be done in a separate terminal window.
Expose the API
To send JSON-RPC requests to our lite-node, we need to expose the API.
Open ~/.lotus/config.toml and uncomment ListenAddress on line 6:
2023-01-26T11:18:54.251-0400 INFO main lotus/daemon.go:219 lotus repo: /Users/johnny/.lotus
2023-01-26T11:18:54.254-0400 WARN cliutil util/apiinfo.go:94 API Token not set and requested, capabilities might be limited
...
The Lotus daemon will continue to run in this terminal window. All subsequent commands we use should be done in a separate terminal window.
Open ~/.lotus/config.toml and uncomment ListenAddress on line 6:
2023-01-26T11:18:54.251-0400 INFO main lotus/daemon.go:219 lotus repo: /Users/johnny/.lotus
2023-01-26T11:18:54.254-0400 WARN cliutil util/apiinfo.go:94 API Token not set and requested, capabilities might be limited.
...
The Lotus daemon will continue to run in this terminal window. All subsequent commands we use should be done in a separate terminal window.
The lite-node is now set up to accept local JSON-RPC requests! However, we don't have an authorization key, so we won't have access to privileged JSON-RPC methods.
Create a key
To access privileged JSON-RPC methods, like creating a new wallet, we need to supply an authentication key with our Curl requests.
Create a new admin token and set the result to a new LOTUS_ADMIN_KEY environment variable:
The result field is the public key for our address. The private key is stored within our lite-node.
Set the new address as the default wallet for our lite-node. Remember to replace the Bearer token with our auth key eyJhbGc... and the "params" value with the wallet address, f1vuc4..., returned from the previous command:
You should now have a local lite-node connected to a remote full-node with an admin API key! You can use this setup to continue playing around with the JSON-RPC, or start building your applications on Filecoin!