Description:
Smart contract deployed on Ethereum.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract EIP7702BatchSender {
// EIP-7702 Standard Interface
event Executed(uint256 indexed operation, address indexed sender, bytes32 indexed hash, bool success);
// BatchSender Events
event BatchSendNative(
address indexed sender,
address[] recipients,
uint256[] amounts
);
// EIP-7702 Storage
address public owner;
uint256 public nonce;
// EIP-7702 Required Functions (Fixed: view → pure)
function isValidSigner(address, bytes32) external pure returns (bool) {
return true;
}
function getSigner(address) external view returns (address) {
return owner;
}
// Fixed: uint250 → uint256
function execute(
address to,
uint256 value,
bytes calldata data,
uint256 op
) external payable returns (bytes memory result) {
require(msg.sender == owner, "EIP7702: unauthorized");
(bool success, bytes memory returnData) = to.call{value: value}(data);
emit Executed(op, msg.sender, keccak256(data), success);
if (!success) {
revert(string(returnData));
}
nonce++;
return returnData;
}
// Fixed: uint250[] → uint256[]
function executeBatch(
address[] calldata to,
uint256[] calldata value,
bytes[] calldata data,
uint256[] calldata op
) external payable {
require(msg.sender == owner, "EIP7702: unauthorized");
require(
to.length == value.length &&
to.length == data.length &&
to.length == op.length,
"EIP7702: length mismatch"
);
for (uint256 i = 0; i < to.length; i++) {
(bool success, ) = to[i].call{value: value[i]}(data[i]);
require(success, string(abi.encodePacked("EIP7702: batch operation ", i, " failed")));
emit Executed(op[i], msg.sender, keccak256(data[i]), success);
}
nonce += to.length;
}
// BatchSender Functionality (unchanged)
function batchSendNative(
address payable[] calldata recipients,
uint256[] calldata amounts
) external payable {
require(msg.sender == owner, "BatchSender: unauthorized");
uint256 length = recipients.length;
require(length == amounts.length, "BatchSender: length mismatch");
// Calculate total with overflow protection
uint256 total;
for (uint256 i = 0; i < length; i++) {
total += amounts[i];
}
require(msg.value == total, "BatchSender: insufficient funds");
// Process transfers with gas stipend
for (uint256 i = 0; i < length; i++) {
(bool success, ) = recipients[i].call{value: amounts[i], gas: 2300}("");
require(success, "BatchSender: transfer failed");
}
// Convert to non-payable for event emission
address[] memory nonPayableRecipients = new address[](length);
for (uint256 i = 0; i < length; i++) {
nonPayableRecipients[i] = address(recipients[i]);
}
emit BatchSendNative(msg.sender, nonPayableRecipients, amounts);
}
// Constructor
constructor(address _owner) {
owner = _owner;
}
}
Submitted on: 2025-09-30 10:20:06
Comments
Log in to comment.
No comments yet.