Skip to main content

IStandardExecutor

IStandardExecutor Interface

The IStandardExecutor interface defines the standard functions for executing single or batch transactions on behalf of a smart account. This interface ensures that all executor modules interact seamlessly with the wallet's core functionality.

Code Snippet

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

struct Execution {
// The target contract for account to execute.
address target;
// The value for the execution.
uint256 value;
// The call data for the execution.
bytes data;
}

interface IStandardExecutor {
/// @dev Standard execute method.
/// @param target The target contract for account to execute.
/// @param value The value for the execution.
/// @param data The call data for the execution.
function execute(
address target,
uint256 value,
bytes calldata data
) external payable;

/// @dev Standard executeBatch method.
/// @param executions The array of executions.
function executeBatch(Execution[] calldata executions) external payable;
}

Execution Struct

struct Execution {
// The target contract for account to execute.
address target;
// The value for the execution.
uint256 value;
// The call data for the execution.
bytes data;
}

The Execution struct encapsulates the details required to perform a single transaction.

  • target: The address of the target contract to execute.
  • value: The amount of Ether (in wei) to send with the transaction.
  • data: The call data to be sent to the target contract.

Functions

execute

function execute(
address target,
uint256 value,
bytes calldata data
) external payable;

This function performs a single transaction on behalf of the smart account.

  • target: The address of the target contract to execute.
  • value: The amount of Ether (in wei) to send with the transaction.
  • data: The call data to be sent to the target contract.

Usage: This function allows the smart account to interact with other contracts, send Ether, and call functions on the target contract.

executeBatch

function executeBatch(Execution[] calldata executions) external payable;

This function performs multiple transactions in a single call, enabling batch processing of transactions.

  • executions: An array of Execution structs, each representing a transaction to be executed.

Usage: This function is useful for scenarios where multiple transactions need to be executed in sequence, reducing the overhead of multiple calls and ensuring atomicity of the batch operations.


Example Use Cases

Single Transaction Execution

A module implementing the IStandardExecutor interface can use the execute function to perform actions such as:

  1. Calling a function on another contract.
  2. Sending Ether to an address.
  3. Interacting with decentralized finance (DeFi) protocols.

Batch Transaction Execution

A module implementing the IStandardExecutor interface can use the executeBatch function to:

  1. Perform a series of related transactions in one go.
  2. Execute multiple trades or interactions with different protocols.
  3. Automate complex workflows that require multiple contract interactions.

By implementing these functions, third-party developers can create modules that allow the smart account to interact with various contracts and perform complex operations efficiently. This interface provides a standardized way to handle single and batch executions, ensuring compatibility and enhancing the wallet's functionality.