This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Examples

The examples section provides information on some examples of how Solo can be used and leveraged.

The usage of examples in Solo

Table of Contents

Example DirectoryDescription
address-bookExample of using Yahcli to pull the ledger and mirror node address book
custom-network-configDeploy a Solo network with custom configuration settings (log4j2, properties, etc.)
external-database-testDeploy a Solo network with an external PostgreSQL database
network-with-block-nodeDeploy a Solo network that includes a block node
network-with-domain-namesSetup a network using custom domain names for all components
node-create-transactionManually write a NodeCreateTransaction and use the add-prepare/prepare-upgrade/freeze-upgrade/add-execute commands.
node-delete-transactionManually write a NodeDeleteTransaction and use the add-prepare/prepare-upgrade/freeze-upgrade/add-execute commands.
node-update-transactionManually write a NodeUpdateTransaction and use the add-prepare/prepare-upgrade/freeze-upgrade/add-execute commands.
running-solo-inside-clusterExample showing how to run Solo inside a Kubernetes cluster

Prerequisites

  • install taskfile: npm install -g @go-task/cli

Running the examples with Taskfile

  • cd into the directory under examples that has the Taskfile.yml, e.g. (from solo repo root directory) cd examples/network-with-block-node/
  • make sure that your current kubeconfig context is pointing to the cluster that you want to deploy to
  • run task which will do the rest and deploy the network and take care of many of the pre-requisites

NOTES:

  • Some of these examples are for running against large clusters with a lot of resources available.
  • Edit the values of the variables as needed.

Customizing the examples

  • take a look at the Taskfile.yml sitting in the subdirectory for the deployment you want to run
  • make sure your cluster can handle the number in SOLO_NETWORK_SIZE, if not, then you will have to update that and make it match the number of nodes in the init-containers-values.yaml: hedera.nodes[]
  • take a look at the init-containers-values.yaml file and make sure the values are correct for your deployment with special attention to:
    • resources
    • nodeSelector
    • tolerations

1 - Node Create Transaction Example

Using Solo with a custom NodeCreateTransaction from an SDK call

Node Create Transaction Example

This example demonstrates how to use the node add-prepare/prepare-upgrade/freeze-upgrade/add-execute commands against a network in order to manually write a NodeCreateTransaction.

What It Does

  • Stands up a network with two existing nodes
  • Runs solo node add-prepare to get artifacts needed for the SDK NodeCreateTransaction
  • Runs a JavaScript program using the Hiero SDK JS code to run a NodeCreateTransaction
  • Runs solo node prepare-upgrade and solo node freeze-upgrade to put the network into a freeze state
  • Runs solo node add-execute to add network resources for a third consensus node, configures it, then restarts the network to come out of the freeze and leverage the new node
  • Contains the destroy commands to bring down the network if desired

How to Use

  1. Install dependencies:
    • Make sure you have Task, Node.js, npm, kubectl, and kind installed.
    • Run npm install while in this directory so that the solo-node-create-transaction.js script will work correctly when ran
  2. Choose your Solo command:
    • Edit Taskfile.yml and comment out/uncomment depending on if you want to run Solo checked out of the repository or running Solo with an NPM install
      • SOLO_COMMAND: "npm run solo --": use this if running with solo source repository
      • SOLO_COMMAND: "solo": use this if running with installed version of Solo
  3. Provide your custom application.properties if desired:
    • The following code is provided as an example and can be modified:
          # Copy and update application.properties
          cp resources/templates/application.properties {{ .APPLICATION_PROPERTIES }}
          echo "contracts.evm.ethTransaction.zeroHapiFees.enabled=false" >> {{ .APPLICATION_PROPERTIES }}
      
    • resources/templates/application.properties is the location of the Solo customized application.properties if you are sitting in the root of the Solo repository directory
    • You can download a copy here: https://github.com/hiero-ledger/solo/blob/main/resources/templates/application.properties
    • If you want you can download a copy, add your configurations, (be careful changing existing configurations as it could break Solo’s network), and then update the variable at the top to point to the new location: APPLICATION_PROPERTIES: "{{ .TEMPORARY_DIR }}/application.properties"
  4. CN_VERSION:
    • The following is only used for certain decision logic. It is best to have it as close to possible as the local build you are using of consensus node: CN_VERSION: "v0.64.2"
    • The script is configured to leverage a local build of the Consensus Node, for example the main branch. You will need to clone the Hiero Consensus Node yourself and then from its root directory run ./gradlew assemble, this assumes you have all its prerequisites configured, see: https://github.com/hiero-ledger/hiero-consensus-node/blob/main/docs/README.md
  5. Updating Directory Locations
    • The script was designed to run from this directory and so if you copy down the example without the repository or change other locations you might need to make changes
    • The dir: ../.. setting says to run the script two directories above, CN_LOCAL_BUILD_PATH can be updated to be relative to that, or can be changed to have the full path to the consensus node directory
    • The CN_LOCAL_BUILD_PATH actually points to the <hiero-consensus-node>/hedera-node/data, this is because this is the location of the artifacts that Solo needs to upload to the network node
  6. Run the default workflow:
    • From this directory, run:
      task
      
    • This will:
      • Install the Solo CLI
      • Create a Kind cluster
      • Set the kubectl context
      • Initialize Solo
      • Connect and set up the cluster reference
      • Create and configure the deployment
      • Add the cluster to the deployment
      • Generate node keys
      • Deploy the network with custom configuration files
      • Set up and start nodes
      • Deploy mirror node, relay, and explorer
      • Perform the node add as described in the ‘What It Does’ section above
  7. Destroy the network:
    • Run:
      task destroy
      
    • This will:
      • Stop all nodes
      • Destroy mirror node, relay, and explorer
      • Destroy the Solo network
      • Delete the Kind cluster

