To set up a local development environment for the TRUF.NETWORK, follow these steps:

Prerequisites

Ensure the following tools are installed on your system:

  1. Go: Download and install Go.
  2. Taskfile: Install Taskfile.
  3. Docker Compose: Install Docker Compose.
  4. Python (optional, for running seed scripts): Download Python.
  5. Pandas (optional, for running seed scripts): Install Pandas.

Building Locally

You can build and run the TRUF-Node using Docker Compose or manually.

Using Docker Compose (Recommended)

  1. Clone the TN repository:
git clone https://github.com/trufnetwork/node.git
cd node
  1. Build and start the TRUF-Node containers:
task single:start

This command builds and starts the TRUF-Node in Docker containers with pre-seeded data.

Manual Build and Run

  1. Build the Binary:
task build

This compiles the TRUF-Node binary, which will be located in the .build/ directory.

  1. Run PostgreSQL:

Start PostgreSQL using Docker:

task postgres
  1. Run TRUF-Node:

Start a single-node network:

task kwild
  1. Configure kwil-cli:

Set up kwil-cli to interact with TRUF-Node:

kwil-cli configure

Provide the following values when prompted:

  • Kwil RPC URL: http://localhost:8484
  • Kwil Chain ID: tn-v2
  • Private Key: (any Ethereum private key)

For testing purposes, you can use the private key 0000000000000000000000000000000000000000000000000000000000000001.

Running the Kwil Gateway (Optional)

The Kwil Gateway (KGW) is a load-balancer with authentication capabilities, enabling data privacy protection for Proof of Authority (POA) Kwil blockchain networks. While not required for development, you can run it locally:

  1. Navigate to the deployments/dev-gateway directory:
cd deployments/dev-gateway
  1. Follow the instructions in the README.md file to set up and run the gateway.

Running the Indexer

The indexer collects and processes data from the TN-DB. To start the indexer:

task indexer

Access the metrics dashboard at http://localhost:1337/v0/swagger.

Fetching the Genesis File

The genesis file contains the initial configuration for the TN network. To fetch the latest genesis file:

  1. Ensure you have read access to the repository.
  2. Create a .env file in the root directory, similar to .env.example, and include your GitHub token.
  3. Run the following command:
task get-genesis

Metrics and Monitoring

When running the development setup using task compose-dev, the following monitoring tools are available:

  • Prometheus: Accessible at http://localhost:9090
  • Grafana: Accessible at http://localhost:3000 (default credentials: admin/admin)

These tools provide insights into the performance and behavior of the TN-DB system.

For more details on metrics configuration, refer to the files in the deployments/dev-gateway directory.

Additional Resources

For further assistance, join our Discord community or open an issue on our GitHub repository.