Skip to main content

Function Signature

Description

Prepares and executes a deposit into an Earn vault in one call: it builds the payload with prepareDeposit and executes its ordered Solana transaction sequence with executeEarnTransaction. Shares are credited to receiverAddress when given, otherwise to the depositing wallet.

Parameters

Required Parameters

  • vaultId (string): The vault identifier from listVaults.
  • amount (string): How much of the vault’s underlying asset to deposit, in the asset’s human-readable units ('12.5' USDC, not '12500000'). Needs a leading zero ('0.01', not '.01').
  • walletMetadata (WalletMetadata): Non-sensitive wallet metadata persisted from createWalletAccount() / importPrivateKey(). Its chainName must be 'SVM'.

Optional Parameters

  • receiverAddress (string): The address that receives the vault shares. Defaults to the depositing wallet.
  • password (string): Required if the wallet was created with backUpToDynamic: true. Used for backup decryption when externalServerKeyShares is not provided.
  • externalServerKeyShares (ServerKeyShare[]): Caller-supplied plaintext shares.
  • sponsored (boolean): When true, sponsors every transaction in the sequence. See SVM Gas Sponsorship.
  • rpcUrl (string): Solana RPC endpoint. Defaults to the public cluster for the payload’s chainId (101 mainnet, 103 devnet).
  • chainId (string): The Solana chain identifier.
  • context (SignMessageContext): Signing context forwarded to the transaction signer.
  • onStepChange ((step: EarnExecutionStep) => void): Reports transaction once per transaction in the sequence.
  • onTransactionStepChange ((step: EarnTransactionStepProgress) => void): Invoked as each transaction is about to be signed, with its ordinal, the total, and an optional label.
  • traceContext (TraceContext): Trace context forwarded to the Dynamic API.

Returns

  • Promise<EarnTransactionResult>: An object with transactionHash, the signature of the last transaction in the sequence.

Example

Error Handling

Fails with an HTTP 403 error when Earn is not enabled for your environment or an HTTP 400 error when the amount or address is invalid. Throws when walletMetadata.chainName is not 'SVM', when the payload carries no transactions sequence, or when a sequence step expires or fails; see executeEarnTransaction for EarnSolanaStepError.

See Also

Last modified on October 29, 2026