Files

  • Taskfile.yml — All automation tasks and configuration
  • package.json - Contains the libraries for the solo-node-create-transaction.js to function
  • package-lock.json - A snapshot of what was last used when npm install was ran, run npm ci to install these versions specifically
  • solo-node-create-transaction.js - The script to run the Hiero SDK JS calls

Notes

  • This example is self-contained and does not require files from outside this directory.
  • All steps in the workflow are named for clear logging and troubleshooting.
  • You can extend the Taskfile to add more custom resources or steps as needed.
  • For more advanced usage, see the main Solo documentation.

2 - Node Delete Transaction Example

Using Solo with a custom NodeDeleteTransaction from an SDK call

Node Delete Transaction Example

This example demonstrates how to use the node add-prepare/prepare-upgrade/freeze-upgrade/add-execute commands against a network in order to manually write a NodeDeleteTransaction.

What It Does

  • Stands up a network with two existing nodes
  • Runs solo node delete-prepare to get artifacts needed for the SDK NodeDeleteTransaction
  • Runs a JavaScript program using the Hiero SDK JS code to run a NodeDeleteTransaction
  • Runs solo node prepare-upgrade and solo node freeze-upgrade to put the network into a freeze state
  • Runs solo node delete-execute to configure the network to stop using the deleted node, then restarts the network to come out of the freeze and run with the new configurations
  • Contains the destroy commands to bring down the network if desired

How to Use

  1. Install dependencies:
    • Make sure you have Task, Node.js, npm, kubectl, and kind installed.
    • Run npm install while in this directory so that the solo-node-delete-transaction.js script will work correctly when ran
  2. Choose your Solo command:
    • Edit Taskfile.yml and comment out/uncomment depending on if you want to run Solo checked out of the repository or running Solo with an NPM install
      • SOLO_COMMAND: "npm run solo --": use this if running with solo source repository
      • SOLO_COMMAND: "solo": use this if running with installed version of Solo
  3. Provide your custom application.properties if desired:
    • The following code is provided as an example and can be modified:
          # Copy and update application.properties
          cp resources/templates/application.properties {{ .APPLICATION_PROPERTIES }}
          echo "contracts.evm.ethTransaction.zeroHapiFees.enabled=false" >> {{ .APPLICATION_PROPERTIES }}
      
    • resources/templates/application.properties is the location of the Solo customized application.properties if you are sitting in the root of the Solo repository directory
    • You can download a copy here: https://github.com/hiero-ledger/solo/blob/main/resources/templates/application.properties
    • If you want you can download a copy, add your configurations, (be careful changing existing configurations as it could break Solo’s network), and then update the variable at the top to point to the new location: APPLICATION_PROPERTIES: "{{ .TEMPORARY_DIR }}/application.properties"
  4. CN_VERSION:
    • The following is only used for certain decision logic. It is best to have it as close to possible as the local build you are using of consensus node: CN_VERSION: "v0.64.2"
    • The script is configured to leverage a local build of the Consensus Node, for example the main branch. You will need to clone the Hiero Consensus Node yourself and then from its root directory run ./gradlew assemble, this assumes you have all its prerequisites configured, see: https://github.com/hiero-ledger/hiero-consensus-node/blob/main/docs/README.md
  5. Updating Directory Locations
    • The script was designed to run from this directory and so if you copy down the example without the repository or change other locations you might need to make changes
    • The dir: ../.. setting says to run the script two directories above, CN_LOCAL_BUILD_PATH can be updated to be relative to that, or can be changed to have the full path to the consensus node directory
    • The CN_LOCAL_BUILD_PATH actually points to the <hiero-consensus-node>/hedera-node/data, this is because this is the location of the artifacts that Solo needs to upload to the network node
  6. Run the default workflow:
    • From this directory, run:
      task
      
    • This will:
      • Install the Solo CLI
      • Create a Kind cluster
      • Set the kubectl context
      • Initialize Solo
      • Connect and set up the cluster reference
      • Create and configure the deployment
      • Add the cluster to the deployment
      • Generate node keys
      • Deploy the network with custom configuration files
      • Set up and start nodes
      • Deploy mirror node, relay, and explorer
      • Perform the node delete as described in the ‘What It Does’ section above
  7. Destroy the network:
    • Run:
      task destroy
      
    • This will:
      • Stop all nodes
      • Destroy mirror node, relay, and explorer
      • Destroy the Solo network
      • Delete the Kind cluster

