Blockchain / Global / Address
Contract
0x3976E43fa6f4F367652Fe83c0678CB139866254D
- Balance
- 0 SOMI
- Transactions sent
- 1
- Type
- Contract · 2,043 bytes of code
NativeBatchSender Verified
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- Solidity
- Optimization
- No
- EVM version
- prague
- License
- —
- Verified
- 2026-10-12
NativeBatchSender.sol
Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract NativeBatchSender {
error LengthMismatch();
error IncorrectMsgValue();
error TransferFailed();
event BatchSend(address indexed sender, uint256 total, uint256 count);
function batchSend(
address payable[] calldata recipients,
uint256[] calldata amounts
) external payable {
if (recipients.length != amounts.length) revert LengthMismatch();
uint256 total;
unchecked {
for (uint256 i = 0; i < amounts.length; i++) {
total += amounts[i];
}
}
if (msg.value != total) revert IncorrectMsgValue();
for (uint256 i = 0; i < recipients.length; i++) {
(bool ok, ) = recipients[i].call{value: amounts[i]}("");
if (!ok) revert TransferFailed();
}
emit BatchSend(msg.sender, total, recipients.length);
}
function batchSendSame(
address payable[] calldata recipients,
uint256 amount
) external payable {
uint256 count = recipients.length;
uint256 total = amount * count;
if (msg.value != total) revert IncorrectMsgValue();
for (uint256 i = 0; i < count; i++) {
(bool ok, ) = recipients[i].call{value: amount}("");
if (!ok) revert TransferFailed();
}
emit BatchSend(msg.sender, total, count);
}
receive() external payable {
revert IncorrectMsgValue();
}
fallback() external payable {
revert IncorrectMsgValue();
}
}
ABI · 8 entries
json
[
{
"name": "IncorrectMsgValue",
"type": "error",
"inputs": []
},
{
"name": "LengthMismatch",
"type": "error",
"inputs": []
},
{
"name": "TransferFailed",
"type": "error",
"inputs": []
},
{
"name": "BatchSend",
"type": "event",
"inputs": [
{
"name": "sender",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "total",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "count",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "fallback",
"stateMutability": "payable"
},
{
"name": "batchSend",
"type": "function",
"inputs": [
{
"name": "recipients",
"type": "address[]",
"internalType": "address payable[]"
},
{
"name": "amounts",
"type": "uint256[]",
"internalType": "uint256[]"
}
],
"outputs": [],
"stateMutability": "payable"
},
{
"name": "batchSendSame",
"type": "function",
"inputs": [
{
"name": "recipients",
"type": "address[]",
"internalType": "address payable[]"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "payable"
},
{
"type": "receive",
"stateMutability": "payable"
}
]