Address Contract Verified
Address
0xf4B5CE5c651259F4065F8A9EBBF3162f7145dAfb
Balance
0 ETH
Nonce
1
Code Size
8378 bytes
Creator
0x65C07cCF...1f99 at tx 0xd5bacfd5...99ca65
Indexed Transactions
0
Contract Bytecode
8378 bytes
0x608060405260043610610073575f3560e01c80638da5cb5b1161004d5780638da5cb5b1461011d578063b2118a8d14610147578063d0de1ddc1461016f578063f2fde38b14610197576100b3565b8063469f0ab5146100b7578063690d8320146100df578063715018a614610107576100b3565b366100b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100aa9061118a565b60405180910390fd5b5f5ffd5b3480156100c2575f5ffd5b506100dd60048036038101906100d89190611456565b6101bf565b005b3480156100ea575f5ffd5b5061010560048036038101906101009190611507565b6101d5565b005b348015610112575f5ffd5b5061011b61038c565b005b348015610128575f5ffd5b5061013161039f565b60405161013e9190611541565b60405180910390f35b348015610152575f5ffd5b5061016d6004803603810190610168919061155a565b6103c7565b005b34801561017a575f5ffd5b50610195600480360381019061019091906115aa565b6106da565b005b3480156101a2575f5ffd5b506101bd60048036038101906101b891906115e8565b6109cd565b005b6101c7610a51565b6101d18282610ad8565b5050565b6101dd610a51565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361024b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102429061165d565b60405180910390fd5b5f4790505f8111610291576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610288906116c5565b60405180910390fd5b5f8273ffffffffffffffffffffffffffffffffffffffff16826040516102b690611710565b5f6040518083038185875af1925050503d805f81146102f0576040519150601f19603f3d011682016040523d82523d5f602084013e6102f5565b606091505b5050905080610339576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103309061176e565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f6148672a948a12b8e0bf92a9338349b9ac890fad62a234abaf0a4da99f62cfcc8360405161037f919061179b565b60405180910390a2505050565b610394610a51565b61039d5f610d3b565b565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6103cf610a51565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361043d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610434906117fe565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036104ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104a290611866565b60405180910390fd5b5f81116104ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e4906118ce565b60405180910390fd5b5f8390505f8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161052b9190611541565b602060405180830381865afa158015610546573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061056a9190611900565b9050808311156105af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a69061199b565b60405180910390fd5b5f8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86866040518363ffffffff1660e01b81526004016105eb9291906119b9565b6020604051808303815f875af1158015610607573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061062b9190611a15565b90508061066d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066490611a8a565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f4ef96419716b45f517dc240344424ade2aa3be63eea169e6d947fdb6c2ea31ac866040516106ca919061179b565b60405180910390a3505050505050565b6106e2610dfe565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610750576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610747906117fe565b60405180910390fd5b5f8111610792576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610789906118ce565b60405180910390fd5b5f8290506107ca6107a1610e4b565b30848473ffffffffffffffffffffffffffffffffffffffff16610e52909392919063ffffffff16565b5f600280548060200260200160405190810160405280929190818152602001828054801561084a57602002820191905f5260205f20905b815f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610801575b505050505090505f600380548060200260200160405190810160405280929190818152602001828054801561089c57602002820191905f5260205f20905b815481526020019060010190808311610888575b505050505090505f5f90505b825181101561094d575f8382815181106108c5576108c4611aa8565b5b602002602001015190505f8383815181106108e3576108e2611aa8565b5b602002602001015190505f61271082896108fd9190611b02565b6109079190611b70565b90505f81111561093d5761093c83828973ffffffffffffffffffffffffffffffffffffffff16610ed49092919063ffffffff16565b5b50505080806001019150506108a8565b50610956610e4b565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f28f83976a1606de6e0641f044ae0d7b6343bc4e8f258954281c8a90f21dcb1018685856040516109b693929190611d0e565b60405180910390a35050506109c9610f53565b5050565b6109d5610a51565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610a45575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610a3c9190611541565b60405180910390fd5b610a4e81610d3b565b50565b610a59610e4b565b73ffffffffffffffffffffffffffffffffffffffff16610a7761039f565b73ffffffffffffffffffffffffffffffffffffffff1614610ad657610a9a610e4b565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610acd9190611541565b60405180910390fd5b565b8051825114610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1390611dc1565b60405180910390fd5b5f825111610b5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5690611e29565b60405180910390fd5b5f5f90505f5f90505b8351811015610c8a575f73ffffffffffffffffffffffffffffffffffffffff16848281518110610b9b57610b9a611aa8565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1603610bf9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf090611e91565b60405180910390fd5b5f838281518110610c0d57610c0c611aa8565b5b602002602001015111610c55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4c90611ef9565b60405180910390fd5b828181518110610c6857610c67611aa8565b5b602002602001015182610c7b9190611f17565b91508080600101915050610b68565b506127108114610ccf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc690611f94565b60405180910390fd5b8260029080519060200190610ce5929190610ff7565b508160039080519060200190610cfc92919061107e565b507fe513d216117f51d2e3f1d22d007ed71d23a52c0bcc410e8258732d682fe3db938383604051610d2e929190611fb2565b60405180910390a1505050565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60025f5403610e42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3990612031565b60405180910390fd5b60025f81905550565b5f33905090565b610ece848573ffffffffffffffffffffffffffffffffffffffff166323b872dd868686604051602401610e879392919061204f565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610f5c565b50505050565b610f4e838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401610f079291906119b9565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610f5c565b505050565b60015f81905550565b5f5f60205f8451602086015f885af180610f7b576040513d5f823e3d81fd5b3d92505f519150505f8214610f94576001811415610faf565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b15610ff157836040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401610fe89190611541565b60405180910390fd5b50505050565b828054828255905f5260205f2090810192821561106d579160200282015b8281111561106c578251825f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190611015565b5b50905061107a91906110c9565b5090565b828054828255905f5260205f209081019282156110b8579160200282015b828111156110b757825182559160200191906001019061109c565b5b5090506110c591906110c9565b5090565b5b808211156110e0575f815f9055506001016110ca565b5090565b5f82825260208201905092915050565b7f455448207061796d656e747320617265206e6f7420616c6c6f776564206469725f8201527f6563746c792e205573652073706c6974416e645472616e73666572546f6b656e60208201527f20666f7220746f6b656e732e0000000000000000000000000000000000000000604082015250565b5f611174604c836110e4565b915061117f826110f4565b606082019050919050565b5f6020820190508181035f8301526111a181611168565b9050919050565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b611203826111bd565b810181811067ffffffffffffffff82111715611222576112216111cd565b5b80604052505050565b5f6112346111a8565b905061124082826111fa565b919050565b5f67ffffffffffffffff82111561125f5761125e6111cd565b5b602082029050602081019050919050565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61129d82611274565b9050919050565b6112ad81611293565b81146112b7575f5ffd5b50565b5f813590506112c8816112a4565b92915050565b5f6112e06112db84611245565b61122b565b9050808382526020820190506020840283018581111561130357611302611270565b5b835b8181101561132c578061131888826112ba565b845260208401935050602081019050611305565b5050509392505050565b5f82601f83011261134a576113496111b9565b5b813561135a8482602086016112ce565b91505092915050565b5f67ffffffffffffffff82111561137d5761137c6111cd565b5b602082029050602081019050919050565b5f819050919050565b6113a08161138e565b81146113aa575f5ffd5b50565b5f813590506113bb81611397565b92915050565b5f6113d36113ce84611363565b61122b565b905080838252602082019050602084028301858111156113f6576113f5611270565b5b835b8181101561141f578061140b88826113ad565b8452602084019350506020810190506113f8565b5050509392505050565b5f82601f83011261143d5761143c6111b9565b5b813561144d8482602086016113c1565b91505092915050565b5f5f6040838503121561146c5761146b6111b1565b5b5f83013567ffffffffffffffff811115611489576114886111b5565b5b61149585828601611336565b925050602083013567ffffffffffffffff8111156114b6576114b56111b5565b5b6114c285828601611429565b9150509250929050565b5f6114d682611274565b9050919050565b6114e6816114cc565b81146114f0575f5ffd5b50565b5f81359050611501816114dd565b92915050565b5f6020828403121561151c5761151b6111b1565b5b5f611529848285016114f3565b91505092915050565b61153b81611293565b82525050565b5f6020820190506115545f830184611532565b92915050565b5f5f5f60608486031215611571576115706111b1565b5b5f61157e868287016112ba565b935050602061158f868287016112ba565b92505060406115a0868287016113ad565b9150509250925092565b5f5f604083850312156115c0576115bf6111b1565b5b5f6115cd858286016112ba565b92505060206115de858286016113ad565b9150509250929050565b5f602082840312156115fd576115fc6111b1565b5b5f61160a848285016112ba565b91505092915050565b7f496e76616c6964206164647265737300000000000000000000000000000000005f82015250565b5f611647600f836110e4565b915061165282611613565b602082019050919050565b5f6020820190508181035f8301526116748161163b565b9050919050565b7f4e6f204554482062616c616e636520746f2077697468647261770000000000005f82015250565b5f6116af601a836110e4565b91506116ba8261167b565b602082019050919050565b5f6020820190508181035f8301526116dc816116a3565b9050919050565b5f81905092915050565b50565b5f6116fb5f836116e3565b9150611706826116ed565b5f82019050919050565b5f61171a826116f0565b9150819050919050565b7f455448207472616e73666572206661696c6564000000000000000000000000005f82015250565b5f6117586013836110e4565b915061176382611724565b602082019050919050565b5f6020820190508181035f8301526117858161174c565b9050919050565b6117958161138e565b82525050565b5f6020820190506117ae5f83018461178c565b92915050565b7f546f6b656e2061646472657373206973207a65726f00000000000000000000005f82015250565b5f6117e86015836110e4565b91506117f3826117b4565b602082019050919050565b5f6020820190508181035f830152611815816117dc565b9050919050565b7f526563697069656e742061646472657373206973207a65726f000000000000005f82015250565b5f6118506019836110e4565b915061185b8261181c565b602082019050919050565b5f6020820190508181035f83015261187d81611844565b9050919050565b7f416d6f756e74206d7573742062652067726561746572207468616e207a65726f5f82015250565b5f6118b86020836110e4565b91506118c382611884565b602082019050919050565b5f6020820190508181035f8301526118e5816118ac565b9050919050565b5f815190506118fa81611397565b92915050565b5f60208284031215611915576119146111b1565b5b5f611922848285016118ec565b91505092915050565b7f496e73756666696369656e7420746f6b656e2062616c616e636520696e20636f5f8201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b5f6119856026836110e4565b91506119908261192b565b604082019050919050565b5f6020820190508181035f8301526119b281611979565b9050919050565b5f6040820190506119cc5f830185611532565b6119d9602083018461178c565b9392505050565b5f8115159050919050565b6119f4816119e0565b81146119fe575f5ffd5b50565b5f81519050611a0f816119eb565b92915050565b5f60208284031215611a2a57611a296111b1565b5b5f611a3784828501611a01565b91505092915050565b7f546f6b656e20726573637565207472616e73666572206661696c6564000000005f82015250565b5f611a74601c836110e4565b9150611a7f82611a40565b602082019050919050565b5f6020820190508181035f830152611aa181611a68565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611b0c8261138e565b9150611b178361138e565b9250828202611b258161138e565b91508282048414831517611b3c57611b3b611ad5565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f611b7a8261138e565b9150611b858361138e565b925082611b9557611b94611b43565b5b828204905092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b611bd281611293565b82525050565b5f611be38383611bc9565b60208301905092915050565b5f602082019050919050565b5f611c0582611ba0565b611c0f8185611baa565b9350611c1a83611bba565b805f5b83811015611c4a578151611c318882611bd8565b9750611c3c83611bef565b925050600181019050611c1d565b5085935050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b611c898161138e565b82525050565b5f611c9a8383611c80565b60208301905092915050565b5f602082019050919050565b5f611cbc82611c57565b611cc68185611c61565b9350611cd183611c71565b805f5b83811015611d01578151611ce88882611c8f565b9750611cf383611ca6565b925050600181019050611cd4565b5085935050505092915050565b5f606082019050611d215f83018661178c565b8181036020830152611d338185611bfb565b90508181036040830152611d478184611cb2565b9050949350505050565b7f50617965657320616e6420736861726573206c656e677468206d69736d6174635f8201527f6800000000000000000000000000000000000000000000000000000000000000602082015250565b5f611dab6021836110e4565b9150611db682611d51565b604082019050919050565b5f6020820190508181035f830152611dd881611d9f565b9050919050565b7f4e6f207061796565732070726f766964656400000000000000000000000000005f82015250565b5f611e136012836110e4565b9150611e1e82611ddf565b602082019050919050565b5f6020820190508181035f830152611e4081611e07565b9050919050565b7f50617965652061646472657373206973207a65726f00000000000000000000005f82015250565b5f611e7b6015836110e4565b9150611e8682611e47565b602082019050919050565b5f6020820190508181035f830152611ea881611e6f565b9050919050565b7f5368617265206d7573742062652067726561746572207468616e207a65726f005f82015250565b5f611ee3601f836110e4565b9150611eee82611eaf565b602082019050919050565b5f6020820190508181035f830152611f1081611ed7565b9050919050565b5f611f218261138e565b9150611f2c8361138e565b9250828201905080821115611f4457611f43611ad5565b5b92915050565b7f536861726573206d7573742073756d20746f20313030303020283130302529005f82015250565b5f611f7e601f836110e4565b9150611f8982611f4a565b602082019050919050565b5f6020820190508181035f830152611fab81611f72565b9050919050565b5f6040820190508181035f830152611fca8185611bfb565b90508181036020830152611fde8184611cb2565b90509392505050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c005f82015250565b5f61201b601f836110e4565b915061202682611fe7565b602082019050919050565b5f6020820190508181035f8301526120488161200f565b9050919050565b5f6060820190506120625f830186611532565b61206f6020830185611532565b61207c604083018461178c565b94935050505056fea2646970667358221220ac44c91a3831bff03a0b26e4125cb8fc6d782cb8939d255b0d62cd6e37152a1664736f6c634300081e0033
Verified Source Code Full Match
Compiler: v0.8.30+commit.73712a01
EVM: prague
Optimization: No
ERC20Splitter.sol 160 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
// ⬇️⬇️ 1. إضافة جديدة ومهمة ⬇️⬇️
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title ERC20Splitter
* @notice عقد لسحب أي توكن ERC-20 من المُرسل وتوزيعه على عدة مستفيدين بنسب ثابتة.
* @dev [تعديل 5]: يستخدم SafeERC20 لدعم العملات مثل USDT.
*/
contract ERC20Splitter is Context, ReentrancyGuard, Ownable {
// ⬇️⬇️ 2. إضافة جديدة ⬇️⬇️
using SafeERC20 for IERC20;
// --- المتغيرات الأساسية ---
address[] private _payees;
uint256[] private _shares;
uint256 private constant TOTAL_SHARES = 10000; // المجموع = 100%
// --- الأحداث (Events) ---
event FundsSplit(
address indexed tokenAddress,
address indexed sender,
uint256 totalAmount,
address[] payees,
uint256[] shares
);
event ETHWithdrawn(uint256 amount, address indexed to);
event ERC20Rescued(address indexed token, uint256 amount, address indexed to);
event PayeesUpdated(address[] newPayees, uint256[] newShares);
/**
* @notice دالة الإنشاء (Constructor)
*/
constructor(
address[] memory payees,
uint256[] memory shares
) payable Ownable(_msgSender()) {
_updatePayeesInternal(payees, shares);
}
/**
* @notice الوظيفة الرئيسية: لسحب أي توكن ERC-20 من المُرسل وتوزيعه فورياً.
*/
function splitAndTransferToken(
address tokenAddress,
uint256 amountToSplit
) public nonReentrant {
require(tokenAddress != address(0), "Token address is zero");
require(amountToSplit > 0, "Amount must be greater than zero");
IERC20 token = IERC20(tokenAddress);
// ⬇️⬇️ 3. التعديل الأهم: استخدام safeTransferFrom ⬇️⬇️
// تم حذف السطرين:
// bool success = token.transferFrom(_msgSender(), address(this), amountToSplit);
// require(success, "Token pull failed - Check Approve allowance");
// واستبدالهم بـ:
token.safeTransferFrom(_msgSender(), address(this), amountToSplit);
// ⬆️⬆️ نهاية التعديل ⬆️⬆️
// 3. التوزيع على المستفيدين
address[] memory currentPayees = _payees;
uint256[] memory currentShares = _shares;
for (uint i = 0; i < currentPayees.length; i++) {
address payee = currentPayees[i];
uint256 share = currentShares[i];
uint256 amount = (amountToSplit * share) / TOTAL_SHARES;
if (amount > 0) {
// ⬇️⬇️ 4. التعديل الثاني: استخدام safeTransfer ⬇️⬇️
// تم حذف السطرين:
// bool transferSuccess = token.transfer(payee, amount);
// require(transferSuccess, "Token transfer to payee failed");
// واستبدالهم بـ:
token.safeTransfer(payee, amount);
// ⬆️⬆️ نهاية التعديل ⬆️⬆️
}
}
emit FundsSplit(
tokenAddress,
_msgSender(),
amountToSplit,
currentPayees,
currentShares
);
}
// --- بقية الدوال كما هي (لا تحتاج تعديل) ---
function withdrawETH(address payable to) public onlyOwner {
require(to != address(0), "Invalid address");
uint256 balance = address(this).balance;
require(balance > 0, "No ETH balance to withdraw");
(bool success, ) = to.call{value: balance}("");
require(success, "ETH transfer failed");
emit ETHWithdrawn(balance, to);
}
function rescueERC20(address tokenAddress, address to, uint256 amount) public onlyOwner {
require(tokenAddress != address(0), "Token address is zero");
require(to != address(0), "Recipient address is zero");
require(amount > 0, "Amount must be greater than zero");
IERC20 token = IERC20(tokenAddress);
uint256 contractBalance = token.balanceOf(address(this));
require(amount <= contractBalance, "Insufficient token balance in contract");
// (ملاحظة: دالة الإنقاذ تستخدم .transfer العادية، وهذا مقبول)
bool success = token.transfer(to, amount);
require(success, "Token rescue transfer failed");
emit ERC20Rescued(tokenAddress, amount, to);
}
function updatePayeesAndShares(
address[] memory newPayees,
uint256[] memory newShares
) public onlyOwner {
_updatePayeesInternal(newPayees, newShares);
}
function _updatePayeesInternal(
address[] memory newPayees,
uint256[] memory newShares
) private {
require(newPayees.length == newShares.length, "Payees and shares length mismatch");
require(newPayees.length > 0, "No payees provided");
uint256 totalShares_ = 0;
for (uint256 i = 0; i < newPayees.length; i++) {
require(newPayees[i] != address(0), "Payee address is zero");
require(newShares[i] > 0, "Share must be greater than zero");
totalShares_ += newShares[i];
}
require(totalShares_ == TOTAL_SHARES, "Shares must sum to 10000 (100%)");
_payees = newPayees;
_shares = newShares;
emit PayeesUpdated(newPayees, newShares);
}
receive() external payable {
revert("ETH payments are not allowed directly. Use splitAndTransferToken for tokens.");
}
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Read Contract
owner 0x8da5cb5b → address
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
renounceOwnership 0x715018a6
No parameters
rescueERC20 0xb2118a8d
address tokenAddress
address to
uint256 amount
splitAndTransferToken 0xd0de1ddc
address tokenAddress
uint256 amountToSplit
transferOwnership 0xf2fde38b
address newOwner
updatePayeesAndShares 0x469f0ab5
address[] newPayees
uint256[] newShares
withdrawETH 0x690d8320
address to
Token Balances (2)
View Transfers →Recent Transactions
No transactions found for this address