The config.json file organizes all your BitGo credentials by environment and coin:
{
"environment": {
"coin": {
"accessToken": "...",
"walletId": "...",
"walletPassphrase": "...",
"otp": "...",
"enterpriseId": "..."
}
}
}{
"test": {
"tbtc": {
"accessToken": "v2xc00d469e22c1ccd2e73e9d5c3d8bdfa8f549e191c8f4e38633cb8f36c68126d7",
"walletId": "67b4c23549295a1c015189732e9d4d85",
"walletPassphrase": "GQZyI10zi3jQ",
"otp": "000000",
"enterpriseId": "63869330a084ba0007172450e20fbb5f"
},
"gteth": {
"accessToken": "v2xc00d469e22c1ccd2e73e9d5c3d8bdfa8f549e191c8f4e38633cb8f36c68126d7",
"walletId": "608f6e3374b930386277867deadbeef",
"walletPassphrase": "GQZyI10zi3jQ"
},
"talgo": {
"accessToken": "v2xc00d469e22c1ccd2e73e9d5c3d8bdfa8f549e191c8f4e38633cb8f36c68126d7",
"walletId": "623a8e3fd3db7000089919797d8e9d8b",
"walletPassphrase": "GQZyI10zi3jQ"
},
"tlnbtc": {
"accessToken": "v2xc00d469e22c1ccd2e73e9d5c3d8bdfa8f549e191c8f4e38633cb8f36c68126d7",
"walletId": "68e3f85ba3d7c96a4b6988b1cdeadbeef",
"walletId2": "68e3f85ba3d7c96a4b6988b1c12345678",
"walletPassphrase": "GQZyI10zi3jQ"
}
},
"staging": {
"tbtcsig": {
"accessToken": "v2xd55e5e283ce5ff872aacd6de5a2001d521a0a003dad19bdd8f4619eb06d9075c",
"walletId": "6536d2b677de640007639c81a4a24c69",
"walletPassphrase": "GQZyI10zi3jQ"
},
"teos": {
"accessToken": "v2xd55e5e283ce5ff872aacd6de5a2001d521a0a003dad19bdd8f4619eb06d9075c",
"walletId": "6536d2b677de640007639c81deadbeef",
"walletPassphrase": "GQZyI10zi3jQ"
}
},
"prod": {
"btc": {
"accessToken": "v2x50d10c52923393baf037884aef126e81f7e40c2993cf097393dcf35fce66c9d5",
"walletId": "642ca4993408b800074757c9e0d668a0",
"walletPassphrase": "EV&7fOVAD$!P1Cw*kMgO",
"enterpriseId": "63869330a084ba0007172450e20fbb5f"
},
"eth": {
"accessToken": "v2x50d10c52923393baf037884aef126e81f7e40c2993cf097393dcf35fce66c9d5",
"walletId": "642ca4993408b800074757c9deadbeef",
"walletPassphrase": "EV&7fOVAD$!P1Cw*kMgO"
}
},
"custom": {
"tbtc": {
"accessToken": "v2x...",
"walletId": "63b4ca74b1f7950007eeb3ed99d43434",
"walletPassphrase": "Ghghjkg!455544llll",
"customRootUri": "https://app.custom-bitgo.com",
"customBitcoinNetwork": "testnet"
}
}
}# Test Bitcoin
BITGO_COIN=tbtc BITGO_ENV=test yarn bitgo-dev balance
# Test Ethereum
BITGO_COIN=gteth BITGO_ENV=test yarn bitgo-dev balance
# Test Algorand
BITGO_COIN=talgo BITGO_ENV=test yarn bitgo-dev balance# Test environment
BITGO_ENV=test BITGO_COIN=tbtc yarn bitgo-dev balance
# Staging environment
BITGO_ENV=staging BITGO_COIN=tbtcsig yarn bitgo-dev balance
# Production environment (be careful!)
BITGO_ENV=prod BITGO_COIN=btc yarn bitgo-dev balanceEven with config.json, you can override specific values:
# Use config.json for most settings, but override wallet ID
BITGO_COIN=tbtc BITGO_WALLET_ID=<different_wallet> yarn bitgo-dev balance
# Override access token for one-off test
BITGO_COIN=tbtc BITGO_ACCESS_TOKEN=<temp_token> yarn bitgo-dev balanceSettings are loaded in this order (later overrides earlier):
- config.json - Base configuration file
- .env file - Environment file (if present)
- Environment variables - Command-line overrides
Example:
# config.json has: test.tbtc.walletId = "abc123"
# .env has: BITGO_WALLET_ID=def456
# Command line has: BITGO_WALLET_ID=ghi789
# Final value used: "ghi789" (command line wins)accessToken- Your BitGo access token
walletId- Default wallet ID (required for most commands)walletPassphrase- For signing operations
otp- OTP code (for sensitive operations)enterpriseId- For wallet creationwalletId2- Secondary wallet (e.g., for lightning)customRootUri- Custom BitGo API endpointcustomBitcoinNetwork- Custom Bitcoin network
Lightning coins need both walletId and walletId2:
{
"test": {
"tlnbtc": {
"accessToken": "...",
"walletId": "primary-lightning-wallet",
"walletId2": "secondary-lightning-wallet",
"walletPassphrase": "..."
}
}
}For custom BitGo instances:
{
"custom": {
"tbtc": {
"accessToken": "...",
"walletId": "...",
"customRootUri": "https://app.custom-bitgo.com",
"customBitcoinNetwork": "testnet"
}
}
}If you have existing .env files, you can keep them alongside config.json:
- config.json - Stores all your coins/environments
- .env - Can override defaults (BITGO_ENV, BITGO_COIN)
Example .env:
# Default to test environment and tbtc
BITGO_ENV=test
BITGO_COIN=tbtcThen just switch coins:
BITGO_COIN=gteth yarn bitgo-dev balance # Uses test env from .env{
"test": {
"tbtc": { /* for general testing */ },
"tbtc-integration": { /* for integration tests */ },
"tbtc-dev": { /* for local development */ }
}
}For security, use different access tokens for test/staging/prod:
{
"test": { "tbtc": { "accessToken": "test-token-..." } },
"prod": { "btc": { "accessToken": "prod-token-..." } }
}Add to your .bashrc or .zshrc:
# Switch to staging
bgstaging() {
export BITGO_ENV=staging
export BITGO_COIN=${1:-tbtcsig}
}
# Switch to prod
bgprod() {
export BITGO_ENV=prod
export BITGO_COIN=${1:-btc}
}
# Usage:
# bgstaging teos
# yarn bitgo-dev balance- Never commit
config.jsonto git (it's in.gitignore) - Keep production credentials separate
- Use read-only tokens when possible
- Rotate tokens regularly
- Consider using different access tokens per environment
- Check that you have
config.jsonwith the right structure - Verify the environment and coin names match exactly
- Try:
BITGO_ENV=test BITGO_COIN=tbtc yarn bitgo-dev balance
- Add
walletIdto your config.json entry - Or pass via:
BITGO_WALLET_ID=... yarn bitgo-dev balance
- Verify
config.jsonis valid JSON - Check file is in
modules/dev-cli/config.json - Look for warnings when running commands