Skip to content

Configuration

The SDK needs to know which Algorand network you’re targeting. It uses a priority-based resolution:

  1. Explicit callsetCurrentNetwork('testnet')
  2. Environment variableALGORAND_NETWORK=testnet
  3. URL detection — Infers from the AlgorandClient’s algod URL

Recommended approach — call setCurrentNetwork() at app startup:

import { setCurrentNetwork } from '@akta/sdk'
setCurrentNetwork('mainnet')

Environment variable — works in Node.js and with Next.js:

Terminal window
# Standard
ALGORAND_NETWORK=testnet
# Next.js client-side alternatives
NEXT_PUBLIC_ALGORAND_NETWORK=testnet
NEXT_PUBLIC_ALGOD_NETWORK=testnet

Auto-detection — the SDK can infer the network from your AlgorandClient’s URL:

import { AlgorandClient } from '@algorandfoundation/algokit-utils'
// The SDK detects "testnet" from the URL
const algorand = AlgorandClient.testNet()

Detection patterns:

NetworkURL patterns
mainnetmainnet, algonode.io, mainnet-api.algonode.cloud
testnettestnet, testnet-api.algonode.cloud
localnetlocalhost, 127.0.0.1, :4001

Every SDK class needs an application ID. The SDK resolves it through a fallback chain:

  1. Constructor parameter — explicitly passed appId
  2. Environment variable — e.g. DAO_APP_ID=3368388956
  3. Baked-in network IDs — testnet and mainnet app IDs are built into the SDK

For testnet and mainnet, you don’t need to configure anything:

import { setCurrentNetwork, AkitaDaoSDK } from '@akta/sdk'
setCurrentNetwork('mainnet')
// App ID resolves to mainnet DAO: 3368388956
const dao = new AkitaDaoSDK({ algorand })

Override the auto-resolved ID:

const dao = new AkitaDaoSDK({
algorand,
factoryParams: { appId: 123456n }
})

Set app IDs through environment variables. This is useful for localnet or when overriding defaults:

Terminal window
# Core contracts
DAO_APP_ID=3368388956
WALLET_APP_ID=3368395481
STAKING_APP_ID=3368393172
REWARDS_APP_ID=3368388985
SUBSCRIPTIONS_APP_ID=3368389628
ESCROW_FACTORY_APP_ID=3368388829
WALLET_FACTORY_APP_ID=3368389117
STAKING_POOL_FACTORY_APP_ID=3368391029
# Social
SOCIAL_APP_ID=3368393551
SOCIAL_GRAPH_APP_ID=3414941676
SOCIAL_IMPACT_APP_ID=3368393419
SOCIAL_MODERATION_APP_ID=3368393629
# Factories
AUCTION_FACTORY_APP_ID=3368393933
MARKETPLACE_APP_ID=3368394180
RAFFLE_FACTORY_APP_ID=3368394210
POLL_FACTORY_APP_ID=3368394268
PRIZE_BOX_FACTORY_APP_ID=3368394289
# Gates & Other
GATE_APP_ID=3368394436
HYPER_SWAP_APP_ID=3368394471
META_MERKLES_APP_ID=3368394372
# Assets
AKTA_ASSET_ID=523683256
BONES_ASSET_ID=3368406527

For advanced use, load all config at once:

import { getConfigFromEnv } from '@akta/sdk'
const config = getConfigFromEnv()
// Returns: { network, daoAppId, walletAppId, stakingAppId, ... }

In browsers without process.env, set config on window:

window.__AKITA_ENV__ = {
ALGORAND_NETWORK: 'mainnet',
DAO_APP_ID: '3368388956',
}

The SDK’s getEnvVar() checks window.__AKITA_ENV__ as a fallback.

You can access the full set of app IDs for any network:

import { getNetworkAppIds, MAINNET_APP_IDS, TESTNET_APP_IDS } from '@akta/sdk'
const mainnet = getNetworkAppIds('mainnet')
console.log(mainnet.dao) // 3368388956n
console.log(mainnet.wallet) // 3368395481n
console.log(mainnet.staking) // 3368393172n

See the full App IDs reference for all testnet and mainnet IDs.