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:
- Environment variable (highest priority)
tachyon.config.kvxvalue- 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
| Variable | Maps to | Default |
|---|---|---|
TACHYON_CONFIG | Config file path | tachyon.config.kvx |
TACHYON_API_ADDR | APIAddr | :8645 |
TACHYON_PROJECT_ROOT | ProjectRoot | . |
TACHYON_ARTIFACTS_DIR | ArtifactsDir | artifacts |
TACHYON_REGISTRY_PATH | RegistryPath | registry.json |
TACHYON_SOLC_PATH | SolcPath | (empty) |
TACHYON_FORGE_PATH | ForgePath | forge |
TACHYON_AUTH_TOKEN | AuthToken | (empty) |
TACHYON_WALLET_MODE | Wallet.Mode | (auto-detect) |
TACHYON_WALLET_SIGNER | Wallet.Signer | (auto-detect) |
TACHYON_DEV_PRIVATE_KEY | Wallet.PrivateKey | (empty) |
TACHYON_KEYSTORE_PATH | Wallet.KeystorePath | (empty) |
TACHYON_KEYSTORE_PASSWORD | Wallet.KeystorePassword | (empty) |
MATRIX_EXECUTOR_KEY | Wallet.Keyfile | (empty) |
TACHYON_AGENT_LABEL | Wallet.Label | executor |
PAXEER_WALLET_API | Wallet.API | (empty) |
PAXEER_WALLET_TOKEN | (auto-selects embedded mode) | - |
Modifying the config
| What to change | Where |
|---|---|
| Add config field | internal/config/config.go - Config struct + Load() |
| Add env variable | internal/config/config.go - pick() call in Load() |
| Add KVX section | internal/config/config.go - loadWallet/loadPolicies/loadChains |
| Change KVX format | internal/config/kvx.go - parser |
