trustlinedocs
Getting started

Your first onboarding

A complete, zero-touch receive on testnet. We’ll onboard an account into EURCV using the default mechanism — a claimable balance — so the user needs no XLM and no prior trustline.

The shape of the flow

  1. Detect
    Read the holder's state to confirm the trustline is missing or unauthorized.
  2. Build
    One call returns the unsigned transaction for the right mechanism.
  3. 3
    Sign
    The user signs once in their wallet; the sponsor co-signs the reserve.
  4. 4
    Settle
    Submit, then verify the balance is usable.

1. Detect

Ask whether the account can already receive the asset. If it has an authorized trustline, you’re done — no onboarding needed.

onboard.ts
import { onboarder } from "./onboarder";

const asset = { code: "EURCV", issuer: "GBAD…7QFD" };

const state = await onboarder.detect({ account, asset });
// { hasTrustline: false, authorized: false }

2. Build the transaction

One call assembles the operations for the chosen mechanism — the change-trust, the claim, and the begin/end sponsoring sandwich — and returns an unsigned plan.

const plan = await onboarder.buildOnboardingTx({
  account,
  asset,
  mechanism: "claimable",
});

console.log(plan.mechanism); // "claimable"
console.log(plan.xdr);       // base64 transaction envelope

3. Sign once

The user signs the envelope in their wallet. The sponsor’s signature for the reserve is collected by the SDK, and — for a regulated asset — the approval server adds the issuer authorization. The user sees a single prompt.

const signed = await wallet.sign(plan.xdr);

4. Settle and verify

Submit the signed transaction, then confirm the balance landed and is usable.

const result = await onboarder.submit(signed);
// { hash: "…", balance: "100.00", asset: "EURCV" }

const ok = await onboarder.verifyActivation({ account, asset });
// true — authorized trustline, claim settled
Prefer to click through it? Try the live demo — the exact activation flow an end user sees. Or run every step printed against a live testnet issuer, distributor, sponsor, and recipient: pnpm --filter @trustline-onboarder/demo start.
Previous
Configure the SDK
Next
C — Claimable balance