Skip to main content

Function Signature

Description

Prepares and executes a claim of every reward the wallet has accrued in an Earn vault: it builds the payload with prepareClaimRewards and executes it with executeEarnTransaction. Rewards are supported only for vaults from some providers; for any other provider the API rejects the request with an HTTP 400 error. See Provider support.

Parameters

Required Parameters

  • vaultId (string): The vault identifier from listVaults.
  • walletMetadata (WalletMetadata): Non-sensitive wallet metadata persisted from createWalletAccount() / importPrivateKey(). Its chainName must be 'EVM'.

Optional Parameters

  • 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, relays the claim as a gasless transaction. See EVM Gas Sponsorship.
  • chain (Chain): The viem chain for the vault. Its id must match the vault’s chainId. When omitted, the chain is built from rpcUrl, so one of chain or rpcUrl is required.
  • rpcUrl (string): RPC endpoint for the vault’s chain.
  • onStepChange ((step: EarnExecutionStep) => void): Reports transaction as execution proceeds.
  • traceContext (TraceContext): Trace context forwarded to the Dynamic API.

Returns

  • Promise<EarnTransactionResult>: An object with transactionHash, the hash of the claim transaction.

Example

Error Handling

Fails with an HTTP 403 error when Earn is not enabled for your environment, an HTTP 400 error when the vault’s provider does not support rewards, or an HTTP 422 error when the wallet has nothing to claim. Throws when walletMetadata.chainName is not 'EVM', when chain.id mismatches the payload’s chainId, when neither chain nor rpcUrl is given, or when the claim transaction reverts.

See Also

Last modified on October 29, 2026