> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yield.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Crossmint

> Discover, enter, track and exit yields from a React app, with Crossmint wallets signing the transactions Yield.xyz builds.

This guide builds a React or Next.js flow where users discover a yield, enter it, track the position and exit, signing with Crossmint wallets. The same flow covers DeFi vaults, staking and tokenized real-world assets.

## Resources

* [Crossmint wallets](https://docs.crossmint.com/wallets/overview)
* [Crossmint React quickstart](https://docs.crossmint.com/wallets/quickstarts/client-side-wallets)
* [Enter and exit flows](https://docs.yield.xyz/guides/earn/enter-exit-flows.md) and [EVM signing](https://docs.yield.xyz/guides/transaction-signing/evm.md)

## Prerequisites

* A Yield.xyz API key. See [Onboarding](https://docs.yield.xyz/documentation/get-started/onboarding.md).
* A Crossmint project and client API key, with wallets set up through the React quickstart.

## Getting started with Crossmint

Set up a Crossmint project and API key, then follow the React quickstart to add authentication and wallets. You need the user's wallet from `useWallet()` in `@crossmint/client-sdk-react-ui`, wrapped as an `EVMWallet` to send EVM transactions.

## How Yield.xyz fits

Yield.xyz gives you one API across 4,000+ yields on 85+ networks:

* **Discover:** `GET /v1/yields` returns yields with their metadata.
* **Act:** `POST /v1/actions/enter`, `/exit` and `/manage` return an ordered list of unsigned transactions.
* **Track:** `POST /v1/yields/{yieldId}/balances` and `POST /v1/yields/balances` return lifecycle-aware balances.

Yield.xyz builds transactions and never signs or holds funds. Crossmint signs them in the user's wallet. This guide uses EVM networks. Crossmint also supports Solana and Stellar; see [Transaction signing](https://docs.yield.xyz/guides/transaction-signing/index.md) for those payloads.

## Keep the API key on your server

Keep your Yield.xyz API key on your server. The snippets in this guide call a small proxy route that adds the key, for example a Next.js route handler:

```typescript theme={null}
// app/api/yield/[...path]/route.ts
export async function handler(req: Request, { params }: { params: { path: string[] } }) {
  const url = new URL(req.url);
  const res = await fetch(`https://api.yield.xyz/${params.path.join("/")}${url.search}`, {
    method: req.method,
    headers: { "content-type": "application/json", "x-api-key": process.env.YIELD_API_KEY! },
    body: req.method === "GET" ? undefined : await req.text(),
  });
  return new Response(res.body, { status: res.status, headers: { "content-type": "application/json" } });
}
export { handler as GET, handler as POST, handler as PUT };
```

On the client, one helper calls it:

```typescript theme={null}
export async function yieldApi(path: string, body?: unknown, method = body ? "POST" : "GET") {
  const res = await fetch(`/api/yield${path}`, {
    method,
    headers: { "content-type": "application/json" },
    body: body ? JSON.stringify(body) : undefined,
  });
  const json = await res.json();
  if (!res.ok) throw Object.assign(new Error(json.message ?? `yield.xyz ${res.status}`), { status: res.status, body: json });
  return json;
}
```

## Discover a yield

The discovery response already carries what your UI needs, so you don't need a second request per yield.

```typescript theme={null}
const { items } = await yieldApi("/v1/yields?network=base&token=USDC&limit=10");

const selected = items[0];
const yieldId = selected.id;
const name = selected.metadata.name;
const rate = selected.rewardRate.total;                        // current estimated rate
const tvlUsd = selected.statistics?.tvlUsd;
const enterFields = selected.mechanics.arguments.enter.fields;  // what enter needs
const kycRequired = selected.mechanics.requirements?.kycRequired ?? false;
```

Every field on a yield is described in [Yield metadata](https://docs.yield.xyz/documentation/earn/core-concepts/yield-metadata.md).

## Find yields to offer

Rather than hardcoding yield IDs, which change as yields are added and retired, query the catalog for what you want to offer:

```bash theme={null}
# Stablecoin and DeFi yields on Base
curl "https://api.yield.xyz/v1/yields?network=base&token=USDC&types=lending,vault" \
  -H "x-api-key: $YIELD_API_KEY"

# Native staking
curl "https://api.yield.xyz/v1/yields?type=staking&limit=100" \
  -H "x-api-key: $YIELD_API_KEY"

# Tokenized real-world assets
curl "https://api.yield.xyz/v1/yields?type=real_world_asset&networks=ethereum,base" \
  -H "x-api-key: $YIELD_API_KEY"
```

Add `prime=true` to return only yields that meet the [Prime](https://docs.yield.xyz/documentation/earn/core-concepts/yield-metadata.md) quality bar. For staking, default users to [preferred validators](https://docs.yield.xyz/documentation/earn/staking/validators/preferred-validators.md). For DeFi, wrap yields in an [OAV](https://docs.yield.xyz/documentation/earn/oavs/single-strategy.md) to charge fees and auto-compound incentives (see [Monetization](#monetization)).

## Enter a yield

Build the action, then send each transaction with the Crossmint wallet, in order, and report each hash.

```typescript theme={null}
import { useWallet, EVMWallet } from "@crossmint/client-sdk-react-ui";

const TERMINAL = ["CONFIRMED", "FAILED", "SKIPPED"];

export function useYieldSigner() {
  const { wallet } = useWallet();

  return async function signAndTrack(action: any) {
    if (!wallet) throw new Error("Connect a wallet");
    const evmWallet = EVMWallet.from(wallet);
    const txs = [...action.transactions].sort((a, b) => a.stepIndex - b.stepIndex);

    for (const tx of txs) {
      if (TERMINAL.includes(tx.status)) continue; // e.g. an approval already covered
      const parsed = JSON.parse(tx.unsignedTransaction);

      const { hash } = await evmWallet.sendTransaction({
        to: parsed.to,
        data: parsed.data,
        value: parsed.value !== undefined ? BigInt(parsed.value) : 0n,
      });

      await yieldApi(`/v1/transactions/${tx.id}/submit-hash`, { hash }, "PUT");
    }
    return action.id;
  };
}

// In a component
const signAndTrack = useYieldSigner();
const address = wallet!.address;
const action = await yieldApi("/v1/actions/enter", { yieldId, address, arguments: { amount: "100" } });
await signAndTrack(action);
```

Crossmint wallets are smart contract wallets: Crossmint sets the gas and executes each call through the wallet, so only `to`, `data` and `value` are passed. The wallet must be on the same chain as the transaction's `chainId`.

Build the `arguments` from `mechanics.arguments.enter.fields` rather than hardcoding `{ amount }`, so the same code works for yields that also need a `validatorAddress` or another field. Amounts are in token units, for example `"100"` for 100 USDC. See [Enter and exit flows](https://docs.yield.xyz/guides/earn/enter-exit-flows.md).

## KYC-gated RWA yields

Tokenized real-world assets, such as US Treasuries, money market funds and private credit, use the same enter and exit flow, so no new signing code is needed. Some issuers require the wallet to be allowlisted first, shown by `mechanics.requirements.kycRequired: true` on the yield.

Check the wallet when it connects, so you can show "Verify identity" instead of "Deposit" for a gated yield:

```typescript theme={null}
const kyc = await yieldApi(`/v1/yields/${yieldId}/kyc/status?address=${address}`);
// kyc.kycStatus: not_required | not_started | pending | approved | rejected
// kyc.authorizeUrl: the issuer's KYC portal, when the issuer provides one
```

Send the user to `authorizeUrl` when the status is `not_started` or `rejected`, ideally in a new tab or after saving the pending deposit so you can resume it, and enter once it is `approved`. If you call enter for a wallet that is not cleared, the API returns `412` with `RwaKycError`, and the message includes the issuer's KYC URL:

```typescript theme={null}
try {
  await signAndTrack(await yieldApi("/v1/actions/enter", { yieldId, address, arguments: { amount: "100000" } }));
} catch (e: any) {
  if (e.status === 412) {
    // Not allowlisted yet: fetch kyc/status and hand the user to authorizeUrl
  } else throw e;
}
```

Read `entryLimits.minimum` before you build the action: many RWA yields have high minimums. Issuer eligibility is in [RWA KYC](https://docs.yield.xyz/documentation/earn/rwas/kyc.md) and on each issuer's page under [RWAs](https://docs.yield.xyz/documentation/earn/rwas/index.md).

## Read the position balance

Balances are lifecycle-aware: each one has a `type` that says whether funds are `active`, `entering`, `exiting`, `withdrawable`, `claimable` or `locked`.

```typescript theme={null}
const { balances } = await yieldApi(`/v1/yields/${yieldId}/balances`, { address });
for (const b of balances) {
  console.log(b.type, b.amount, b.token.symbol, b.pendingActions?.map((p: any) => p.type));
}
```

For many yields or wallets at once, use `POST /v1/yields/balances` with `{ "queries": [{ "address", "network" }] }`, up to 25 queries per request:

```typescript theme={null}
const all = await yieldApi("/v1/yields/balances", {
  queries: [{ address, network: "base" }], // every yield on Base for this wallet
});
```

See [Tracking balances](https://docs.yield.xyz/guides/earn/tracking-balances.md).

## Handle pending actions

A balance can carry `pendingActions`, such as `CLAIM_REWARDS` or `CLAIM_UNSTAKED`. Pass one back to `POST /v1/actions/manage` unchanged, then sign the result the same way as an enter:

```typescript theme={null}
const pending = balances.find((b: any) => b.pendingActions?.length)?.pendingActions[0];
if (pending) {
  const manage = await yieldApi("/v1/actions/manage", {
    yieldId,
    address,
    action: pending.type,
    passthrough: pending.passthrough,
  });
  await signAndTrack(manage);
}
```

## Exit a yield

Exiting is the same pattern as entering:

```typescript theme={null}
const exit = await yieldApi("/v1/actions/exit", {
  yieldId,
  address,
  arguments: { amount: "50" }, // see mechanics.arguments.exit
});
await signAndTrack(exit);
```

Some exits need more than one transaction, for example withdraw and unwrap.

Not every exit settles at once. Staking unbonds wait out the network's cooldown, and many RWA redemptions settle on a NAV strike or over several days. While that happens the position shows as an `exiting` balance. When it settles it becomes `withdrawable` with a `CLAIM_UNSTAKED` pending action, which you complete through `POST /v1/actions/manage` as above. Poll balances on a sensible cadence and show the in-flight state in your UI.

## Track transaction status

After each broadcast, report the hash with `PUT /v1/transactions/{transactionId}/submit-hash`, then poll `GET /v1/transactions/{transactionId}` (or `GET /v1/actions/{actionId}`) until it reaches a terminal status:

```typescript theme={null}
const tx = await yieldApi(`/v1/transactions/${transactionId}`);
console.log(tx.status); // CONFIRMED, FAILED, ...
```

See [Monitoring and alerting](https://docs.yield.xyz/guides/earn/monitoring-alerting.md).

## Integration tips

* Send transactions in `stepIndex` order and skip any already at a terminal status.
* Never change `to`, `data`, `value`, gas or `nonce` before signing.
* Build arguments from `mechanics.arguments.*` for the right fields and units.
* Keep your Yield.xyz API key on the server.
* Geo-blocking is applied by the API for your project; see [Geo-blocking](https://docs.yield.xyz/documentation/advanced-setup/geo-blocking/index.md).
* Create the Crossmint wallet on the chain of the yields you offer, and match it to each transaction's `chainId`.
* Because the wallet is a smart contract wallet, `address` on the action request must be the Crossmint wallet address, not the user's signer key.

## Monetization

How you earn depends on the yield type. Each yield's `mechanics.possibleFeeTakingMechanisms` says which fees you can configure on it.

* **Staking:** deposit fees, deducted atomically in the same transaction, and a share of validator revenue through Yield.xyz's validator agreements. See [Preferred validators](https://docs.yield.xyz/documentation/earn/staking/validators/preferred-validators.md).
* **DeFi:** revenue share from some protocols and curators, and user-facing deposit, performance and management fees through [OAVs](https://docs.yield.xyz/documentation/earn/oavs/single-strategy.md).
* **RWAs:** issuer fees are set by the issuer and passed through. Where an RWA is wrapped in an OAV, you can add your own fees on top.

OAVs also improve the user experience: incentive tokens are sold into the deposit asset and reinvested automatically, wrapping and swapping are handled for the user, and users only ever see their deposit token. See [Earn monetization](https://docs.yield.xyz/documentation/earn/monetization.md) for fee configuration, and [Plans](https://docs.yield.xyz/documentation/plans-limits/plans-tiers.md) for commercial terms.

## Next steps

> [card] [Enter and exit flows](https://docs.yield.xyz/guides/earn/enter-exit-flows.md)
>
> The full request, sign and poll loop.

> [card] [Yield metadata](https://docs.yield.xyz/documentation/earn/core-concepts/yield-metadata.md)
>
> Every field returned on a yield.

> [card] [Shield](https://docs.yield.xyz/documentation/security/shield.md)
>
> Verify each transaction before Crossmint signs it.

> [card] [Embedded wallets](https://docs.yield.xyz/guides/integrations/index.md)
>
> The same flow with other wallet providers.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.