Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-7638 proposes a compact encoding format for executing multiple calls through a smart contract account (SCA), with the aim of reducing gas costs and supporting atomic execution.
This article translates, summarizes, and expands on the following proposal.
More EIP explainers:
Overview
Batch Calls Encoding (BCE) combines the data for multiple contract calls into a compact byte sequence.
A smart contract account can decode that sequence and execute the calls within one transaction. Compared with conventional ABI encoding of an array of call structures, compact encoding can reduce calldata size and its associated gas cost.
Motivation
Consider an NFT owned by Alice that Bob needs to transfer to another address.
An approval followed by a transferFrom operation ordinarily requires separate authorized actions. A smart contract account can support batching these actions into one transaction where the ownership, caller identity, and approval requirements are satisfied.
If the account propagates a failure from any constituent call, the entire batch reverts, providing atomic execution.
Encoding the call parameters compactly can also reduce the amount of transaction data.
A relayed execution architecture can combine batching with a separate fee-payment arrangement. For example:
- A user authorizes several operations through a smart contract account.
- The user agrees to pay a relayer 10 USDT as a service fee.
- The relayer submits the transaction, pays network gas in ETH, and receives the agreed USDT fee through the implemented payment mechanism.
A bundler or relayer submits an outer transaction on behalf of users. In ERC-4337, a bundler collects UserOperations and submits them through the EntryPoint contract.
A smart contract account can execute internal calls but cannot independently originate an ordinary signed Ethereum transaction in the same manner as an EOA.
For additional background:
The user can sign the intended batch and provide its encoded data to a relayer. The relayer may decline to submit the transaction if the proposed compensation is insufficient.
The actual fee settlement, signature verification, and authorization policy depend on the wallet and relayer implementation. BCE itself defines an encoding format, not a complete fee-sponsorship protocol.
ERC-4337 also supports alternative fee-payment arrangements. BCE can be used alongside an account abstraction architecture if the account supports decoding and executing the format.
For ERC-4337, see the following articles.
ERC-4337: Account abstraction without protocol-level changes
Specification
The proposal defines an encoding that smart contract accounts and compatible wallets can use to represent multiple calls.
A DApp communicates its intended operations to a wallet, which encodes the corresponding calls for the smart contract account.
Each call is represented by the following fields.
graph LR
A["to (20bytes)"] --- B["value (32bytes)"] --- C["data length (32bytes)"] --- D["data (bytes)"]to- The destination address, occupying 20 bytes.
value- The ETH amount in wei, occupying 32 bytes.
data length- The calldata length in bytes, occupying 32 bytes.
data- The encoded calldata of the operation.
A batch consists of multiple concatenated call records. Each record has an 84-byte fixed-length header followed by its variable-length calldata.
Rationale
Each operation contains a destination, ETH value, and calldata.
A conventional approach represents these parameters using an array of Solidity structures.
struct Call {
address to;
uint256 value;
bytes data;
}
Call[] calls;Standard ABI encoding of a dynamic array of structures can introduce padding, offsets, and length fields. It does not normally embed explicit type names in the encoded data.
BCE instead uses a predefined layout and concatenates its fields, reducing overhead associated with the conventional ABI representation.
A decoder reads the fixed-width fields and uses the encoded data length to determine the boundary of the next call.
Implementations must validate these boundaries, reject malformed or truncated records, and handle the complete batch according to their execution policy.
Actual gas savings depend on calldata contents, decoding overhead, and the applicable gas schedule.
Compatibility
BCE does not require changes to Ethereum's consensus rules or existing ERC interfaces.
Smart contract accounts and wallets must explicitly support the proposed encoding to use it. Existing accounts do not automatically acquire this capability.
Reference implementation
The proposal specifies the batch encoding rather than a complete smart contract account implementation.
The following illustrative architecture allows a user to authorize multiple calls with a signature and a relayer to submit the transaction.
SmartWallet.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
contract SmartWallet {
using ECDSA for bytes32;
uint32 public valid = 1; //to make AtomSign invalid
address private immutable original;
address public owner;
address public bundler;
mapping(bytes32 => bool) public usedMsgHashes;
modifier onlyBundler() {
require(
bundler == msg.sender,
"onlyBundler: caller is not the bundler"
);
_;
}
modifier onlyOwnerAndOriginal() {
require(
owner == msg.sender || original == msg.sender,
"onlyOwnerAndOriginal: caller is not the owner"
);
_;
}
constructor(address _bundler) {
original = address(this);
owner = msg.sender;
bundler = _bundler;
}
function atomSignCall(
bytes calldata atomCallbytes,
uint32 deadline,
bytes calldata signature
) external onlyBundler {
require(deadline >= block.timestamp, "atomSignCall: Expired");
bytes32 msgHash = keccak256(
bytes.concat(
msg.data[:msg.data.length - signature.length - 32],
bytes32(block.chainid),
bytes20(address(this)),
bytes4(valid)
)
);
require(!usedMsgHashes[msgHash], "atomSignCall: Used msgHash");
require(
owner == msgHash.toEthSignedMessageHash().recover(signature),
"atomSignCall: Invalid Signature"
);
//do calls
uint i;
while(i < atomCallbytes.length) {
address to = address(uint160(bytes20(atomCallbytes[i:i+20])));
uint value = uint(bytes32(atomCallbytes[i+20:i+52]));
uint len = uint(bytes32(atomCallbytes[i+52:i+84]));
(bool success, bytes memory result) = to.call{value: value}(atomCallbytes[i+84:i+84+len]);
if (!success) {
assembly {
revert(add(result, 32), mload(result))
}
}
i += 84 + len;
}
usedMsgHashes[msgHash] = true;
}
/**
* if you signed something then regretted, make it invalid
*/
function makeAtomSignInvalid() public onlyOwnerAndOriginal {
valid = uint32(uint(blockhash(block.number)));
}
}The example is intended to:
- Execute multiple calls within one transaction.
- Validate the account owner's signature.
- Reduce calldata overhead through compact encoding.
- Enforce a deadline and reject previously consumed message hashes.
Variables and mappings
valid- A value included in the signed message to support invalidation of outstanding authorizations.
original- The address captured when the contract is deployed.
owner- The account owner's address.
bundler- The authorized relayer address.
usedMsgHashes- Tracks message hashes that have already been consumed.
Modifiers
onlyBundler- Requires the caller to match the configured bundler.
onlyOwnerAndOriginal- Requires the caller to be either the owner or the original contract address, according to the displayed condition.
Constructor
Initializes the owner, bundler, and original contract address.
atomSignCall
Verifies a signature and executes the encoded calls. The displayed implementation restricts access to the configured bundler.
Parameters
atomCallbytes- The encoded batch of calls.
deadline- The timestamp after which the authorization is no longer valid.
signature- The owner's signature over the expected message.
Execution flow
- Check the deadline
- Require the supplied deadline to be greater than or equal to the current block timestamp.
- Construct the message hash
- The example takes a portion of msg.data and concatenates it with the chain ID, contract address, and valid value before hashing.
- Correctly binding the complete intended batch and deadline requires an unambiguous signing and encoding scheme.
- Check replay state
- Reject a message hash that has already been consumed.
- Validate the signature
- Recover the signer from the Ethereum signed-message hash and compare it with the configured owner.
- Execute the calls
- Decode each destination, ETH value, data length, and calldata in sequence.
- Perform the corresponding external call.
- Propagate revert data if a call fails, rolling back the batch.
- Record the message hash
- Mark the message hash as consumed.
makeAtomSignInvalid
Updates the valid value to invalidate signatures associated with the previous value. The function is restricted by onlyOwnerAndOriginal.
Execution flow
- Verify that the caller satisfies the owner-or-original-address condition.
- Update the value used in the signature-validation scheme.
The displayed implementation derives the new value from blockhash(block.number). This is problematic because the EVM BLOCKHASH operation returns zero for the current block. A properly designed nonce or invalidation counter is required instead.
Bundler.sol
pragma solidity ^0.8.0;
contract Bundler {
address public owner;
modifier onlyOwner() {
require(
owner == msg.sender,
"onlyOwner: caller is not the owner"
);
_;
}
constructor() {
owner = msg.sender;
}
function executeOperation(
address wallet,
bytes calldata data
) public onlyOwner {
(bool success, bytes memory result) = _callTo.call{value: 0}(data);
if (!success) {
assembly {
revert(add(result, 32), mload(result))
}
}
}
}executeOperation
The intended function allows the authorized owner of the relayer contract to submit a call to a specified wallet and propagate a failure.
Parameters
wallet- The intended wallet destination.
data- The encoded calldata to execute.
Execution flow
- Check authorization
- The onlyOwner modifier verifies the caller.
- Execute the call
- The intended operation calls the wallet with the supplied calldata and zero ETH value.
- The low-level call returns a success flag and return data.
- Handle failures
- If the call fails, the assembly code propagates the returned revert data.
The reference code uses _callTo rather than its declared wallet parameter. That identifier is not defined in the displayed contract, so the example cannot compile as written.
For additional background on Solidity assembly, see:
The reference implementations are preserved unchanged for historical comparison. They have not been independently compiled or audited. In addition to the issues noted above, the wallet's signature hash relies on slicing raw ABI calldata, and its replay flag is updated after external calls. These choices require careful validation of signature binding, calldata padding, and reentrancy behavior before any production use.
Security
The proposal focuses on compact call encoding. It does not provide confidentiality, hide personal information, or define a complete account authorization protocol.
Implementers must independently enforce correct decoding, authorization, replay protection, execution boundaries, and the intended atomicity policy.
Citation
George (@JXRow), Zisu (@lazy1523), "ERC-7638: Batch Calls Encoding in SCA [DRAFT]," Ethereum Improvement Proposals, no. 7638, February 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7638.
Conclusion
ERC-7638 proposes a compact format for representing multiple smart contract calls in a single byte sequence. A compatible smart contract account can decode and execute the batch, potentially reducing calldata overhead while supporting atomic execution and integration with relayed transactions.
Questions are welcome via Twitter @cardene777.
Other publications:




