Skip to main content

Legend Prime API

The Legend Prime API gives you programmatic access to Legend’s non-custodial DeFi infrastructure. Create accounts, earn yield, transfer assets, and monitor portfolios — all through a simple REST API.

What you can do

  • Create accounts — Provision sub-accounts for your users, each with their own on-chain wallet
  • Earn yield — Deploy assets into DeFi protocols like Compound, Morpho, and Aave
  • Transfer assets — Move funds between wallets and across networks
  • Monitor portfolios — View balances, track activities, and poll for real-time updates

How it works

Legend uses a plan-sign-execute model. Your server creates a plan (e.g., “earn 1000 USDC on Compound”), the account’s signer approves it with an EIP-712 signature, and Legend executes the on-chain transactions.
Your Server                    Legend                      Blockchain
    │                            │                            │
    ├── POST /plan/earn ────────>│                            │
    │<── plan_id + digest ───────│                            │
    │                            │                            │
    │── sign(digest) ──┐         │                            │
    │<─────────────────┘         │                            │
    │                            │                            │
    ├── POST /plan/execute ─────>│── submit transaction ─────>│
    │<── { status: executing } ──│<── confirmation ───────────│
    │                            │                            │
    ├── GET /activities ────────>│                            │
    │<── [{ status: confirmed }]─│                            │

Architecture

Every integration starts with a Prime Account — your organization’s container. Under it, you create sub-accounts, each with its own on-chain wallet and signer key.
Prime Account (your organization)
├── Query Key 1 (API access)
├── Query Key 2 (rotatable)

├── Sub-Account acc_abc123 (EOA signer)
│   └── Quark Wallet 0x7f3a...

├── Sub-Account acc_def456 (EOA signer)
│   └── Quark Wallet 0x9b2c...

└── Sub-Account acc_ghi789 (Turnkey P256 signer)
    └── Quark Wallet 0x1d4e...

Non-custodial

Legend never holds your users’ keys. Query keys grant API access (creating accounts, viewing portfolios, creating plans), but moving funds always requires the account signer’s approval. The signer key — whether an EOA private key or a Turnkey-managed key — stays with you or your user.

Next steps