Skip to main content

Embed a Privy wallet in an investor front end

Embed the Privy SDK in your investor front end, sign investors in with the token DALP issues, and send a gas-sponsored transfer from their wallet.

Overview

An investor can hold their own key in an embedded wallet managed by Privy. Your front end embeds the Privy SDK, signs the investor into Privy with a DALP-issued JWT, and calls the Platform API to link the wallet, create the identity, deploy the smart wallet, and submit transfers. DALP prepares and broadcasts transactions but never holds the key.

Because Privy authenticates the investor from the DALP token, your front end needs no separate Privy login. Protect DALP sign-in with the same security posture as the wallet itself.

This guide covers the embedded-wallet path when an investor joins an organisation. See Onboard an investor through the API for managed custody and Let an investor choose custody for custody selection and browser wallets.

When the organisation's gas payer is a paymaster, transfers are sponsored and the smart wallet needs no native gas token. Otherwise the smart wallet pays its own gas, and preparing a transfer from an unfunded wallet returns DALP-14034 with shortfallWei. Fiat on-ramps and off-ramps stay inside Privy in your front end.

The sequence at a glance

Seven steps from the offered provider to a sponsored transfer signed in Privy.Step 1 reads the offered providers and the Privy app id with GET /api/v2/custody/investor-provider. Step 2 signs the investor in to Privy with the token from GET /api/auth/token, which Privy checks against GET /api/auth/jwks. Step 3 creates the participant and proves the Privy key. Step 4 creates the identity. Step 5 deploys the smart wallet when the organisation uses account abstraction. Step 6 prepares the transfer with POST /api/v2/transaction-preparations. Step 7 signs the user operation typed data in Privy and finalises it, and the organisation's paymaster pays the gas.Seven steps from the offered provider to a sponsored transfer signed in Privy.The same figure as the desktop variant, drawn portrait for phone widths. The steps run in order: read the offered providers, sign in to Privy, create the participant and prove the key, create the identity, deploy the smart wallet, prepare the transfer, then sign in Privy and finalise.

Steps 1 and 2 happen before any wallet exists, and steps 3 to 5 repeat only until the investor is set up.

Embed the Privy SDK

Embed @privy-io/react-auth (the DALP Investor portal pins version 3.51.4). Wrap your application in PrivyProvider with these options:

  • appId (and optional clientId): read dynamically from DALP in step 1, owned by either the deployment operator or the organisation.
  • externalWallets.disableAllExternalWallets: true, so investors sign only with their embedded wallet.
  • embeddedWallets.ethereum.createOnLogin: "off". Create the wallet explicitly when the investor reaches that step.
  • supportedChains and defaultChain: set from chainId returned by GET /api/v2/organizations/{organizationId}/joinable-participants.

Set up Privy to trust DALP

Enable custom JWT-based authentication in the Privy dashboard:

Privy setting
Value
JWT-based auth
On
User id claim
sub
JWKS endpoint
<platform URL>/api/auth/jwks
Allowed origin
The origin serving your investor front end

<platform URL> must be publicly reachable so Privy can fetch the JWKS. The token's sub claim holds the investor's DALP user id.

Step 1: read the offered providers

