Skip to content

Add environment variable support for TRP client in trix bindgen #51

@rodrigomd94

Description

@rodrigomd94

Problem

Currently, when using trix bindgen to generate client code, the TRP endpoint URL is hardcoded in the generated Client (based on the trix.toml config). This creates challenges when you need different endpoints for different environments (e.g., local development vs production deployment).

Current Workarounds

  1. Manually edit the generated Client code after running trix bindgen (not ideal for automation, particularly because these files are regenerated whenever the tx3 file is edited)
  2. Replace URLs and regenerate bindings in CI/CD pipeline before deployment (adds complexity)

Proposed Solution

Add configuration support for environment variables in the TRP profile configuration. This would allow the generated code to read endpoints from environment variables at runtime.

Suggested config format:

[profiles.devnet.trp]
use_env = true

[profiles.devnet.trp.env]
trp_endpoint = "NEXT_PUBLIC_TRP_ENDPOINT"

Use Case

  • Local development: Use local TRP endpoint (e.g., http://localhost:8080)
  • Production deployment: Use production TRP endpoint via environment variable
  • Multiple environments: Easily switch between staging, production, etc. without code changes

Expected Behavior

When use_env = true is set, the generated client code should read the TRP endpoint from the specified environment variable instead of using a hardcoded URL.

It would look something like this:

export const DEFAULT_TRP_ENDPOINT = process.env.NEXT_PUBLIC_TRP_ENDPOINT || "http://localhost:8164";

(or warn about missing env variables)

This would eliminate the need for manual code editing or complex CI/CD URL replacement steps.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions