Convert via FX anchors
When to use
Use for an on-chain conversion after the exact source and destination assets are known. The public example corridor is test network KTA → USD through the Test Network Demo FX Anchor. This documents SDK shape, not current provider availability. HopNow is not identified in the public Keeta org or current public docs reviewed for this pack; do not invent a HopNow URL or claim its corridor is active.
SDK steps
Confirm network, source token, destination token/currency, amount, and amount affinity.
Construct the client and discover supported pairs:
const fxClient = new KeetaAnchor.FX.Client(userClient, { root: userClient.networkAddress }); const pairs = await fxClient.listPossibleConversions({ from: userClient.baseToken });For the documented illustrative test corridor, request KTA-to-USD quotes:
const offers = await fxClient.getQuotes({ from: userClient.baseToken.publicKeyString.get(), to: 'USD', amount, affinity: 'from' });Stop if no offers resolve. For every offer, show provider identity, quote amounts, rate, fees, expiry, and legal disclaimers available in the returned data. Do not choose
offers[0]without review.Re-fetch an expired or stale quote with
offer.refetch(). After explicit approval, call:const exchange = await approvedOffer.createExchange();Use the returned exchange status method when needed and compare fresh
userClient.allBalances()reads before and after.
Confirmations
- Confirm pair, direction (
affinity), base-unit amount, provider, rate, fees, minimum received, and expiry. - Require a final approval immediately before
createExchange(). - Make clear whether the offer is a binding quote or an estimate; obtain a quote when the workflow requires price certainty.
Failures
- No providers or unsupported pair: stop and report the Resolver criteria.
- Expired quote or changed rate: re-quote and ask again.
- Unknown decimals: show base units and do not execute.
- Ambiguous exchange status: poll the documented status and balances; never blindly create a second exchange.
- Never replace an unavailable named provider with an unreviewed endpoint.
Related skills
- Use discover-resolve-anchors to inspect provider metadata.
- Use multi-asset-balances to reconcile.
- Apply spend-policy before execution.