@soroban-dev-kit/anchor
v0.1.1
Published
SEP-1/SEP-10/SEP-24 anchor integration (fiat on/off-ramp) — protocol client plus React hooks.
Maintainers
Readme
@soroban-dev-kit/anchor
Fiat on/off-ramp for soroban-dev-kit —
the full SEP-1 (stellar.toml discovery) → SEP-10 (wallet authentication)
→ SEP-24 (interactive deposit/withdraw + status polling) flow, as protocol
functions plus React hooks.
npm install @soroban-dev-kit/anchorDeposit flow
import { useAnchorAuth, useAnchorDeposit, useAnchorTransactionStatus, type AnchorSession } from "@soroban-dev-kit/anchor";
import { useState } from "react";
function DepositButton() {
const { authenticateAsync } = useAnchorAuth();
const { startDepositAsync } = useAnchorDeposit();
const [session, setSession] = useState<AnchorSession | null>(null);
const [txId, setTxId] = useState<string | null>(null);
async function handleDeposit() {
const session = await authenticateAsync("testanchor.stellar.org"); // SEP-1 + SEP-10
setSession(session);
const { id, url } = await startDepositAsync({ session, assetCode: "SRT" }); // SEP-24
setTxId(id);
window.open(url, "_blank"); // the anchor's KYC/deposit-details form
}
const status = useAnchorTransactionStatus({
session: session!,
id: txId!,
enabled: !!session && !!txId,
});
return <button onClick={handleDeposit}>Deposit</button>;
}useAnchorWithdraw mirrors useAnchorDeposit for the opposite direction.
Why SEP-10 verifies the challenge before signing
authenticateWithAnchor checks that the challenge transaction was actually
signed by the anchor's own published SIGNING_KEY (via
WebAuth.readChallengeTx) before ever asking the wallet to sign it —
skipping that check would let a malicious or misconfigured server trick a
wallet into signing an arbitrary transaction.
Testing without a real anchor account
testanchor.stellar.org is the Stellar
Development Foundation's public SEP-24 reference anchor on testnet — no
special credentials needed, supports a SRT test asset plus test
USDC/native. This package's own integration tests run against it.
Full docs and the design rationale: see the
soroban-dev-kit repo and its
SKILL.md.
