DFINITY
Console
On this page
Documentation Card · ck-USDC · canisters

How it works.

A card or ck-USDC payment, taken by CyclePay's canisters and minted into cycles by the Cycles Minting Canister. Cycles land on the canister you name, or on a Cycles Ledger account minus 0.0002T in ledger fees (T is a trillion cycles).

How it works

How it works end-to-end.#

Three steps take you from payment to cycles deposited, on either rail. Everything runs on Internet Computer canisters; the flow typically completes in under 15 seconds.

01
Sign in, or pay as a guest
Sign in with Internet Identity, using your passkey or biometric. II keeps your session (24 hours on the Buy page, 7 days in the console, 30 days at most), and your principal owns what you buy. A card payment of $5 to $100 can skip this step: it then belongs to no principal, and the page follows it by its Stripe Checkout Session.
import { AuthClient } from '@icp-sdk/auth/client';

const auth = new AuthClient();
await auth.signIn({
  maxTimeToLive:
    BigInt(24 * 60 * 60 * 1e9) // 24h
});
02
Pay on your chosen rail
Card on a Stripe Payment Link (2.9% plus $0.30, taken from the payment, with the amount converted rounded to the cent), or ck-USDC on ICP paid straight to the backend canister after an ICRC-2 approve (0.01 ck-USDC on the approve and 0.01 on the pull). ICRC-2 is the token standard's allowance: you approve the backend for an amount on the ledger, and the backend takes it with icrc2_transfer_from. Both converge on the same delivery path in the backend canister. A signed-in card order and every ck-USDC payment belong to your principal.
# Card: the backend makes the order,
# the buyer pays on the Payment Link
create_order(record {
  destination = variant { Canister = ... };
  amount_usd_cents = 2_500; ... })
# -> client_reference_id = "o_<order id>"

# ck-USDC: approve the backend, then pay
icrc2_approve(...)   # on the ck-USDC ledger
topup_ckusdc(record {
  request_id = "<fresh id>";
  amount_atomic = 25_000_000; ... })
03
Cycles delivered via CMC
The backend canister transfers ICP to the CMC subaccount via icrc1_transfer. For a canister top-up it calls notify_top_up and the cycles land on the target canister. For a Cycles Ledger order it calls notify_mint_cycles into a CyclePay holding subaccount for the order, then transfers the cycles to the beneficiary's Cycles Ledger account (two 100M fees, 0.0002T). Either way the CMC burns the ICP and mints cycles at its current ICP/XDR rate (XDR is the IMF's Special Drawing Rights, a basket of currencies; 1T cycles costs 1 XDR).

Why Internet Identity over CLI key files

Internet Identity replaces long-lived local keys with hardware-backed passkeys and biometric auth. Your root of trust lives in your device's secure enclave, not in a key that icp-cli keeps on this machine.

CLI identity: a key file

icp-cli keeps the private key on this machine (the OS keyring by default, or a PEM under identity/keys/ with plaintext storage).

  • It can be exported, copied or leaked.
  • It has no built-in expiry or scoping.
  • Each agent or machine is another key.
  • If the machine is wiped, the key is gone.

Internet Identity: a passkey

The passkey lives in the device's secure enclave (TPM, Secure Enclave or a FIDO2 key).

  • It is hardware-backed and cannot be copied.
  • A biometric or PIN unlocks it.
  • II issues time-limited delegations.
  • The identity is recoverable through its recovery methods.
  • There are no PEM files on disk to manage.

How II actually works

Per-origin principals. II derives a different principal for each frontend origin. Your principal on this site is different from your principal on other dapps. This is a privacy feature, not a limitation: it prevents cross-app tracking. This means your II principal authorizes payments, and you specify the destination canister separately.

Session keys still exist. II delegations involve an ephemeral session key pair. The difference from CLI identity: the session key is time-limited (sessions up to 30 days, delegations renewed every five minutes), hardware-initiated, and doesn't persist as a file. The root of trust is your passkey in the secure enclave, not a PEM file.

CLI quick start

CyclePay from your terminal.#

Sign in to icp-cli with the same Internet Identity you use on this site, then buy cycles, check balances and spend them from the terminal. Card payments finish on Stripe's page in your browser.

