Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.privy.io/llms.txt

Use this file to discover all available pages before exploring further.

Deposit assets from a wallet into a vault using the deposit endpoint. Privy handles the ERC-20 approval and deposit in a single call. The wallet depositing funds and the admin wallet will receive shares corresponding to the fee share split.
View the full API reference for the deposit endpoint.
If your app has gas sponsorship configured, usage of the /earn/ethereum/deposit endpoint will be gas-sponsored by default. There is no need to specify additional parameters for sponsorship.

Deposit flow

  1. Privy approves the vault to spend the specified amount of the wallet’s ERC-20 tokens.
  2. The vault converts the deposited assets into vault shares at the current share price.
  3. Shares are split between the depositing wallet and your app’s admin wallet based on the fee percentage configured during setup.
  4. The deposit is created as a wallet action with status pending. Privy prepares, signs, and broadcasts the transaction asynchronously. The status moves to succeeded once confirmed onchain.
The share_amount in the response is null while the action is pending. Once the action succeeds, it reflects the number of shares minted to the depositing wallet. To see the admin wallet’s fee shares, query the admin wallet’s position.
The wallet must hold enough of the deposit token to cover the full amount. If the balance is insufficient, the deposit fails. Your app should check the wallet’s token balance before initiating a deposit.

Usage

Use the deposit convenience method on the earn ethereum service to deposit assets into a vault.
const response = await privy.wallets().earn().ethereum().deposit('insert-wallet-id', {
  vault_id: '<your-vault-id>',
  amount: '1.5',
  authorization_context: {
    authorization_private_keys: ['<authorization-private-key>'],
  },
});
The method returns an EarnDepositActionResponse with the pending wallet action. Poll the status with get wallet action, or listen for the wallet_action.earn_deposit.succeeded webhook.
Poll the status with get wallet action, or listen for the wallet_action.earn_deposit.succeeded webhook to know when Privy confirms the deposit onchain.
A rejected status means the action failed before any transaction was signed or broadcast — for example, due to insufficient balance or a policy violation. Your app can safely retry the request. A failed status means a transaction was broadcast but reverted onchain. Inspect the action’s steps for details.

Next steps

Withdraw assets

Withdraw deposited assets with accrued yield.