Files

  • Taskfile.yml — All automation tasks and configuration
  • package.json - Contains the libraries for the solo-node-delete-transaction.js to function
  • package-lock.json - A snapshot of what was last used when npm install was ran, run npm ci to install these versions specifically
  • solo-node-delete-transaction.js - The script to run the Hiero SDK JS calls

Notes

  • This example is self-contained and does not require files from outside this directory.
  • All steps in the workflow are named for clear logging and troubleshooting.
  • You can extend the Taskfile to add more custom resources or steps as needed.
  • For more advanced usage, see the main Solo documentation.

3 - Node Update Transaction Example

Using Solo with a custom NodeUpdateTransaction from an SDK call

Node Update Transaction Example

This example demonstrates how to use the node add-prepare/prepare-upgrade/freeze-upgrade/add-execute commands against a network in order to manually write a NodeUpdateTransaction.

What It Does

  • Stands up a network with two existing nodes
  • Runs solo node update-prepare to get artifacts needed for the SDK NodeUpdateTransaction
  • Runs a JavaScript program using the Hiero SDK JS code to run a NodeUpdateTransaction
  • Runs solo node prepare-upgrade and solo node freeze-upgrade to put the network into a freeze state
  • Runs solo node update-execute to update network resources for the changes to the updated node, then restarts the network to come out of the freeze and leverage the changes
  • Contains the destroy commands to bring down the network if desired

How to Use

  1. Install dependencies:
    • Make sure you have Task, Node.js, npm, kubectl, and kind installed.
    • Run npm install while in this directory so that the solo-node-update-transaction.js script will work correctly when ran
  2. Choose your Solo command:
    • Edit Taskfile.yml and comment out/uncomment depending on if you want to run Solo checked out of the repository or running Solo with an NPM install
      • SOLO_COMMAND: "npm run solo --": use this if running with solo source repository
      • SOLO_COMMAND: "solo": use this if running with installed version of Solo
  3. Provide your custom application.properties if desired:
    • The following code is provided as an example and can be modified:
          # Copy and update application.properties
          cp resources/templates/application.properties {{ .APPLICATION_PROPERTIES }}
          echo "contracts.evm.ethTransaction.zeroHapiFees.enabled=false" >> {{ .APPLICATION_PROPERTIES }}
      
    • resources/templates/application.properties is the location of the Solo customized application.properties if you are sitting in the root of the Solo repository directory
    • You can download a copy here: https://github.com/hiero-ledger/solo/blob/main/resources/templates/application.properties
    • If you want you can download a copy, add your configurations, (be careful changing existing configurations as it could break Solo’s network), and then update the variable at the top to point to the new location: APPLICATION_PROPERTIES: "{{ .TEMPORARY_DIR }}/application.properties"
  4. CN_VERSION:
    • The following is only used for certain decision logic. It is best to have it as close to possible as the local build you are using of consensus node: CN_VERSION: "v0.64.2"
    • The script is configured to leverage a local build of the Consensus Node, for example the main branch. You will need to clone the Hiero Consensus Node yourself and then from its root directory run ./gradlew assemble, this assumes you have all its prerequisites configured, see: https://github.com/hiero-ledger/hiero-consensus-node/blob/main/docs/README.md
  5. Updating Directory Locations
    • The script was designed to run from this directory and so if you copy down the example without the repository or change other locations you might need to make changes
    • The dir: ../.. setting says to run the script two directories above, CN_LOCAL_BUILD_PATH can be updated to be relative to that, or can be changed to have the full path to the consensus node directory
    • The CN_LOCAL_BUILD_PATH actually points to the <hiero-consensus-node>/hedera-node/data, this is because this is the location of the artifacts that Solo needs to upload to the network node
  6. Run the default workflow:
    • From this directory, run:
      task
      
    • This will:
      • Install the Solo CLI
      • Create a Kind cluster
      • Set the kubectl context
      • Initialize Solo
      • Connect and set up the cluster reference
      • Create and configure the deployment
      • Add the cluster to the deployment
      • Generate node keys
      • Deploy the network with custom configuration files
      • Set up and start nodes
      • Deploy mirror node, relay, and explorer
      • Perform the node update as described in the ‘What It Does’ section above
  7. Destroy the network:
    • Run:
      task destroy
      
    • This will:
      • Stop all nodes
      • Destroy mirror node, relay, and explorer
      • Destroy the Solo network
      • Delete the Kind cluster

Files

  • Taskfile.yml — All automation tasks and configuration
  • package.json - Contains the libraries for the solo-node-update-transaction.js to function
  • package-lock.json - A snapshot of what was last used when npm install was ran, run npm ci to install these versions specifically
  • solo-node-update-transaction.js - The script to run the Hiero SDK JS calls

Notes

  • This example is self-contained and does not require files from outside this directory.
  • All steps in the workflow are named for clear logging and troubleshooting.
  • You can extend the Taskfile to add more custom resources or steps as needed.
  • For more advanced usage, see the main Solo documentation.