Requirements

  • Node.js 18 or later and npm, or Homebrew, to install icp-cli
  • icp-cli 1.7.0 or later for icp cycles buy; 1.4.0 or later for the rest (signing in alone works from 0.3.0; auto-refill’s --add-status-viewer and icp token approve --expires-in need 1.4.0)
  • A browser on the same machine, for the sign-in
  • An Internet Identity (id.ai)

Step 1 · Install icp-cli

npm install -g @icp-sdk/icp-cli   # or: brew install icp-cli
icp --version                     # 1.7.0 or later for icp cycles buy
# An older one: npm install -g @icp-sdk/icp-cli@latest, or brew upgrade icp-cli

Step 2 · Turn on CLI access

Sign in at id.ai, open your identity settings and turn on CLI access. It is off by default and is stored per browser, so turn it on in the browser you will sign in with. Without it, the sign-in page shows “CLI access not enabled”.

Step 3 · Sign in from the terminal

icp identity link web cyclepay --app 4w3yu-fyaaa-aaaac-beeoa-cai.icp0.io

Press Enter when prompted. Your browser opens id.ai; sign in with your passkey and the delegation comes back to icp-cli over a localhost callback. --app gives the terminal the same principal this website shows you, so your purchases, ledger balance and auto-refill rules are the same account on both.

Step 4 · Check it is the same principal

icp canister call --query --identity cyclepay -n ic ivcos-eqaaa-aaaab-qablq-cai whoami '()'
# prints your principal: it should match the one shown on this site

Pass --identity cyclepay on each command instead of making it your default identity, so your deploys keep using the identity you chose for them. When the delegation expires, run icp identity reauth cyclepay and sign in again.

What you can do from the terminal

Fund your identity with ck-USDC: send ck-USDC to the principal the first line prints, from a wallet or an exchange, and check it arrived with the second:

icp identity principal --identity cyclepay
icp token xevnm-gaaaa-aaaar-qafnq-cai balance --identity cyclepay -n ic

Buy cycles with ck-USDC: approve the backend on the ck-USDC ledger for the amount plus the 0.01 fee of the pull, for 10 minutes, then pay (topup_ckusdc; amounts in 6-decimal atoms, $1 to $200). REQUEST_ID is a fresh id for this purchase; if the call gets no answer, send it again with the same one:

icp token xevnm-gaaaa-aaaar-qafnq-cai approve 25.01 2bwus-iiaaa-aaaac-bee3a-cai --expires-in 10m --identity cyclepay -n ic
REQUEST_ID=$(uuidgen)
icp canister call --identity cyclepay -n ic 2bwus-iiaaa-aaaac-bee3a-cai topup_ckusdc \
  '(record { request_id = "'"$REQUEST_ID"'"; amount_atomic = 25_000_000 : nat; destination = variant { Canister = principal "<canister-id>" }; beneficiary = null; project_id = null; confirm_system_canister = null })'

Buy cycles by card: icp cycles buy shows the price, the card fee and about how many cycles it buys, and asks to confirm. It then prints the payment page’s link with a QR code to scan with your phone, and waits until the cycles land on your Cycles Ledger account. --cycles 5T pays the least, to the cent, that buys 5T at the quoted rate. Nothing is charged until you pay on Stripe’s page, and Ctrl-C stops the wait, not the order:

icp cycles buy --amount 10 -n ic --identity cyclepay
icp cycles buy --cycles 5T -n ic --identity cyclepay

The same order by canister call, from any IC agent or to top up a canister directly: make the order, then pay on the payment_url it returns (create_order; get_card_terms has the limits and the fees):

icp canister call --identity cyclepay -n ic 2bwus-iiaaa-aaaac-bee3a-cai create_order \
  '(record { destination = variant { Canister = principal "<canister-id>" }; beneficiary = null; escrow_spender = null; escrow_principal = null; project_id = null; amount_usd_cents = 2_500 : nat64; confirm_system_canister = null })'
# Open the payment_url it returns, as it is.

Check your Cycles Ledger balance ( um5iw-rqaaa-aaaaq-qaaba-cai ):

