Skip to content

Configuration ​

Orbis1SDK accepts a single SDKConfig object validated by Zod at construction time. Invalid config throws ConfigurationError immediately.

Full reference ​

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

const keys = await generateKeys(BitcoinNetwork.TESTNET4);

const sdk = new Orbis1SDK({
  // ── Required ──────────────────────────────────────────────────────────────
  apiKey: 'pk_test_your_key',            // pk_test_... or sk_live_...
  environment: Environment.TESTNET4,      // TESTNET4 | MAINNET | REGTEST

  // ── Wallet ────────────────────────────────────────────────────────────────
  wallet: {
    enabled: true,
    keys,
    dataDir: `${RNFS.DocumentDirectoryPath}/wallet-data`,  // optional: defaults to app documents directory
    supportedSchemas: [AssetSchema.NIA, AssetSchema.CFA, AssetSchema.UDA],
    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,
      // Note: pollingInterval is accepted by validation but background polling
      // is not currently implemented. Call addToWatchTower() explicitly.
    },
  },

  // ── Logging ───────────────────────────────────────────────────────────────
  logging: {
    level: LogLevel.INFO,
    logger: (level, message, ...args) => myAppLogger[level]?.(message, ...args),
  },

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

SDKConfig fields ​

Top-level ​

FieldTypeRequiredDefaultDescription
apiKeystring✅—API key
environmentEnvironment✅—Target network
walletWalletConfig—Wallet configuration
featuresFeaturesConfig{}Feature toggles
loggingLoggingConfig{ level: 'info' }Logging
optionsOptionsConfig{}Behaviour flags

wallet ​

FieldTypeRequiredDefaultDescription
enabledboolean✅—Must be true to activate
keysKeys✅—Mnemonic, xpubs, fingerprint
dataDirstringApp documents directoryAbsolute path where wallet data is stored. Defaults to app's documents directory.
supportedSchemasAssetSchema[][CFA, NIA, UDA]Asset schemas to track
maxAllocationsPerUtxonumber1RGB allocations per UTXO
vanillaKeychainnumber0Keychain index for 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

LogLevel enum ​

ValueOutput
NONESilent
ERRORErrors only
WARNWarnings + errors
INFONormal operation
DEBUGVerbose debug (recommended for development)
VERBOSEAll messages

Environment enum ​

ValueNetworkRequired key prefix
TESTNET4Bitcoin Testnet4pk_test_
REGTESTLocal regtestpk_test_
MAINNETBitcoin Mainnetsk_live_

Wallet data storage ​

Default location ​

If wallet.dataDir is not specified, wallet data is stored in the app's documents directory (platform-specific):

  • iOS: NSDocumentDirectory
  • Android: Context.getFilesDir()

This ensures wallet data:

  • ✅ Persists across app updates
  • ✅ Is backed up (iOS)
  • ✅ Survives cache clearing

Custom location ​

For explicit control, use react-native-fs:

bash
yarn add react-native-fs
typescript
import RNFS from 'react-native-fs';

const sdk = new Orbis1SDK({
  apiKey: 'your-key',
  environment: Environment.TESTNET4,
  wallet: {
    enabled: true,
    keys,
    dataDir: `${RNFS.DocumentDirectoryPath}/wallet-data`,
  },
});

Available paths:

  • RNFS.DocumentDirectoryPath - App documents (default, backed up on iOS)
  • RNFS.CachesDirectoryPath - Temporary cache (can be cleared by system)
  • RNFS.LibraryDirectoryPath - iOS library directory

TIP

For most apps, the default location (documents directory) is appropriate.

Feature guard ​

Accessing a disabled feature accessor throws FeatureNotEnabledError:

typescript
sdk.gasFree();      // throws if gasFree.enabled !== true
sdk.watchTower();   // throws if watchTower.enabled !== true

Gas-Free dependencies ​

Gas-Free requires:

  • wallet.enabled: true (throws OrbisError otherwise)
  • environment !== REGTEST (throws OrbisError otherwise)

Released under the MIT License.