getComputationFee
getComputationFee(
arciumProgram,mxeProgramId,computationOffset,commitment?):Promise<{baseFee:BN;callbackCuLimit:number;priorityFee:BN;source:"account"; } |null>
Fetch a live computation's on-chain fee by its offset.
Returns the ComputationFee account variant while the computation
account is alive, or null once it has been closed (claim_computation_rent,
reclaim_expired_computation_fee, or a failure-claim flow). There is no
automatic fallback for closed accounts: the on-chain data is gone, so a caller
that stored the queue tx signature must pass it to
getComputationFeeFromQueueTx to reconstruct the fee inputs.
Throws if the live account at (cluster, offset) belongs to a different MXE:
the computation PDA is keyed on (cluster, comp_offset) only, so two MXEs on
a shared cluster can collide on it across lifecycles, and silently returning
the wrong MXE's fee would be a correctness bug.
Parameters
| Parameter | Type | Description |
|---|---|---|
arciumProgram | Program<Arcium> | Anchor program instance (Arcium IDL). |
mxeProgramId | PublicKey | MXE program the computation belongs to; derives the cluster and computation PDA. |
computationOffset | BN | Computation offset. |
commitment? | Commitment | RPC commitment for the account reads. |
Returns
Promise<{ baseFee: BN; callbackCuLimit: number; priorityFee: BN; source: "account"; } | null>
The live account fee, or null if the account is closed.
Example
import { getArciumProgram, getComputationFee, getComputationFeeFromQueueTx } from '@arcium-hq/reader';
const program = getArciumProgram(provider);
const fee = await getComputationFee(program, mxeProgramId, computationOffset);
if (fee) {
console.log('Live fee:', fee.baseFee.add(fee.priorityFee).toString());
}
else {
// Closed: reconstruct from the stored queue tx signature.
const queued = await getComputationFeeFromQueueTx(program, queueTxSignature, mxeProgramId, computationOffset);
console.log('cuPriceMicro:', queued.cuPriceMicro.toString());
}