Complete API reference for cycles management and monitoring
getBalance(canisterId)
canisterId
: Principal | string
- Canister to queryPromise<ICyclesBalance>
canisterId
: Principal
- Canister IDbalance
: bigint
- Current cycles balancestatus
: string
- Canister statusfreezingThreshold
: bigint
- Freezing threshold in secondsmemorySize
: bigint
- Memory usageidle_cycles_burned_per_day
: bigint
- Daily cycles burn ratetopUp(canisterId, amount?, options?)
canisterId
: Principal | string
- Canister to top upamount
(optional): bigint | string
- Cycles amount (default: 2T)options
(optional): ICyclesTopUpOptions
priority
: boolean
- Priority transactionmemo
: Uint8Array
- Transaction memoPromise<void>
Example:
transfer(options)
options
: ICyclesTransferOptions
from
: Principal
- Source canisterto
: Principal
- Destination canisteramount
: bigint
- Cycles amount to transferPromise<void>
Example:
convertIcpToCycles(icpAmount, options?)
icpAmount
: bigint | string
- ICP amount in e8soptions
(optional): IICPToCyclesOptions
targetCanister
: Principal
- Canister to send cycles toautoTopUp
: boolean
- Automatically top up target canisterPromise<ICyclesConversionResult>
icpAmount
: bigint
- ICP amount convertedcyclesAmount
: bigint
- Cycles receivedxdrRate
: bigint
- XDR exchange rate usedfee
: bigint
- Conversion feegetPricing()
Promise<ICyclesPricing>
xdrRate
: bigint
- Current XDR to cycles ratecyclesPerXdr
: bigint
- Cycles per XDRicpToXdr
: number
- ICP to XDR exchange ratelastUpdated
: number
- Last update timestampgetUsageMetrics(canisterId, period?)
canisterId
: Principal | string
- Canister to analyzeperiod
(optional): 'hour' | 'day' | 'week' | 'month'
- Metrics period (default: ‘day’)Promise<ICyclesUsageMetrics[]>
canisterId
: Principal
- Canister IDperiod
: string
- Time periodtotalConsumed
: bigint
- Total cycles consumedavgConsumptionRate
: bigint
- Average consumption ratetimestamp
: number
- Metric timestampgetForecast(canisterId)
canisterId
: Principal | string
- Canister to forecastPromise<ICyclesForecast>
canisterId
: Principal
- Canister IDcurrentBalance
: bigint
- Current balanceavgDailyConsumption
: bigint
- Average daily consumptiondaysUntilDepletion
: number
- Estimated days until depletionforecastDate
: Date
- Estimated depletion daterecommendedTopUp
: bigint
- Recommended top-up amountconfidence
: number
- Forecast confidence (0-100)startMonitoring(config)
config
: ICyclesMonitoringConfig
canisterIds
: Principal[]
- Canisters to monitorlowBalanceThreshold
: bigint
- Low balance alert thresholdcheckInterval
: number
- Check interval in secondsautoTopUp
(optional): Auto top-up configuration
enabled
: boolean
- Enable auto top-uptopUpAmount
: bigint
- Amount to top upPromise<void>
Example:
stopMonitoring()
void
Example:
getAlerts()
ICyclesAlert[]
id
: string
- Alert IDtype
: string
- Alert typeseverity
: 'info' | 'warning' | 'critical'
- Severity levelcanisterId
: Principal
- Related canistermessage
: string
- Alert messagecurrentBalance
: bigint
- Current balance when alert was createdthreshold
: bigint
- Threshold that triggered alerttimestamp
: Date
- Alert timestampacknowledged
: boolean
- Whether alert was acknowledgedclearAlerts()
void
Example:
getBatchBalances(canisterIds)
canisterIds
: (Principal | string)[]
- Canisters to queryPromise<ICyclesBalance[]>
- Array of balance information
Example:
batchTopUp(operations)
operations
: Array of top-up operations
canisterId
: Principal | string
- Target canisteramount
: bigint | string
- Cycles amountoptions
: ICyclesTopUpOptions
(optional)Promise<Array<{ canisterId: string; success: boolean; error?: string }>>
Example:
formatCycles(cycles)
cycles
: bigint
- Cycles amountstring
- Formatted cycles (e.g., “2.5T”, “1.2B”)
Example:
parseCycles(cycles)
cycles
: string
- Cycles string (e.g., “2.5T”, “1B”)bigint
- Parsed cycles amount
Example:
validateAmount(amount)
amount
: bigint | string
- Amount to validatebigint
- Validated amount
Example:
canisterExists(canisterId)
canisterId
: Principal | string
- Canister to checkPromise<boolean>
- Whether canister exists
Example:
getBalanceSummary(canisterId)
canisterId
: Principal | string
- Canister to summarizePromise<string>
- Balance summary
Example:
estimateConsumption(canisterId, days?)
canisterId
: Principal | string
- Canister to analyzedays
(optional): number
- Number of days to estimate (default: 30)Promise<bigint>
- Estimated consumption
Example:
ICyclesBalance
ICyclesMonitoringConfig
ICyclesForecast