moxzi
Docs / On-chain builds / Payment

Paymentalpha

How an on-chain build is priced, paid for in ICP, and refunded.

A paid build works like a deposit. Before the build starts, you approve an amount of ICP and the canister takes the most the build could cost. When the build ends, you're charged three times what it actually used, and the rest is refunded. moxzi build --remote does all of this; you confirm the amount once.

A compiler canister whose operator hasn't set up payment builds for free, and moxzi build --remote says so.

The steps#

StepWhat happens
QuoteThe canister prices the build in ICP at the current ICP/XDR rate from the Cycles Minting Canister
Approvemoxzi checks your balance and approves the amount with ICRC-2 (icrc2_approve) on the ICP ledger
EscrowStarting the build moves the escrow to the canister
BuildThe build runs. No further payment checks
SettleThe canister works out what the build used, keeps three times that (up to the escrow), and refunds the rest

If the canister can't afford to finish the build with its own cycles, it refuses before taking any ICP.

How much#

The escrow is 750,000 cycles per byte of uploaded source, with a minimum of 0.5 trillion cycles. One trillion cycles is one XDR (about 1.3 US dollars). Most of the escrow comes back.

What a build actually used, for some real builds:

BuildSourceCycles used
hello.mo217 bytesabout 1 billion
A 660-file application15 MBabout 1.6 trillion
The moxzi compiler itself8 MBabout 1.6 trillion

Cost depends on the shape of the code as well as its size: code with very large functions costs more per byte.

The charge is computed from the job's own message and instruction counts, multiplied by a factor that covers memory and other costs the counts don't capture. Operators can adjust the rates.

Refunds#

SituationResult
The build succeedsYou pay 3× what it used, up to the escrow. The rest is refunded
The build failsYou pay for what it used. The rest is refunded
You stop driving the build and never come backAn operator can close the job and refund the unused escrow
The refund is smaller than the ledger feeNothing is transferred

If your refund has not been sent yet, moxzi build --remote prints settlement pending and still writes your wasm. Settlement is retried until it completes and never pays out twice. Once your refund is sent, the build reports it as settled, even if the operator's share of the charge is still being processed; that part does not affect you.

Limitations#

Limitation
Payment is in ICP onlyThe canister converts to cycles itself
You can't get an exact price before uploadingThe escrow depends on the size of what you upload
A local build can't predict the chargeLocal instruction counts don't map to cycles at a fixed rate
On this pageThe stepsHow muchRefundsLimitations