Using CLI to Run a Local Testnet

USING SOURCE OR DOCKER RUN A LOCAL TESTNET

If you want to use Docker or Jin-core source to start and run a local testnet, see Run a Local Testnet with Validatorarrow-up-right.

You can run a local testnet of the Jinblockchain. This local testnet will not be connected to the Aptos devnet. It will run on your local machine, independent of other Aptos networks. You can use this local testnet for testing and development purposes. A local testnet is a great tool for doing local development against a known version of the codebase without having to interact with a live network or deal with the real world costs of a live network.

JinCLI DOCUMENTATION

If you are new to Jin CLI, then see this comprehensive Jin CLI documentationarrow-up-right.

Starting a local testnet with a faucetarrow-up-right

You can start a local testnet using the following JinCLI command:

aptos node run-local-testnet --with-faucet

The above command will start a local validator node and will display a terminal output similar to the following:

Completed generating configuration:        Log file: "/Users/greg/.aptos/testnet/validator.log"        Test dir: "/Users/greg/.aptos/testnet"        Aptos root key path: "/Users/greg/.aptos/testnet/mint.key"        Waypoint: 0:74c9d14285ec19e6bd15fbe851007ea8b66efbd772f613c191aa78721cadac25        ChainId: TESTING        REST API endpoint: 0.0.0.0:8080        Fullnode network: /ip4/0.0.0.0/tcp/6181Aptos is running, press ctrl-c to exitFaucet is running.  Faucet endpoint: 0.0.0.0:8081

The above command will use the default configuration for the validator node.

DO NOT USE TWO INSTANCES OF THE SAME COMMAND AT THE SAME TIME

Note that two instances of the same command cannot run at the same time. This will result in a conflict on ports for the validator node.

Test with your local testnetarrow-up-right

You can use the JinCLI for a full range of local testnet operations. See below for how to configure the CLI first.

Configuring your Jin CLI to use the local testnetarrow-up-right

You can add a separate profile, as shown below:

and you will get an output like below. At the Enter your private key... command prompt press enter to generate a random new key.

This will create a new account and fund it with the default amount of coins, as shown below:

From now on you should add --profile local to the commands to run them on the local testnet.

Creating and funding accountsarrow-up-right

To create new accounts on the local testnet, we recommend using the above instructions with different profile names:

To fund accounts:

To create resource accounts:

Publishing modules to the local testnetarrow-up-right

You can run any command by adding the --profile $PROFILE flag. In this case, we also use $PROFILE as the named address in the HelloBlockchain example.

Resetting the local statearrow-up-right

If you updated your codebase with backwards incompatible changes, or just want to start over, you can run the command with 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.

I'm getting the error address already in use, what can I do?arrow-up-right

If you're getting an error similar to this error:

This means you are either already running a node, or you have another process running on that port.

On macOS and Linux, you can run the following command to get the name and PID of the process using the port:

Where can I get more information about the run-local-testnet command?arrow-up-right

More CLI help can be found by running the command:

which will provide information about each of the flags for the command.

Last updated