Skip to main content

Function Signature

Description

Executes an Earn signing payload returned by the client.earn.prepare* methods, signing and sending it with the wallet identified by walletMetadata. When the payload carries an evmApproval and the current allowance is short, the ERC-20 approval is sent first and waited on before the vault transaction. With sponsored: true, the approval and vault call are relayed as one gasless batch through Dynamic gas sponsorship. For a single call that prepares and executes, use depositToEarnVault, withdrawFromEarnVault, or claimEarnRewards.

Parameters

Required Parameters

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. If omitted, the SDK recovers from backup using password.
  • sponsored (boolean): When true, relays the approval and vault call as one gasless batch. See EVM Gas Sponsorship.
  • chain (Chain): The viem chain for the vault. Its id must match the payload’s chainId. When omitted, the chain is built from the payload’s chainId and rpcUrl, so one of chain or rpcUrl is required.
  • rpcUrl (string): RPC endpoint for the vault’s chain. Also used by the relayer to read the wallet’s on-chain state when sponsored is set.
  • onStepChange ((step: EarnExecutionStep) => void): Reports approval then transaction as execution proceeds.
  • traceContext (TraceContext): Trace context forwarded to the Dynamic API.

Returns

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

Example

Error Handling

Throws when walletMetadata.chainName is not 'EVM', when the payload carries no evmTransaction, when chain.id mismatches the payload’s chainId, when neither chain nor rpcUrl is given, or when the approval or vault transaction reverts.

See Also

Last modified on October 29, 2026