Running A Local Network
Last updated
Last updated
Local networks can be helpful when testing your code. They are not connected to any production Endless networks like mainnet, but they are useful for three main reasons:
No rate limits: You can interact with hosted services like the Node API, Indexer API, and faucet with no rate-limits to speed up testing.
Reproducibility: You can set up specific on-chain scenarios and restart the network from scratch at any point to return to a clean slate.
High availability: The Endless devnet and testnet networks are periodically upgraded, during which time they can be unavailable. Local development networks are also always available even if you have no internet access.
Ensure you have the Endless CLI installed.
Ensure you have installed.
This is exclusively needed for making a production-like environment by running the Indexer API. Many downstream tools such as the Endless SDK depend on the Indexer API.
Docker recommends that you install via to get automatic updates.
Start Docker.
Run the following command in a new terminal to start the private network:
You should expect to see an output similar to this:
Wait for the final line Setup is complete, you can now use the localnet!
:::caution If you ran into an error, jump to the Common Errors section below. :::
As you can see from the above example output, once the local network is running, you have access to the following services:
Node API: This is a REST API that runs directly on the node. It enables core write functionality such as transaction submission and a limited set of read functionality, such as reading account resources or Move module information.
Transaction Stream Service: This is a gRPC stream of transactions used by the Indexer API. This is only relevant to you if you are developing a custom processor.
If you do not want to run any of these sub-components of a network, there are flags to disable them.
For more information on different flags you can pass when starting your local network, or configuration settings such as changing which port certain services run on, run the help command:
Address Already In Use
This means one of the ports needed by the local network is already in use by another process.
To fix this on Unix systems, you can:
Identify the name and PID of the process by running lsof -i :8080
.
Run kill <pid>
once you know the PID to free up that port.
Too many open files error
This means there were too many open files on your system. On many Unix systems you can increase the maximum number of open files by adding something like this to your .zshrc
:
Docker is not available
To debug this, try the below fixes:
Make sure you have docker installed by running docker --version
.
Ensure the Docker daemon is running by running docker info
(if this errors saying Cannot connect to the Docker daemon
Docker is NOT running)
Make sure the socket for connecting to Docker is present on your machine in the default location. For example, on Unix systems /var/run/docker.sock
should exist.
If that file does not exist, open Docker Desktop and enable Settings -> Advanced -> Allow the default Docker socket to be used.
Or, you can find where the Docker socket is by running docker context inspect | grep Host
, then symlink that location to the default location by running sudo ln -s /Users/dport/.docker/run/docker.sock /var/run/docker.sock
Now that the network is running, you can use it like you would any other network.
So, you can create a local profile like this:
Configuring the TypeScript SDK
If you want to use the local network with the TypeScript SDK, you can use local network URLs when initializing the client object (Endless):
Resetting the local network
Sometimes while developing it is helpful to reset the local network back to its initial state, for example:
You made backwards incompatible changes to a Move module, and you'd like to redeploy it without renaming it or using a new account.
You want to clear all on chain state, e.g. accounts, objects, etc.
To start with a brand new local network, use the --force-restart
flag:
It will then prompt you if you really want to restart the chain, to ensure that you do not delete your work by accident.
If you do not want to be prompted, include --assume-yes
as well:
If you are writing a script and would like to wait for the local network to come up with all services, you can make a GET request to http://127.0.0.1:8070
. At first this will return http code . When it returns it means all the services are ready.
You can then use that profile for any commands you want to use going forward. For example, if you wanted to publish a Move module like the package to your local network you could run:
You are building a and would like to index using a fresh network.