Skip to main content
This guide shows how to build a yield account feature for a neobank or fintech app. Your users deposit funds, which are allocated to a Morpho lending vault via Trails. The blockchain layer is fully abstracted: your users see a savings balance and an interest rate, nothing else.

How it works

Users never interact with a blockchain directly. Wallet creation, gas, and transaction signing all happen in the background via a non-custodial wallet tied to their account.

Prerequisites

  • A Trails API key
  • A wagmi-compatible non-custodial wallet provider (Polygon Wallet, Privy, Dynamic, or similar), which powers the invisible signing layer your users never see

Install

Addresses

Step 1: Set up the non-custodial wallet

Each user gets a non-custodial wallet created automatically at sign-up, with no crypto onboarding and no seed phrases. This wallet is the signing key for their yield account; users never see or interact with it directly.
Users log in with email, phone, or SSO via your standard auth flow. Privy silently provisions the wallet in the background:

Step 2: Discover the vault market

Composable actions use market IDs instead of hand-encoded vault calldata. Fetch the available vaults, then pass the selected market’s id to the deposit action:

Step 3: Quote and execute the deposit

Use useQuote with the deposit action. Trails quotes the route, handles any bridge or swap, and executes the vault deposit from the destination intent wallet:
From the user’s perspective this is still one confirmation. From your app’s perspective, onStatusUpdate gives you progress events for the route and destination action so you can update the savings balance after settlement.

Withdraw

Users can withdraw their full balance (principal + accrued yield) at any time. Use useEarnBalances to read the user’s position, then build a plain ERC-4626 redeem transaction with viem:
useEarnBalances returns the normalized earn position for the wallet, including the market yieldId, the display balance, and protocol-specific share/output token balances. Until the SDK exposes a higher-level withdraw helper, you can encode the vault’s ERC-4626 redeem call directly and submit it with the user’s wallet.

Next steps

Trails API Reference

Full reference for QuoteIntent, CommitIntent, ExecuteIntent, and monitoring.

Wallet Compatibility

Full list of supported non-custodial wallet providers including Privy, Dynamic, and WalletConnect.

Smart Sessions

Automate recurring deposits: schedule weekly transfers to savings without per-transaction prompts.

Treasury Wallet

Sweep funds from user accounts into a central treasury wallet on a schedule.