Skip to main content

Working with your running Testnet

While your Testnet is running, you can run CLI commands to update the Testnet. This is done by applying changes on the chains and off-chain actors. You can use the commands:

  • edit
  • apply

Let's explore these commands further

Configuring chains​

edit command​

While the Testnet is running, we can run the edit command and make direct changes to it.

Add​

To add a chain to a Testnet, you need 4 flags:

  • <chain-name> must be recognized by Harbor
  • artifacts-path path to your compiled contracts
  • deploy-path path to your deployed scripts
  • tag the string that identifies the current version of the chain
    • If we are updating the chain, then we must add a new tag value and run harbor apply <testnet-name>
    • Only + - = . _ : / @ are allowed as special characters

Here is a list of chain names recognized by Harbor:

So, to add a polygon chain with a certain artifacts path and deploy, run:

harbor edit <testnet-name> add polygon --artifacts-path /path/to/artifacts/ --deploy-path /path/to/deploy/ --tag polygon-tag

If you don't provide an artifacts-path, deploy-path, and tag then the command will fail.

Adding wallets​

When we add a chain, we can add one with wallets. To do so, run the following:

harbor edit <testnet-name> add ethereum --artifacts-path /path/to/artifacts/ --deploy-path /path/to/deploy/ --wallet 2 --token matic --amount 1000 --tag polygon-tag

This will add ethereum, with 2 wallets containing 1000 matic.

caution

As of November 29th, 2022:

  • If you are adding non-base tokens for anything other than the Ethereum chain, we don't support that yet
  • If you are trying to set the amount of the base token (ETH for Ethereum, AVAX for Avalanche, MATIC for Polygon, etc.), then Harbor will just automatically set the amount to the default 10,000 tokens

To see the list of all tokens supported in Ethereum, check them out here.

Update​

You can also update the attributes within a chain actor. Suppose you'd like to update the ethereum's artifactsPath with a new path:

harbor edit random-testnet-name update ethereum --artifacts-path /new/path/to/artifacts --tag <tag-name>

Make sure the new <tag-name> is different from the old tag name.

Updating chain with wallets​

We can also update an ethereum chain on a Testnet to add 3 wallets containing 1000 dai:

harbor edit random-testnet-name update ethereum --wallet 3 --token dai --amount 1000 --tag <tag-name>

As before, make sure the new <tag-name> is different.

Stop​

To stop a chain from running in a Testnet, like ethereum, then run the command below:

harbor edit random-testnet-name stop ethereum

Remove​

What if you wanted to completely remove the ethereum chain from the Testnet? To do just that, you must run:

harbor edit random-testnet-name remove ethereum

apply command​

With the apply command, we first make changes to the configuration file, and then we apply them (much like Terraform).

You can either directly edit the configuration file to add an off-chain actor, or you can leverage the configure command to add an off-chain actor.

Update the configuration file with a chain from the CLI​

harbor configure add chain <flags>

You can add the following flags:

  • artifacts-path the path to the chain's smart contract artifacts
  • chain-id is the id to be used for the chain
  • depends-on are the dependencies for the chain
  • deploy-path is the path to the chain's smart contract deploy folder
  • config specifies the location of the config file you want to modify
  • include-paths are the paths to be included while building the chain
  • name is the name of the chain. Accepted names are:
  • tag the string that identifies the current version of the chain
    • If we are updating the chain, then we must add a new tag value and run harbor apply <testnet-name>
    • Only + - = . _ : / @ are allowed as special characters
  • wallet the number of wallets
  • token the symbol(s) of coins needed. Examples are:
    • ETH
    • DAI
  • amount the number of tokens, respectively according to the order of the token symbols provided.

The artifacts-path, deploy-path, name, and tag are all mandatory flags.

To create an ethereum configuration via the CLI with 2 wallets containing 1000 MATIC and the above flags, we run:

harbor configure add chain --name ethereum --token matic --wallet 2 --amount 1000 --artifacts-path /path/to/artifacts/ --deploy-path /path/to/deploy --tag v1

Follow the next section to learn how to apply these changes.

apply the changes​

After adding your changes, through the CLI or directly, run the command

harbor apply <testnet-name> --config /path/to/harbor/config.json

Where <testnet-name> is the name of your running Testnet.

Configuring off-chain actors​

edit command​

While the Testnet is running, we can run the edit command and make direct changes to it.

Add​

To add an off-chain actor, you need to satisfy a minimum of 3 requirements:

  • <actor-name> must not be a name of a chain
  • image flag must be provided OR
  • docker-file flag along with build-path must also be provided
  • tag the string that identifies the current version of the off-chain actor
    • If we are updating the off-chain actor, then we must add a new tag value and run harbor apply <testnet-name>
    • Only + - = . _ : / @ are allowed as special characters

So to add an off-chain actor with an image, run:

harbor edit random-testnet-name add postgres1337 --image postgres --tag  postgres-tag

Otherwise, to add an off-chain actor with a Dockerfile, run:

harbor edit random-testnet-name add liquidationBot --docker-file /path/to/dockerfile --build-path /path/to/buildpath --tag liquidation-tag

Update​

You can also update the attributes within an off-chain. Suppose you'd like to update the port with an additional value of an off-chain actor:

harbor edit random-testnet-name update <actor-name> --ports <value> --tag <tag-name>

Stop​

To stop an off-chain actor from running in a Testnet, run the command below:

harbor edit random-testnet-name stop <actor-name>

Remove​

What if you wanted to completely remove an off-chain actor from a Testnet? To do just that, you must run:

harbor edit random-testnet-name remove <actor-name>

apply command​

With the apply command, we must first make changes to the configuration file, and then we apply them.

Like with adding a chain, you can either directly edit the configuration file, or you can leverage the configure command to add an off-chain actor.

Update the configuration file with an off-chain actor from the CLI​

To add an off-chain actor, you need to satisfy a minimum of 3 requirements:

  • <actor-name> must not be a name of a chain
  • image flag must be provided OR
  • docker-file flag along with build-path must also be provided
  • tag the string that identifies the current version of the off-chain actor
    • If we are updating the off-chain actor, then we must add a new tag value and run harbor apply <testnet-name>
    • Only + - = . _ : / @ are allowed as special characters

All of these flags are mandatory.

So to add an off-chain actor with an image, run:

harbor configure add off-chain-actor  --name postgres1337 --image postgres --tag  postgres-tag

Otherwise, to add an off-chain actor with a Dockerfile, run:

harbor configure add off-chain-actor --name liquidationBot --docker-file /path/to/dockerfile --build-path /path/to/buildpath --tag liquidation-tag

apply the changes​

After adding your changes, through the CLI or directly, run the command

harbor apply <testnet-name> --config /path/to/harbor/config.json

Where <testnet-name> is the name of your running Testnet.