Matrix logo

Config

Runtime configuration uses the .kvx format with environment variable precedence. It controls the API address, project paths, wallet mode, policy profiles, and chain definitions.

Source files: internal/config/config.go, internal/config/kvx.go

Runtime configuration is loaded with precedence: environment variables > tachyon.config.kvx > defaults. A .env file in the working directory is loaded when present.


Design decisions

KVX format

The config file uses a simple INI-like .kvx format with section.key = value syntax. Sections are dot-separated (e.g., wallet.self_hosted, policy.default, chains.paxeer-mainnet).

Precedence chain

Every config value follows the same precedence:

  1. Environment variable (highest priority)
  2. tachyon.config.kvx value
  3. Hardcoded default (lowest priority)

The pick(envKey, kvxVal, fallback) function implements this consistently.

.env file loading

When a .env file exists in the working directory, it is loaded before config parsing. Only KEY=VALUE lines are processed; comments (#) and blank lines are skipped. Quoted values are trimmed. Existing environment variables are not overwritten.

Foundry root detection

findFoundryRoot walks up to 12 parent directories from ProjectRoot looking for foundry.toml. When found, it becomes the effective project root. This lets the daemon auto-detect the project root when launched from a subdirectory.


Config struct

type Config struct {
    APIAddr      string                    // default ":8645"
    ProjectRoot  string                    // default "." (resolved to cwd)
    ArtifactsDir string                    // default "artifacts"
    RegistryPath string                    // default "registry.json"
    SolcPath     string                    // default "" (forge finds it)
    ForgePath    string                    // default "forge"
    AuthToken    string                    // default "" (auth disabled)

    Wallet   WalletConfig
    Policies map[string]PolicyProfile
    Chains   []ChainConfig
}

WalletConfig

type WalletConfig struct {
    Mode             string // "" | "self_hosted" | "embedded"
    Signer           string // "raw" | "keystore" | "env"
    PrivateKey       string // hex key (SignerRaw/SignerEnv)
    KeystorePath     string // geth v3 JSON path (SignerKeystore)
    KeystorePassword string
    Keyfile          string // ed25519 seed path (embedded mode)
    Label            string // DID label, default "executor"
    API              string // embedded wallet base URL
}

PolicyProfile

type PolicyProfile struct {
    Name        string
    SpendCapWei string
    Allow       []string   // contract addresses
    Chains      []string   // chain ids
}

ChainConfig

type ChainConfig struct {
    ID       string
    Name     string
    RPCURL   string
    ChainID  uint64
    Explorer string
}

Environment variables

VariableMaps toDefault
TACHYON_CONFIGConfig file pathtachyon.config.kvx
TACHYON_API_ADDRAPIAddr:8645
TACHYON_PROJECT_ROOTProjectRoot.
TACHYON_ARTIFACTS_DIRArtifactsDirartifacts
TACHYON_REGISTRY_PATHRegistryPathregistry.json
TACHYON_SOLC_PATHSolcPath(empty)
TACHYON_FORGE_PATHForgePathforge
TACHYON_AUTH_TOKENAuthToken(empty)
TACHYON_WALLET_MODEWallet.Mode(auto-detect)
TACHYON_WALLET_SIGNERWallet.Signer(auto-detect)
TACHYON_DEV_PRIVATE_KEYWallet.PrivateKey(empty)
TACHYON_KEYSTORE_PATHWallet.KeystorePath(empty)
TACHYON_KEYSTORE_PASSWORDWallet.KeystorePassword(empty)
MATRIX_EXECUTOR_KEYWallet.Keyfile(empty)
TACHYON_AGENT_LABELWallet.Labelexecutor
PAXEER_WALLET_APIWallet.API(empty)
PAXEER_WALLET_TOKEN(auto-selects embedded mode)-

Modifying the config

What to changeWhere
Add config fieldinternal/config/config.go - Config struct + Load()
Add env variableinternal/config/config.go - pick() call in Load()
Add KVX sectioninternal/config/config.go - loadWallet/loadPolicies/loadChains
Change KVX formatinternal/config/kvx.go - parser