Address Details
contract
0xa9ECF002DF9Fb467498E1b4aff8bB53daa67E921
- Contract Name
- TestAdmin
- Creator
- 0xa20c11–f1ddd5 at 0x38fea7–ba2286
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 0 Transactions
- Transfers
- 0 Transfers
- Gas Used
- Fetching gas used...
- Last Balance Update
- 17883664
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- TestAdmin
- Optimization enabled
- true
- Compiler version
- v0.8.1+commit.df193b15
- Optimization runs
- 200
- EVM Version
- istanbul
- Verified at
- 2023-05-22T21:17:40.313133Z
contracts/TestAdmin.sol
// contracts/ARISwapToken.sol // SPDX-License-Identifier: MIT Licensed pragma solidity 0.8.1; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract TestAdmin is Ownable, ReentrancyGuard { using Counters for Counters.Counter; struct Commit { address payable owner; uint256 numberOfTrees; uint256 budget; uint256 balance; uint256 spent; } event CommitCreated( address indexed owner, uint256 indexed timestamp, uint256 commitId, uint256 numberOfTrees ); event PayoutSent( address indexed owner, uint256 indexed timestamp, bool isFronted, uint256 balance, string payoutMetadata ); IERC20 private immutable _stableToken; uint256 private constant MAX_PERCENTAGE = 10000; Counters.Counter private _commitIdTracker; mapping(uint256 => Commit) private _commits; constructor(address stableTokenAddress) { require( stableTokenAddress != address(0), "Zero address for stabletoken" ); _stableToken = IERC20(stableTokenAddress); } function commitTree( address owner, uint256 budget, uint256 numberOfTrees, uint256 timestamp ) external nonReentrant { require(owner != address(0), "Zero address for owner"); require(budget > 0, "Budget must be greater than 0"); require(numberOfTrees > 0, "Number of trees must be greater than 0"); uint256 commitId = _commitIdTracker.current(); _commits[commitId] = Commit({ owner: payable(owner), numberOfTrees: numberOfTrees, budget: budget, balance: 0, spent: 0 }); _commitIdTracker.increment(); emit CommitCreated(owner, timestamp, commitId, numberOfTrees); } function frontPayout( uint256 commitId, uint256 payoutAmount, uint256 timestamp ) external nonReentrant { require( _commits[commitId].owner != address(0), "No commits exist for that id" ); Commit storage commit = _commits[commitId]; require(commit.spent <= commit.budget, "Budget has been fully spent"); commit.spent += payoutAmount; require(commit.spent <= commit.budget, "Payout will exceed the budget"); commit.balance += payoutAmount; require( _stableToken.transferFrom(msg.sender, commit.owner, payoutAmount), "Transfer failed" ); emit PayoutSent(commit.owner, timestamp, true, commit.balance, ""); } }
/_openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../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. * * By default, the owner account will be the one that deploys the contract. 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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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); } }
/_openzeppelin/contracts/security/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
/_openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount ) external returns (bool); /** * @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); }
/_openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
/_openzeppelin/contracts/utils/Counters.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"stableTokenAddress","internalType":"address"}]},{"type":"event","name":"CommitCreated","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":true},{"type":"uint256","name":"commitId","internalType":"uint256","indexed":false},{"type":"uint256","name":"numberOfTrees","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PayoutSent","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":true},{"type":"bool","name":"isFronted","internalType":"bool","indexed":false},{"type":"uint256","name":"balance","internalType":"uint256","indexed":false},{"type":"string","name":"payoutMetadata","internalType":"string","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"commitTree","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"budget","internalType":"uint256"},{"type":"uint256","name":"numberOfTrees","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"frontPayout","inputs":[{"type":"uint256","name":"commitId","internalType":"uint256"},{"type":"uint256","name":"payoutAmount","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x60a060405234801561001057600080fd5b50604051610a6a380380610a6a83398101604081905261002f916100db565b61003f61003a610087565b61008b565b600180556001600160a01b0381166100725760405162461bcd60e51b815260040161006990610109565b60405180910390fd5b60601b6001600160601b031916608052610140565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100ec578081fd5b81516001600160a01b0381168114610102578182fd5b9392505050565b6020808252601c908201527f5a65726f206164647265737320666f7220737461626c65746f6b656e00000000604082015260600190565b60805160601c61090c61015e6000396000610391015261090c6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630db8ff741461005c578063715018a6146100715780638da5cb5b14610079578063d5907ad014610097578063f2fde38b146100aa575b600080fd5b61006f61006a36600461059d565b6100bd565b005b61006f610232565b61008161027d565b60405161008e9190610620565b60405180910390f35b61006f6100a53660046105f5565b61028c565b61006f6100b836600461057c565b61048f565b600260015414156100e95760405162461bcd60e51b81526004016100e09061086d565b60405180910390fd5b60026001556001600160a01b0384166101145760405162461bcd60e51b81526004016100e09061083d565b600083116101345760405162461bcd60e51b81526004016100e09061079a565b600082116101545760405162461bcd60e51b81526004016100e09061071d565b60006101606002610500565b6040805160a0810182526001600160a01b03888116825260208083018881528385018a81526000606086018181526080870182815289835260039586905297909120955186546001600160a01b0319169516949094178555905160018501555160028085019190915591519083015591516004909101559091506101e390610508565b81856001600160a01b03167ff2772ff8b8fc97f4bf762c07da5874e6a443b3a3c7dcad87f5cf2fcbf67a890e838660405161021f9291906108a4565b60405180910390a3505060018055505050565b61023a610511565b6001600160a01b031661024b61027d565b6001600160a01b0316146102715760405162461bcd60e51b81526004016100e0906107d1565b61027b6000610515565b565b6000546001600160a01b031690565b600260015414156102af5760405162461bcd60e51b81526004016100e09061086d565b60026001556000838152600360205260409020546001600160a01b03166102e85760405162461bcd60e51b81526004016100e090610763565b600083815260036020526040902060028101546004820154111561031e5760405162461bcd60e51b81526004016100e090610806565b8281600401600082825461033291906108b2565b909155505060028101546004820154111561035f5760405162461bcd60e51b81526004016100e090610677565b8281600301600082825461037391906108b2565b909155505080546040516323b872dd60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116926323b872dd926103cb92339216908890600401610634565b602060405180830381600087803b1580156103e557600080fd5b505af11580156103f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041d91906105d5565b6104395760405162461bcd60e51b81526004016100e0906106f4565b8054600382015460405184926001600160a01b0316917f8c4881ce8ab56167a18486f854f4685c00a1b282685d51d5c1fd692cec45bab89161047d91600191610658565b60405180910390a35050600180555050565b610497610511565b6001600160a01b03166104a861027d565b6001600160a01b0316146104ce5760405162461bcd60e51b81526004016100e0906107d1565b6001600160a01b0381166104f45760405162461bcd60e51b81526004016100e0906106ae565b6104fd81610515565b50565b80545b919050565b80546001019055565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461050357600080fd5b60006020828403121561058d578081fd5b61059682610565565b9392505050565b600080600080608085870312156105b2578283fd5b6105bb85610565565b966020860135965060408601359560600135945092505050565b6000602082840312156105e6578081fd5b81518015158114610596578182fd5b600080600060608486031215610609578283fd5b505081359360208301359350604090920135919050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b9115158252602082015260606040820181905260009082015260800190565b6020808252601d908201527f5061796f75742077696c6c206578636565642074686520627564676574000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b60208082526026908201527f4e756d626572206f66207472656573206d75737420626520677265617465722060408201526507468616e20360d41b606082015260800190565b6020808252601c908201527f4e6f20636f6d6d69747320657869737420666f72207468617420696400000000604082015260600190565b6020808252601d908201527f427564676574206d7573742062652067726561746572207468616e2030000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601b908201527f42756467657420686173206265656e2066756c6c79207370656e740000000000604082015260600190565b6020808252601690820152752d32b9379030b2323932b9b9903337b91037bbb732b960511b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b918252602082015260400190565b600082198211156108d157634e487b7160e01b81526011600452602481fd5b50019056fea2646970667358221220beb3c552c0b2cf8884c30297a3ea8cc45e84f731c269759ff7156129bbc4351664736f6c63430008010033000000000000000000000000874069fa1eb16d44d622f2e0ca25eea172369bc1
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100575760003560e01c80630db8ff741461005c578063715018a6146100715780638da5cb5b14610079578063d5907ad014610097578063f2fde38b146100aa575b600080fd5b61006f61006a36600461059d565b6100bd565b005b61006f610232565b61008161027d565b60405161008e9190610620565b60405180910390f35b61006f6100a53660046105f5565b61028c565b61006f6100b836600461057c565b61048f565b600260015414156100e95760405162461bcd60e51b81526004016100e09061086d565b60405180910390fd5b60026001556001600160a01b0384166101145760405162461bcd60e51b81526004016100e09061083d565b600083116101345760405162461bcd60e51b81526004016100e09061079a565b600082116101545760405162461bcd60e51b81526004016100e09061071d565b60006101606002610500565b6040805160a0810182526001600160a01b03888116825260208083018881528385018a81526000606086018181526080870182815289835260039586905297909120955186546001600160a01b0319169516949094178555905160018501555160028085019190915591519083015591516004909101559091506101e390610508565b81856001600160a01b03167ff2772ff8b8fc97f4bf762c07da5874e6a443b3a3c7dcad87f5cf2fcbf67a890e838660405161021f9291906108a4565b60405180910390a3505060018055505050565b61023a610511565b6001600160a01b031661024b61027d565b6001600160a01b0316146102715760405162461bcd60e51b81526004016100e0906107d1565b61027b6000610515565b565b6000546001600160a01b031690565b600260015414156102af5760405162461bcd60e51b81526004016100e09061086d565b60026001556000838152600360205260409020546001600160a01b03166102e85760405162461bcd60e51b81526004016100e090610763565b600083815260036020526040902060028101546004820154111561031e5760405162461bcd60e51b81526004016100e090610806565b8281600401600082825461033291906108b2565b909155505060028101546004820154111561035f5760405162461bcd60e51b81526004016100e090610677565b8281600301600082825461037391906108b2565b909155505080546040516323b872dd60e01b81526001600160a01b037f000000000000000000000000874069fa1eb16d44d622f2e0ca25eea172369bc18116926323b872dd926103cb92339216908890600401610634565b602060405180830381600087803b1580156103e557600080fd5b505af11580156103f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041d91906105d5565b6104395760405162461bcd60e51b81526004016100e0906106f4565b8054600382015460405184926001600160a01b0316917f8c4881ce8ab56167a18486f854f4685c00a1b282685d51d5c1fd692cec45bab89161047d91600191610658565b60405180910390a35050600180555050565b610497610511565b6001600160a01b03166104a861027d565b6001600160a01b0316146104ce5760405162461bcd60e51b81526004016100e0906107d1565b6001600160a01b0381166104f45760405162461bcd60e51b81526004016100e0906106ae565b6104fd81610515565b50565b80545b919050565b80546001019055565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461050357600080fd5b60006020828403121561058d578081fd5b61059682610565565b9392505050565b600080600080608085870312156105b2578283fd5b6105bb85610565565b966020860135965060408601359560600135945092505050565b6000602082840312156105e6578081fd5b81518015158114610596578182fd5b600080600060608486031215610609578283fd5b505081359360208301359350604090920135919050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b9115158252602082015260606040820181905260009082015260800190565b6020808252601d908201527f5061796f75742077696c6c206578636565642074686520627564676574000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b60208082526026908201527f4e756d626572206f66207472656573206d75737420626520677265617465722060408201526507468616e20360d41b606082015260800190565b6020808252601c908201527f4e6f20636f6d6d69747320657869737420666f72207468617420696400000000604082015260600190565b6020808252601d908201527f427564676574206d7573742062652067726561746572207468616e2030000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601b908201527f42756467657420686173206265656e2066756c6c79207370656e740000000000604082015260600190565b6020808252601690820152752d32b9379030b2323932b9b9903337b91037bbb732b960511b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b918252602082015260400190565b600082198211156108d157634e487b7160e01b81526011600452602481fd5b50019056fea2646970667358221220beb3c552c0b2cf8884c30297a3ea8cc45e84f731c269759ff7156129bbc4351664736f6c63430008010033