Contract Address Details

0x5922F957C2DF08FE3dD5f6Dd8f2f7FE14fF9c43f

Contract Name
Treasury
Creator
0x598ca9–731e18 at 0xb92bd0–4581ad
Balance
0 TT ( )
Tokens
Fetching tokens...
Transactions
Transfers
Gas Used
Last Balance Update
3353436
Contract name:
Treasury




Optimization enabled
true
Compiler version
v0.8.19+commit.7dd6d404




Optimization runs
200
Verified at
2024-03-24 03:26:57.053315Z

src/Treasury.sol

//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
//========================================================================
//IMPORTS
//========================================================================
import "@openzeppelin/contracts/access/Ownable.sol";
/**
@title Treasury
@notice This contract is used to store the funds of the protocol
*/
contract Treasury is Ownable {
//========================================================================
//ERRORS
//========================================================================
error InsufficientBalance(uint requested, uint available);
error InvalidAddress();
error TransferFailed();
//========================================================================
//EVENTS
//========================================================================
/// @dev Event for Ethers received.
event Received(address indexed sender, uint amount);
/// @dev Event for Ethers withdrawn.
event Withdrawn(address indexed beneficiary, uint amount);
//========================================================================
//CONSTRUCTOR
//========================================================================
/// @notice Constructor to set the initial owner and optionally receive Ether.
constructor() payable Ownable(msg.sender) {}
//========================================================================
//RECEIVE ETHER
//========================================================================
/// @notice Receive Ether.
receive() external payable {
emit Received(msg.sender, msg.value);
}
//========================================================================
//EXTERNAL FUNCTIONS
//========================================================================
/// @notice Withdraw Ether from the contract.
/// @param _beneficiary The address to receive the Ether.
/// @param _amount The amount of Ether to withdraw.
function withdraw(
address payable _beneficiary,
uint _amount
) external onlyOwner {
if (address(this).balance < _amount) {
revert InsufficientBalance(_amount, address(this).balance);
}
if (_beneficiary == address(0)) {
revert InvalidAddress();
}
(bool success, ) = _beneficiary.call{value: _amount}("");
if (!success) {
revert TransferFailed();
}
emit Withdrawn(_beneficiary, _amount);
}
//========================================================================
//VIEW FUNCTIONS
//========================================================================
/// @notice Get the balance of the contract.
/// @return The balance of the contract.
function getBalance() external view returns (uint) {
return address(this).balance;
}
}

lib/OpenZeppelin-contracts/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity 0.8.19;
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);
}
}

lib/OpenZeppelin-contracts/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity 0.8.19;
/**
* @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;
}
}

Contract ABI

[{"type":"constructor","stateMutability":"payable","inputs":[]},{"type":"error","name":"InsufficientBalance","inputs":[{"type":"uint256","name":"requested","internalType":"uint256"},{"type":"uint256","name":"available","internalType":"uint256"}]},{"type":"error","name":"InvalidAddress","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"TransferFailed","inputs":[]},{"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":"Received","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Withdrawn","inputs":[{"type":"address","name":"beneficiary","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBalance","inputs":[]},{"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"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"address","name":"_beneficiary","internalType":"address payable"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
            

Deployed ByteCode

0x6080604081815260048036101561004b575b509050361561001f57600080fd5b513481527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587460203392a2005b600092833560e01c90816312065fe0146102c757508063715018a61461026a5780638da5cb5b1461023e578063f2fde38b146101b05763f3fef3a30361001157346101ac57816003193601126101ac5780356001600160a01b03811692908390036101a857602435916100bc6102e1565b82471061018c57831561017e578480808086885af13d156101795767ffffffffffffffff3d81811161016657845191601f8201601f19908116603f011683019081118382101761015357855281528660203d92013e5b1561014557507f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d59160209151908152a280f35b90516312171d8360e31b8152fd5b634e487b7160e01b895260418552602489fd5b634e487b7160e01b885260418452602488fd5b610112565b905163e6c4247b60e01b8152fd5b906044924791519263cf47918160e01b84528301526024820152fd5b8380fd5b8280fd5b5090346101ac5760203660031901126101ac576001600160a01b0382358181169391929084900361023a576101e36102e1565b831561022457505082546001600160a01b0319811683178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b51631e4fbdf760e01b8152908101849052602490fd5b8480fd5b505034610266578160031936011261026657905490516001600160a01b039091168152602090f35b5080fd5b83346102c457806003193601126102c4576102836102e1565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b849034610266578160031936011261026657602090478152f35b6000546001600160a01b031633036102f557565b60405163118cdaa760e01b8152336004820152602490fdfea2646970667358221220179181cd71edac4007d44c19a5071637ca6e77ee0aa2996db2d25fd0958b998964736f6c63430008130033