Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4.8 KiB
ERC7821
Minimal batch executor mixin.
This contract can be inherited to create fully-fledged smart accounts.
If you merely want to combine approve-swap transactions into a single transaction
using EIP-7702, you will need to implement basic
ERC-1271 isValidSignature functionality to
validate signatures with ecrecover against the EOA address. This is necessary because some
signature checks skip ecrecover if the signer has code. For a basic EOA batch executor,
please refer to BEBE, which inherits from this class.
Inherits:
Structs
Call
struct Call {
address to; // Replaced as `address(this)` if `address(0)`. Renamed to `to` for Ithaca Porto.
uint256 value; // Amount of native currency (i.e. Ether) to send.
bytes data; // Calldata to send with the call.
}
Call struct for the execute function.
Custom Errors
UnsupportedExecutionMode()
error UnsupportedExecutionMode()
The execution mode is not supported.
BatchOfBatchesDecodingError()
error BatchOfBatchesDecodingError()
Cannot decode executionData as a batch of batches abi.encode(bytes[]).
Execution Operations
execute(bytes32,bytes)
function execute(bytes32 mode, bytes calldata executionData)
public
payable
virtual
Executes the calls in executionData.
Reverts and bubbles up error if any call fails.
executionData encoding (single batch):
- If
opDatais empty,executionDatais simplyabi.encode(calls). - Else,
executionDataisabi.encode(calls, opData).
See: https://eips.ethereum.org/EIPS/eip-7579
executionDataencoding (batch of batches): executionDataisabi.encode(bytes[]), where each element inbytes[]
is anexecutionDatafor a single batch.
Supported modes:0x01000000000000000000...: Single batch. Does not support optionalopData.0x01000000000078210001...: Single batch. Supports optionalopData.0x01000000000078210002...: Batch of batches.
For the "batch of batches" mode, each batch will be recursively passed into
executeinternally with mode0x01000000000078210001....
Useful for passing in batches signed by different signers.
Authorization checks:- If
opDatais empty, the implementation SHOULD require that
msg.sender == address(this). - If
opDatais not empty, the implementation SHOULD use the signature
encoded inopDatato determine if the caller can perform the execution. - If
msg.senderis an authorized entry point, thenexecuteMAY accept
calls from the entry point, and MAY useopDatafor specialized logic.
opDatamay be used to store additional data for authentication,
paymaster data, gas limits, etc.
supportsExecutionMode(bytes32)
function supportsExecutionMode(bytes32 mode)
public
view
virtual
returns (bool result)
Provided for execution mode support detection.
Internal Helpers
_executionModeId(bytes32)
function _executionModeId(bytes32 mode)
internal
view
virtual
returns (uint256 id)
0: invalid mode, 1: no opData support, 2: with opData support, 3: batch of batches.
_executeBatchOfBatches(bytes32,bytes)
function _executeBatchOfBatches(bytes32 mode, bytes calldata executionData)
internal
virtual
For execution of a batch of batches.
_execute(bytes32,bytes,Call[],bytes)
function _execute(
bytes32 mode,
bytes calldata executionData,
Call[] calldata calls,
bytes calldata opData
) internal virtual
Executes the calls.
Reverts and bubbles up error if any call fails.
The mode and executionData are passed along in case there's a need to use them.
_execute(Call[],bytes32)
function _execute(Call[] calldata calls, bytes32 extraData)
internal
virtual
Executes the calls.
Reverts and bubbles up error if any call fails.
extraData can be any supplementary data (e.g. a memory pointer, some hash).
_execute(address,uint256,bytes,bytes32)
function _execute(
address to,
uint256 value,
bytes calldata data,
bytes32 extraData
) internal virtual
Executes the call.
Reverts and bubbles up error if any call fails.
extraData can be any supplementary data (e.g. a memory pointer, some hash).
_get(Call[],uint256)
function _get(Call[] calldata calls, uint256 i)
internal
view
virtual
returns (address to, uint256 value, bytes calldata data)
Convenience function for getting calls[i], without bounds checks.