Skip to content

Configuration ​

Orbis1SDK accepts a single SDKConfig object. Configuration is validated with Zod at construction time; invalid config throws ConfigurationError immediately.

Full reference ​

typescript
import {
  Orbis1SDK,
  Environment,
  LogLevel,
  AssetSchema,
  BitcoinNetwork,
  restoreKeys,
} from 'orbis1-sdk-node';

const keys = await restoreKeys(BitcoinNetwork.TESTNET4, process.env.MNEMONIC!);

const sdk = new Orbis1SDK({
  // ── Required ────────────────────────────────────────────────────────────
  apiKey: process.env.ORBIS_API_KEY!,       // pk_test_... or sk_live_...
  environment: Environment.TESTNET4,         // TESTNET4 | MAINNET | REGTEST

  // ── Wallet (required for Gas-Free) ──────────────────────────────────────
  wallet: {
    enabled: true,
    keys,                                    // { mnemonic, xpub, accountXpubVanilla, accountXpubColored, masterFingerprint }
    dataDir: '/var/lib/myapp/wallet-data',  // optional: defaults to .orbis1-wallet-data at project root
    supportedSchemas: [                      // default: [CFA, NIA, UDA]
      AssetSchema.NIA,
      AssetSchema.UDA,
      AssetSchema.CFA,
    ],
    maxAllocationsPerUtxo: 1,               // default: 1
    vanillaKeychain: 0,                     // default: 0
  },

  // ── Features ────────────────────────────────────────────────────────────
  features: {
    gasFree: {
      enabled: true,
      timeout: 30_000,               // HTTP timeout ms (default: 30000)
      maxRetries: 3,                 // retries on transient failure (default: 3)
      retryBaseDelay: 1_000,         // backoff start ms (default: 1000)
      retryMaxDelay: 10_000,         // backoff cap ms (default: 10000)
      retryJitter: true,             // randomise backoff (default: true)
      quoteExpirationBuffer: 30_000, // reject quote if expiring within this window ms
    },
    watchTower: {
      enabled: true,
    },
  },

  // ── Logging ─────────────────────────────────────────────────────────────
  logging: {
    level: LogLevel.INFO,                   // NONE | ERROR | WARN | INFO | DEBUG | VERBOSE
    logger: (level, message, ...args) => {  // custom logger (optional)
      myLogger[level]?.(message, ...args);
    },
  },

  // ── SDK behaviour ────────────────────────────────────────────────────────
  options: {
    strictMode: false,                      // throw on warnings (default: false)
  },
});

SDKConfig fields ​

Top-level ​

FieldTypeRequiredDefaultDescription
apiKeystring✅—API key from Orbis1 services
environmentEnvironment✅—Target network and service endpoints
walletWalletConfig—Wallet configuration; required for Gas-Free
featuresFeaturesConfig{}Enable and configure features
loggingLoggingConfig{ level: 'info' }Log level and custom logger
optionsOptionsConfig{ strictMode: false }SDK behaviour flags

wallet ​

FieldTypeRequiredDefaultDescription
enabledboolean✅—Must be true to activate wallet
keysKeys✅—Cryptographic keys (mnemonic, xpubs, fingerprint)
dataDirstring.orbis1-wallet-data at project rootAbsolute path for wallet data storage. Defaults to hidden directory at project root (alongside node_modules/) which survives cleanup
supportedSchemasAssetSchema[][CFA, NIA, UDA]Asset schemas tracked by the wallet
maxAllocationsPerUtxonumber1Max RGB allocations per UTXO
vanillaKeychainnumber0Keychain index for vanilla BTC side

features.gasFree ​

FieldTypeDefaultDescription
enabledbooleanfalseActivate Gas-Free
timeoutnumber (ms)30000HTTP timeout
maxRetriesnumber3Retry count on transient failures
retryBaseDelaynumber (ms)1000Backoff base delay
retryMaxDelaynumber (ms)10000Backoff cap
retryJitterbooleantrueRandomise backoff
quoteExpirationBuffernumber (ms)30000Reject quotes expiring soon

features.watchTower ​

FieldTypeDefaultDescription
enabledbooleanfalseActivate Watch Tower module

logging ​

FieldTypeDefaultDescription
levelLogLevelINFOMinimum log level. NONE disables all logs
loggerfunction—Replace SDK's console logger with your own

LogLevel enum ​

ValueOutput
NONESilent
ERRORErrors only
WARNWarnings + errors
INFOInfo + warnings + errors
DEBUGDebug + all above
VERBOSEAll messages

Environment enum ​

ValueNetworkService
TESTNET4Bitcoin Testnet4pk_test_... API keys
REGTESTLocal regtestpk_test_... API keys; Gas-Free unavailable
MAINNETBitcoin Mainnetsk_live_... API keys

API key rules ​

EnvironmentKey prefix
TESTNET4, REGTESTpk_test_
MAINNETsk_live_

Passing the wrong key type for the environment will produce a configuration validation error.

Wallet data storage ​

Default location ​

If wallet.dataDir is not specified, wallet data is stored in .orbis1-wallet-data/ at your project root (the directory containing node_modules/):

my-project/
  ├─ node_modules/
  │   └─ orbis1-sdk-node/
  ├─ .orbis1-wallet-data/    ← Wallet data (survives npm install)
  ├─ package.json
  └─ ...

This hidden directory:

  • ✅ Survives npm install, npm ci, and rm -rf node_modules
  • ✅ Persists across package updates
  • ✅ Stays with your project

Custom location ​

For production deployments, explicitly set dataDir:

typescript
wallet: {
  enabled: true,
  keys,
  dataDir: process.env.WALLET_DATA_DIR || '/var/lib/myapp/wallet-data',
}

Recommended paths:

  • Development: Use default (.orbis1-wallet-data at project root)
  • Production server: /var/lib/myapp/wallet-data or similar
  • User home: path.join(os.homedir(), '.myapp', 'wallet-data')
  • Current directory: path.join(process.cwd(), 'wallet-data')

WARNING

Never store wallet data inside node_modules/ as it will be deleted during package cleanup.

Feature guard ​

Accessing a feature that was not enabled in config throws FeatureNotEnabledError:

typescript
// Config has gasFree.enabled = false (or omitted)
sdk.gasFree();  // throws FeatureNotEnabledError

// Fix: enable gas-free in SDKConfig.features
features: { gasFree: { enabled: true } }

Gas-Free and Wallet dependency ​

Gas-Free requires a Wallet instance. If wallet.enabled is not true, SDK initialization will throw:

OrbisError: Gas-Free feature requires Wallet instance.

Gas-Free is also not available in REGTEST:

OrbisError: Gas-Free is not available in REGTEST yet.

Released under the MIT License.