Call GET /api/v2/custody/investor-provider. It returns data (designated default or null) and options (every configuration offered to investors on the request's network, default first). Render options directly without applying local defaults or filters.

A Privy entry carries clientConfiguration with kind: "privy", tenant, appId, and optional clientId. If no option offers Privy, omit Privy from the UI (Which provider is offered).

Step 2: sign the investor in to Privy

With the investor's DALP session, call GET /api/auth/token, which returns {"token": "<jwt>"}. Pass a getter calling this route to useSubscribeToJwtAuthWithFlag as getExternalJwt alongside isAuthenticated and isLoading. Privy verifies the JWT against GET /api/auth/jwks and refreshes it by calling getExternalJwt again on expiry.

Once Privy reports the investor as authenticated, create the embedded Ethereum wallet. Use its address as signingAddress in step 3.

Step 3: create the participant and prove the key

Run these calls in order using the investor's DALP session:

  1. GET /api/v2/organizations/{organizationId}/joinable-participants reads chainId, aaEnabled, and any reusable participants.
  2. POST /api/v2/participants with organizationId, providerConfigurationId, and walletVerification creates a pending participant (skip if resuming one).
  3. GET /api/v2/users/me/custody-accounts with participantId lists existing accounts so you can reuse one already linked to Privy on this network.
  4. POST /api/v2/users/me/custody-account-control-preparations with providerConfigurationId, participantId, and signingAddress returns message, binding, and account.
  5. Have the investor sign message as a personal message in Privy.
  6. POST /api/v2/users/me/custody-accounts/lifecycles with proof (binding, account, and JSON-encoded artifact: {"kind":"evm-self-custody-control","signature":"<signature>"}), walletVerification, and X-Step-Up-Challenge (from POST /api/v2/step-up-challenges, fetched automatically by the SDK) returns requestId. Prompt for a fresh code if step 2 consumed a single-use factor.
  7. Poll GET /api/v2/users/me/custody-account-requests/{requestId} (or append /stream) until state reaches succeeded.

The account is ready once GET /api/v2/users/me/custody-accounts reports both accountLifecycle and contextLifecycle as active. See Step 3b of Let an investor choose custody for full request and response payloads.

Step 4: create the identity

Call GET /api/v2/system/identities/me with X-Participant, X-Custody-Account-Id, and X-Chain-Id. Treat both 200 (status: "NOT_PROVISIONED") and 404 (IDENTITY_SCOPE_NOT_FOUND) as no identity.

If missing, call POST /api/v2/identities with wallet and walletVerification (prompting for a fresh code unless using a transaction PIN). The first call returns 409 (DALP-12389) carrying data.signingPayload.typedData. Sign it with eth_signTypedData_v4 in Privy, resend with externalMessageAuthorization: {"signature": "<signature>"}, and wait for settlement (Idempotency and async settlement). Continue registration and KYC in Onboard an investor through the API from step 3.

Step 5: deploy the smart wallet

Skip this step when aaEnabled is false. Otherwise call POST /api/v2/users/me/custody-accounts/{custodyAccountId}/smart-wallet-deployment with {}. Sign data.signingPayload.typedData from the 409 response with Privy, then resend with externalMessageAuthorization: {"signature": "<signature>"} to receive the smart wallet address. No native gas token is required.

Step 6: send a sponsored transfer

A transfer runs in three calls:

  1. Prepare: Call POST /api/v2/transaction-preparations with custodyAccountId, executionMode: "prefer-aa", summary, and operation (kind, contractAddress, callData, optional value). The response returns preparedUserOperation (userOperationHash and previewData). When paymaster sponsorship is active, previewData carries paymaster and paymasterData (valid for 300 seconds by default).
  2. Sign: Build EIP-712 typed data from previewData for previewData.entryPointAddress (for example with viem's getUserOperationTypedData), confirm its hash matches userOperationHash, and sign with eth_signTypedData_v4 in Privy (plain message signing fails).
  3. Finalise: Call POST /api/v2/transaction-preparations/{preparationId}/transitions with:
{
  "action": "finalize",
  "artifact": {
    "_tag": "Eip4337UserOperationAuthorization",
    "kind": "eip-4337-user-operation",
    "userOperationHash": "0x8a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "signature": "0x4c1d8f2a9b3e41c7a2f08d6e1b5c9a3f7d2e8b4a1c6f0d9e2a5b8c3d7f1e4a9b2c6d0e3f4a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a41c"
  }
}

Follow the returned transactionRequestId on GET /api/v2/transaction-requests/{transactionId}/stream until it reaches a terminal state.

Which provider is offered

The deployment controls which provider kinds exist via custody.providers.<kind>.enabled. Each organisation chooses which enabled configurations investors see via offeredToInvestors, and designates one default via investorProvider. Offering Privy requires configuration only, with no code changes.

Errors

Steps 3 to 5 also return the refusals listed in The refusals each step returns.

Code
Status
When it appears
What to do
422
Gas is not sponsored and the smart wallet lacks native currency for the transfer.
Fund the smart wallet with at least shortfallWei, then prepare again.
400
Missing walletVerification or invalid X-Step-Up-Challenge on a session call.
Include walletVerification, fetch a fresh challenge, and retry.
409
Preparation binding mismatch, idempotency conflict, or another open owner-signed operation on the smart wallet.
Read the preparation and match its binding, use a new idempotency key, or finish/expire the open operation.

See DALP error index and Read and handle DALP errors for full envelope details.

Next steps