Skip to content

Chi Cost Table

This page provides a detailed reference for chi costs across all operation types.

Storage Costs

OperationCostUnit
Storage read1meter unit per byte (key + value)
Storage write25meter units per byte (key + value)
Submitted transaction bytes1meter unit per byte
Returned value bytes1meter unit per byte
Cross-contract dispatch10,000raw meter units per call

Byte count includes both the encoded key (e.g., currency.balances:alice) and the encoded value (e.g., 1000000).

xian_vm_v1 uses the VM host-operation schedule. Current VM storage writes are charged at 25 units per byte, while VM storage reads are charged by the VM schedule. Cross-contract dispatch is charged as a fixed per-call cost; repeated contract calls do not add a progressive surcharge.

Base Costs

ItemValue
Base transaction cost5 chi
Chi-to-XIAN conversion in paid_metered mode20 chi = 1 XIAN

Limits

LimitValue
Runtime raw safety ceiling50,000,000,000 raw units
Maximum write data per transaction128 KiB
Maximum return value size128 KiB
Maximum submitted contract source64 KiB
Maximum sequence or binary allocation128 KiB
Default chi allocation1,000,000

Chi Formula

chi_used = (raw_meter_cost // 1000) + 5

Where:

  • raw_meter_cost = compute, storage, transaction-byte, return-value, and runtime-bridge costs charged by the selected execution backend
  • 5 = base transaction cost
  • the final value is capped by the transaction's submitted chi budget

Opcode Costs

xian_vm_v1 meters execution through the VM gas schedule plus storage and payload-size costs. The exact compute breakdown is implementation-defined by the VM runtime, so use simulation for final receipt values.

Example Meter Contributions

The rows below show raw meter contributions before the final // 1000 conversion. Do not read a storage row such as 600 as 600 billed chi; it is one part of the raw aggregate that becomes final chi_used.

Simple Variable Read

python
counter.get()
  • Compute cost: VM gas schedule dependent
  • Storage read: key con_x.counter (12 bytes) + value 42 (2 bytes) = 14 raw meter units
  • Final chi: 5 + (raw_meter_cost // 1000), so use simulation for the exact receipt value

Simple Hash Write

python
balances["alice"] = 1000
  • Compute cost: VM gas schedule dependent
  • Storage write: key con_x.balances:alice (20 bytes) + value 1000 (4 bytes) = 24 bytes * 25 = 600 raw meter units
  • Final chi: 5 + (raw_meter_cost // 1000), capped by the submitted budget

Token Transfer (Two Reads + Two Writes)

python
@export
def transfer(to: str, amount: float):
    assert balances[ctx.caller] >= amount, "Insufficient balance"
    balances[ctx.caller] -= amount
    balances[to] += amount
  • 2 storage reads: roughly 30-60 raw meter units, depending on encoded key/value sizes
  • 2 storage writes: roughly 1,200-1,400 raw meter units, depending on encoded key/value sizes
  • compute, transaction bytes, return values, and runtime bridge work add to the same raw meter total
  • final chi is the converted receipt value, so simulate the transaction against the target execution policy for a real estimate

Cost Optimization Tips

StrategySavings
Use shorter contract and variable namesReduces key byte count for every read/write
Cache repeated reads in local variablesAvoids paying read cost multiple times
Use default_value in Hash declarationsAvoids unnecessary reads that return None
Minimize writes in loopsEach write is 25x more expensive than a read
Keep cross-contract boundaries intentionalEach hop pays a fixed dispatch cost plus the called work
Avoid storing large strings or listsEvery byte increases the raw write-meter cost

Measured Local Reference Transactions

These examples were measured on a rebuilt local BDS node in June 2026 with paid_metered fees, chi_cost = 20, and xian_vm_v1 cross-contract dispatch charged as a fixed per-call cost. They are useful for comparing relative transaction shapes, but exact values can move with contract source, arguments, network config, and VM metering policy.

ActionMain callChi usedXIAN fee
Contract read callprobe read_value190.95
Contract storage writeprobe set_value301.50
Contract loop + writeprobe bump_many311.55
Contract event + writeprobe emit_probe402.00
Approve demo tokentoken approve422.10
Approve allowancecurrency.approve603.00
Native XIAN transfercurrency.transfer693.45
Spend via transfer_fromcurrency.transfer_from834.15
Deploy small contractsubmission.submit_contract92746.35
Direct DEX core swapcon_dex.swapExactTokenForToken1,77588.75
Direct DEX supporting swapcon_dex.swapExactTokenForTokenSupportingFeeOnTransferTokens1,92396.15
DEX sell demo tokencon_dex_helper.sell2,126106.30
DEX buy demo tokencon_dex_helper.buy2,214110.70
Shielded command executionshielded command execute_command6,715335.75
Shielded DEX swap pathshielded command plus DEX adapter9,898494.90

The shielded rows include proof verification, hidden-note spend accounting, and hidden change-note output handling. The DEX shielded row also includes the canonical shielded DEX adapter and the real con_dex router swap. Setup transactions such as verifier-key registration, contract deployment, approvals, deposits, and liquidity seeding are excluded from these per-action rows.

ZK Bridge Metering

The runtime zk bridge has explicit meter constants before native verification or shielded helper work runs:

OperationCost
raw Groth16 verify base750,000
raw Groth16 public input50,000 each
raw Groth16 payload byte50 each
registry-backed Groth16 verify base500,000
registry prepared-key setup250,000
registry-backed public input50,000 each
registry-backed payload byte25 each
shielded tree append base250,000
shielded tree append commitment500,000 each
shielded command nullifier digest base100,000
shielded command nullifier digest input50,000 each
shielded command binding100,000
shielded command execution tag50,000

ZK inputs are bounded before verification: verifying-key hex payloads are limited to 8,192 characters, proof hex payloads to 4,096 characters, public inputs to 32, and registry verifying-key ids to 128 characters.

XIAN Cost Conversion

In the default paid_metered mode, the chain converts used chi to XIAN at 20 chi per XIAN:

Billed chiXIAN cost
50.25
201
1005
1,00050
10,000500

In free_metered mode, the same chi accounting and receipt values apply, but the execution fee charged to the sender is 0. Use the submitted chi caps in the node config to bound per-transaction and per-block work on 0-fee networks.

Use dry-run simulation for operation-level estimates. Deployment includes more than final writes: it also pays for contract-analysis work and canonical source storage. Large comments are not preserved in stored __source__, but raw submitted source is still size-limited.