icp cycles balance --identity cyclepay -n ic

Top up a canister from your ledger balance (no CyclePay call needed):

icp canister top-up <canister-id> --amount 500b --identity cyclepay -n ic

Transfer cycles to another principal:

icp cycles transfer 1t <receiver-principal> --identity cyclepay -n ic

What happens in the browser

  • Card payments. Stripe's page opens in the browser, or scan the QR code icp cycles buy prints to pay on your phone. A terminal tool can also send its user to /c/<canister id>/<usd> or /b/<principal>/<usd> on this site: the user pays by card without a sign-in for $5 to $100, otherwise after signing in.
  • Auto-refill. The console sets up prepaid auto-refill: the subscription, its Cycles Ledger approval and the status-viewer command for the canister.
Pricing

Zero margin, transparent fees.#

Zero markup on top of the protocol-defined cycle rate. CyclePay charges $0; you pay only the third-party processing fee for the rail you choose.

Cycle rate
1T cycles = 1 XDR, set by the protocol; only an NNS vote can change it.
XDR rate
USD per XDR, refreshed by the backend canister from the Exchange Rate Canister (CXDR/USD) every 6 hours (public query get_xdr_rate_status). Quotes on this site use the same rate the backend prices the order with. The CMC mints at its current ICP/XDR rate, refreshed from the Exchange Rate Canister every few minutes, and the backend buys the ICP at that rate too, so it cancels out.
Service fee
$0.00 on every rail.
Card (Stripe)
2.9% plus $0.30 per payment, taken from the payment. The amount converted is rounded to the cent.
ck-USDC on ICP
0.01 ck-USDC per ledger operation: 0.02 in all (the approve and the transfer), paid on top.
Cycles Ledger delivery
A Cycles Ledger order delivers 0.0002T less (two 100M Cycles Ledger fees).
A $25 card purchase
You pay$25.00
Stripe fee$1.025 (2.9% of $25 is $0.725, plus $0.30)
Converted to cycles$23.98 ($23.975 rounded to the cent; the quote and the mint use the same figure)
Cycles$23.98 divided by the canister's XDR/USD rate, in trillions
A $25 ck-USDC purchase
You pay25.02 ck-USDC (25.00 plus two 0.01 ledger fees; today's fee, read get_ckusdc_terms)
Converted to cycles25.00 ck-USDC
Cycles25.00 divided by the canister's XDR/USD rate, in trillions
$0 Service markup, every rail
2 rails Card and ck-USDC on ICP
1 XDR per 1T cycles (protocol rate)
Payment rails

Payment rails, one canister flow.#

Pay how you like. The rails take payment differently (a card on Stripe's page, an ICRC-2 approval), but they converge on the same delivery in the backend canister, which mints the cycles through the CMC. The resulting cycles are identical.

Stripe (card)

The backend's create_order makes an order, and the buyer pays it on CyclePay's Stripe Payment Link with its client_reference_id. Stripe's webhook reaches the Stripe gateway canister, which checks it and tells the backend the payment is in. A card payment of $5 to $100 needs no sign-in: the guest Payment Link names the canister or Cycles Ledger account in its reference.

ck-USDC on ICP

The buyer approves the backend canister on the ck-USDC ledger for amount + fee, then calls its topup_ckusdc. The backend pulls the ck-USDC with icrc2_transfer_from and usually delivers the cycles before the call returns. No bridge, and no checkout page.

See the API reference for every method and its Candid types, and agent security for what a sign-in lets its holder do.

Fund flow

From payment to cycles.#

The path a payment takes to land on a canister or a Cycles Ledger account. Steps 1 and 2 differ by rail; from step 3 on, both rails follow the same canister flow. Every order's cycles are paid from the backend canister's ICP balance as soon as the payment clears, and CyclePay refills that balance from what the rails collect.

  1. You pay on one rail card: 2 to 5 s with step 2

    • Card: Stripe's page for CyclePay's Payment Link, carrying the order's client_reference_id.
    • ck-USDC: an ICRC-2 approve of the backend for the amount plus the fee, then topup_ckusdc.
  2. The rail confirms the payment

    • Card: Stripe's webhook reaches the Stripe gateway canister, which checks its signature, reads the payment back from Stripe through consensus, and reports it to the backend (card_payment_confirmed).
    • ck-USDC: the backend pulls it with icrc2_transfer_from, and the ledger returns the block index.
  3. The backend journals the order 3 to 8 s for steps 3 to 6

    It works out the ICP from the CMC's rate and its own XDR/USD rate, and writes a journal entry to stable memory before any ICP moves. A payment is delivered at most once.

  4. The backend sends ICP to the CMC

    It transfers the ICP to the CMC with icrc1_transfer.

  5. The CMC mints the cycles

    • A canister: notify_top_up, and the cycles land on the target canister.
    • A Cycles Ledger account: notify_mint_cycles into a holding subaccount for the order, then a Cycles Ledger transfer to the beneficiary, minus two 100M-cycle fees.
  6. The cycles are delivered

    The Buy page follows a card order with order_status (or order_status_by_session after a guest payment); topup_ckusdc usually returns with the cycles delivered.

Timing and refunds

Card. Steps 1 and 2 take 2 to 5 seconds (card capture and the webhook); steps 3 to 6 take 3 to 8 seconds. Total end-to-end: typically under 15 seconds.

ck-USDC. There is no webhook hop: the pull and the delivery happen in the topup_ckusdc call where the ledgers and the CMC answer in time, and a timer finishes the rest.

Interrupted deliveries. If a delivery stops after its ICP reached the CMC, a backend timer finishes it. The timer runs every 60 seconds while any delivery is waiting, and picks up an entry once it has been idle for 5 minutes. If a delivery stops before that, the backend sends the ICP again after 10 minutes with the same created_at_time, so the ICP ledger ignores the second send if the first one landed. Card deliveries are retried this way unless a review holds them; ck-USDC deliveries only when the ICP ledger refused the send for now (any refusal but BadBurn), a few times at most, after which the payment is refunded, or held for review if the ledger kept refusing its fee. A ck-USDC delivery whose outcome is unknown waits for an operator, as does any unknown entry that an upgrade flags for review.

Refunds. A card payment refused before delivery (an expired order, a daily cap, a destination it cannot reach) is refunded in full, and a payment of either rail that cannot be priced for a day is refunded. Otherwise a payment is refunded once the journal shows the cycles cannot be delivered: a card payment to the card, a ck-USDC payment to the payer minus one ledger fee.

Architecture

Architecture overview.#

CyclePay is four canisters on the Internet Computer and the ledgers they call. There is no server: the site, the payments, the delivery and the console all run on chain.

Stripe gateway

The only canister Stripe talks to and the only one that holds Stripe's secrets, on the confidential subnet re2t4. It checks each webhook about CyclePay's own Payment Links, reads the payment back from Stripe, and hands the backend a minimal fact. It holds no funds and makes refunds through Stripe for the backend.

Backend canister

Makes card orders, pulls ck-USDC, prices every order with its XDR/USD rate, and pays for the cycles from its own ICP balance. For a canister it calls notify_top_up; for a Cycles Ledger account it calls notify_mint_cycles into a holding subaccount for the order, then transfers the cycles to the beneficiary. Same path whichever rail paid.

Console and site

The console canister keeps projects, teams, roles, invites, purchase history and prepaid auto-refill, which tops canisters up from the owner's own Cycles Ledger allowance. The frontend canister serves this site at www.cyclepay.org.

Security model

Security model.#

Multiple layers of protection ensure every payment results in at most one cycle deposit, on every rail.

Journaling

Every delivery writes a JournalEntry to the backend's stable storage before the ICP transfer. States: Pending → IcpTransferred → CyclesDelivered. Every 60 seconds a timer finishes entries whose ICP already moved; entries survive canister upgrades via ic-stable-structures.

Idempotency

Card: each Stripe payment is recorded once, by its Checkout Session and its payment intent, and only payments of CyclePay's own Payment Links count. A signed-in order is paid once: a second payment of it is refunded. A guest checkout (no sign-in) is a top-up each time it is paid, so the page asks the buyer to pay it once. ck-USDC: a payment is named by its payer and request_id, so a retry reports it and never pulls twice. The journal refuses a payment intent it has seen, so a replay at any level changes nothing.

Access control

Only the Stripe gateway can report a card payment, and only the backend's controllers can pause it or change its limits. An order's details are readable by its buyer, by the backend’s controllers (CyclePay’s operators) and by the canisters they allow to read, such as the console; the public status of a Checkout Session says nothing about the buyer.

For AI agents

Buy cycles from any agent.#

CyclePay is designed to be agent-actionable. An agent calls the canisters with icp-cli or an IC agent, with no API key: its identity is its account. Drop the /llms.txt URL or the snippet below into your agent's context and it can buy top-ups on demand.

Three ways an agent buys cycles

1. A link, by card. The agent shows its user https://www.cyclepay.org/c/<canister id>/<usd>. The page shows the canister's full ID beside Pay; the user taps it and pays $5 to $100 by card on Stripe's page, with no sign-in, and the cycles land on the canister.

2. An order, by card. The agent runs icp cycles buy (icp-cli 1.7.0 or later) as its own identity: first without --yes, which prints the quote and creates nothing, for its user to approve; then with --yes --no-open --no-wait --json, which prints the checkout_url the user pays. With --cycles, it orders with --amount set to the Price the user approved. The user pays $1 to $200 in the browser; the agent never pays, and follows the order with order_status; for NeedsReview or RefundOwed it gives its user the order id and CyclePay’s contact, securitybugs@dfinity.org. Without icp-cli 1.7.0 or later, create_order makes the same order and returns its payment_url. <agent> is that identity: icp identity new agent makes one. The buy-cycles skill has more on the flow.

# The quote: it creates nothing, and exit status 1 is expected
icp cycles buy --amount 10 -n ic --identity <agent> < /dev/null
# On the user's yes: one JSON line; give the user its checkout_url
icp cycles buy --amount 10 -n ic --identity <agent> --yes --no-open --no-wait --json
# Until Delivered, Refunded, RefundOwed or NeedsReview, or until expires_at passes unpaid
icp canister call --query --identity <agent> -n ic 2bwus-iiaaa-aaaac-bee3a-cai order_status '("<order_id>")'

3. ck-USDC, paid by the agent. From an identity that holds a ck-USDC budget, the agent approves the backend for the amount plus 0.01 and calls topup_ckusdc, with no human in the loop. Give it a fresh request_id per purchase and the same one on every retry; if a call returns no answer, topup_ckusdc_status says what happened. See the CLI quick start for the commands.

Drop this into your agent's context

Add this note pointing at /llms.txt to any Claude Code CLAUDE.md, Cursor .cursor/rules, Windsurf rules file, or system prompt:

To buy ICP cycles, fetch and follow https://www.cyclepay.org/llms.txt
(or https://4w3yu-fyaaa-aaaac-beeoa-cai.icp0.io/llms.txt): the index of
CyclePay's canister methods, the CLI flow and icp-cli examples.

For a longer copy-pasteable agent config block, see the CLAUDE.md snippet on the API page. For every method, see the API reference.

Agent security

What a sign-in lets its holder do.#

An Internet Identity sign-in hands out a time-limited delegation for your CyclePay principal. Neither the terminal sign-in nor the web sign-in limits it to particular canisters, so treat both as you would a password for that principal until they expire. The same goes for any identity an agent pays with.

Terminal and web sign-ins

Terminal · icp identity link web
# Session key:  OS keyring (default)
# Delegation:   icp-cli identity directory
# Lifetime:     8 hours (id.ai default)
# Canisters:    all
#
# Together they let icp-cli sign any
# call as your CyclePay principal,
# including icrc1_transfer on the
# Cycles Ledger, which spends the
# balance you bought here.
#
# Anything that can run icp as your
# OS user can do the same until the
# delegation expires.
Agent · an identity with ck-USDC
# An identity that pays ck-USDC can
# sign any call as its principal:
#
#   topup_ckusdc, which pulls up to
#   what it approved the backend for
#   icrc1_transfer on the ck-USDC
#   ledger, which sends its whole
#   balance anywhere
#
# Card orders it makes still need a
# person to pay on Stripe's page.
#
# Keep only the ck-USDC it may spend
# in it, and approve each payment's
# exact amount with an expires_at.

Giving an agent less

If an agent only needs to reach one canister, sign it a narrower delegation from your linked identity instead of sharing the identity itself. The agent makes its own key and hands you only the public half; you sign a delegation for it; the agent attaches it:

# On the agent's machine: a new key, its public half to agent-public-key.pem
icp identity delegation request agent > agent-public-key.pem

# On yours: a delegation for that key, to one canister, for 24 hours
icp identity delegation sign --identity cyclepay \
  --key-pem agent-public-key.pem \
  --duration 24h \
  --canisters <your-canister> > delegation.json

# Back on the agent's machine: the identity is ready to sign
icp identity delegation use agent --from-json delegation.json

The agent's key goes in its OS keyring. On a machine without one, such as a server or a container, add --storage password to the first command and give the agent --identity-password-file on its calls.

  • Scope by canister. Point --canisters at a wrapper canister you control, never at the Cycles Ledger (um5iw-rqaaa-aaaaq-qaaba-cai): a delegation for the ledger can transfer the whole balance.
  • Expose only the methods you need. Have that canister offer the agent only what its job needs, with its own caps, and never delegate from an identity that controls it: a controller can withdraw its whole balance.
  • Short lifetime. Pick the shortest --duration that covers the job, and never sign 30-day delegations for agent use. It also stops working when the id.ai delegation behind it expires.
  • Reviewed agents only. The agent's full source plus its prompt boundary determine what it can be coaxed into doing, so treat both as trusted code.
Canister IDs

Reference canisters.#

CyclePay's canisters, the ledgers and system canisters they call, and Internet Identity, which signs you in.

CyclePay backend
2bwus-iiaaa-aaaac-bee3a-cai
Card orders, ck-USDC payments, pricing and delivery: every method on the API reference but the console's and the two ledgers'.
CyclePay console
to2ii-4iaaa-aaaac-bgdma-cai
Projects, teams, purchase history and prepaid auto-refill.
CyclePay Stripe gateway
rmokx-2iaaa-aaaay-aadna-cai
Takes Stripe's webhooks and tells the backend a card payment is in. Nothing to call from outside.
ck-USDC ledger
xevnm-gaaaa-aaaar-qafnq-cai
Approve the backend here before paying with ck-USDC.
Cycles Minting Canister
rkp4c-7iaaa-aaaaa-aaaca-cai
Burns ICP and mints cycles at its current ICP/XDR rate, refreshed from the Exchange Rate Canister.
ICP Ledger
ryjl3-tyaaa-aaaaa-aaaba-cai
Tracks ICP token balances and transfers.
Cycles Ledger (ICRC-1)
um5iw-rqaaa-aaaaq-qaaba-cai
Holds cycle balances keyed on principal. Destination of ledger orders (two 100M fees per delivery) and the source of prepaid auto-refill; spend from it with icp canister top-up or an agent with a scoped delegation.
Internet Identity
rdmx6-jaaaa-aaaaa-aaadq-cai
WebAuthn passkey authentication with per-origin principal derivation.
Exchange Rate Canister
uf6dk-hyaaa-aaaaq-qaaaq-cai
Provides exchange rates to the CMC (ICP/XDR) and to the CyclePay backend (CXDR/USD, every 6 hours).

Destination guards

Funding a system canister (NNS dapp, ICP Ledger, CMC, Internet Identity, NNS Governance/Root, Cycles Ledger, or CyclePay’s frontend) is allowed, after a warning. create_order and topup_ckusdc answer SYSTEM_CANISTER_WARNING for one of these IDs; to go ahead, send the call again with confirm_system_canister = opt true. The Buy page and the console show this confirmation before you pay. Both refuse aaaaa-aa (the IC management canister, which cannot receive cycles) and CyclePay’s backend outright with DESTINATION_BLOCKED. Auto-refill refuses CyclePay’s own canisters.

Ready

Start using cycles.

Pay with a card or ck-USDC on ICP. Cycles reach your canister or Cycles Ledger account in seconds.

For agents Machine-readable copy of cyclepay.org
.md