Address Contract Partially Verified
Address
0x7f7D6c12b45C430f6e2B0Edb5D1aA34aa2d7B6B2
Balance
0 ETH
Nonce
1
Code Size
8114 bytes
Creator
0x961B513d...47BD at tx 0x0d168b9d...0b361c
Indexed Transactions
0
Contract Bytecode
8114 bytes
0x6080604052600436106100c65760003560e01c80638da5cb5b1161007f578063cc0a852011610059578063cc0a852014610287578063f0b2cb16146102b0578063f2fde38b146102d9578063fec4d537146103025761011b565b80638da5cb5b1461020857806395ccea6714610233578063b328cc501461025c5761011b565b80631547915d14610120578063319f0cb2146101495780633ad5c594146101745780634c3462231461019d5780636b7d2811146101c8578063715018a6146101f15761011b565b3661011b573373ffffffffffffffffffffffffffffffffffffffff167fced5d8bf10823804603bba066e4f53aa6e8f6f4be68bf0114cf7a0e52183e4e9346040516101119190611b1d565b60405180910390a2005b600080fd5b34801561012c57600080fd5b50610147600480360381019061014291906114f2565b61032b565b005b34801561015557600080fd5b5061015e6103eb565b60405161016b919061191c565b60405180910390f35b34801561018057600080fd5b5061019b6004803603810190610196919061155f565b610411565b005b3480156101a957600080fd5b506101b2610665565b6040516101bf91906119c0565b60405180910390f35b3480156101d457600080fd5b506101ef60048036038101906101ea91906114f2565b61068b565b005b3480156101fd57600080fd5b5061020661074b565b005b34801561021457600080fd5b5061021d6107d3565b60405161022a919061191c565b60405180910390f35b34801561023f57600080fd5b5061025a6004803603810190610255919061151f565b6107fc565b005b34801561026857600080fd5b5061027161097d565b60405161027e919061191c565b60405180910390f35b34801561029357600080fd5b506102ae60048036038101906102a991906116bb565b6109a3565b005b3480156102bc57600080fd5b506102d760048036038101906102d291906114f2565b610ae6565b005b3480156102e557600080fd5b5061030060048036038101906102fb91906114f2565b610ba6565b005b34801561030e57600080fd5b50610329600480360381019061032491906115e0565b610c9e565b005b610333610e6a565b73ffffffffffffffffffffffffffffffffffffffff166103516107d3565b73ffffffffffffffffffffffffffffffffffffffff16146103a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039e90611a7d565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026001541415610457576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044e90611add565b60405180910390fd5b60026001819055503373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e690611a5d565b60405180910390fd5b818190508484905014610537576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052e90611a3d565b60405180910390fd5b60005b8484905081101561065757600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e17376b586868481811061059657610595611cbe565b5b90506020020160208101906105ab91906114f2565b8585858181106105be576105bd611cbe565b5b90506020020160208101906105d3919061168e565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518463ffffffff1660e01b815260040161061493929190611989565b600060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b505050508061065090611c46565b905061053a565b506001808190555050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610693610e6a565b73ffffffffffffffffffffffffffffffffffffffff166106b16107d3565b73ffffffffffffffffffffffffffffffffffffffff1614610707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106fe90611a7d565b60405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610753610e6a565b73ffffffffffffffffffffffffffffffffffffffff166107716107d3565b73ffffffffffffffffffffffffffffffffffffffff16146107c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107be90611a7d565b60405180910390fd5b6107d16000610e72565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610804610e6a565b73ffffffffffffffffffffffffffffffffffffffff166108226107d3565b73ffffffffffffffffffffffffffffffffffffffff1614610878576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086f90611a7d565b60405180910390fd5b600260015414156108be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b590611add565b60405180910390fd5b6002600181905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461092a5761092533828473ffffffffffffffffffffffffffffffffffffffff16610f369092919063ffffffff16565b610972565b3373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610970573d6000803e3d6000fd5b505b600180819055505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2a90611a5d565b60405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632d2da80682600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610ab1919061191c565b6000604051808303818588803b158015610aca57600080fd5b505af1158015610ade573d6000803e3d6000fd5b505050505050565b610aee610e6a565b73ffffffffffffffffffffffffffffffffffffffff16610b0c6107d3565b73ffffffffffffffffffffffffffffffffffffffff1614610b62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5990611a7d565b60405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610bae610e6a565b73ffffffffffffffffffffffffffffffffffffffff16610bcc6107d3565b73ffffffffffffffffffffffffffffffffffffffff1614610c22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1990611a7d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c89906119fd565b60405180910390fd5b610c9b81610e72565b50565b60026001541415610ce4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cdb90611add565b60405180910390fd5b6002600181905550610cf4610e6a565b73ffffffffffffffffffffffffffffffffffffffff16610d126107d3565b73ffffffffffffffffffffffffffffffffffffffff1614610d68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5f90611a7d565b60405180910390fd5b818190508484905014610db0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da790611a3d565b60405180910390fd5b60005b84849050811015610e5c57610e4b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16848484818110610df757610df6611cbe565b5b90506020020135878785818110610e1157610e10611cbe565b5b9050602002016020810190610e2691906114f2565b73ffffffffffffffffffffffffffffffffffffffff16610fbc9092919063ffffffff16565b80610e5590611c46565b9050610db3565b506001808190555050505050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b610fb78363a9059cbb60e01b8484604051602401610f55929190611960565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061111a565b505050565b6000811480611055575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401611003929190611937565b60206040518083038186803b15801561101b57600080fd5b505afa15801561102f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105391906116e8565b145b611094576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108b90611afd565b60405180910390fd5b6111158363095ea7b360e01b84846040516024016110b3929190611960565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061111a565b505050565b600061117c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166111e19092919063ffffffff16565b90506000815111156111dc578080602001905181019061119c9190611661565b6111db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111d290611abd565b60405180910390fd5b5b505050565b60606111f084846000856111f9565b90509392505050565b60608247101561123e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123590611a1d565b60405180910390fd5b6112478561130d565b611286576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127d90611a9d565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516112af9190611905565b60006040518083038185875af1925050503d80600081146112ec576040519150601f19603f3d011682016040523d82523d6000602084013e6112f1565b606091505b5091509150611301828286611320565b92505050949350505050565b600080823b905060008111915050919050565b6060831561133057829050611380565b6000835111156113435782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137791906119db565b60405180910390fd5b9392505050565b60008135905061139681611f20565b92915050565b60008083601f8401126113b2576113b1611cf2565b5b8235905067ffffffffffffffff8111156113cf576113ce611ced565b5b6020830191508360208202830111156113eb576113ea611cf7565b5b9250929050565b60008083601f84011261140857611407611cf2565b5b8235905067ffffffffffffffff81111561142557611424611ced565b5b60208301915083602082028301111561144157611440611cf7565b5b9250929050565b60008083601f84011261145e5761145d611cf2565b5b8235905067ffffffffffffffff81111561147b5761147a611ced565b5b60208301915083602082028301111561149757611496611cf7565b5b9250929050565b6000815190506114ad81611f37565b92915050565b6000813590506114c281611f4e565b92915050565b6000813590506114d781611f65565b92915050565b6000815190506114ec81611f65565b92915050565b60006020828403121561150857611507611d01565b5b600061151684828501611387565b91505092915050565b6000806040838503121561153657611535611d01565b5b600061154485828601611387565b9250506020611555858286016114c8565b9150509250929050565b6000806000806040858703121561157957611578611d01565b5b600085013567ffffffffffffffff81111561159757611596611cfc565b5b6115a38782880161139c565b9450945050602085013567ffffffffffffffff8111156115c6576115c5611cfc565b5b6115d2878288016113f2565b925092505092959194509250565b600080600080604085870312156115fa576115f9611d01565b5b600085013567ffffffffffffffff81111561161857611617611cfc565b5b6116248782880161139c565b9450945050602085013567ffffffffffffffff81111561164757611646611cfc565b5b61165387828801611448565b925092505092959194509250565b60006020828403121561167757611676611d01565b5b60006116858482850161149e565b91505092915050565b6000602082840312156116a4576116a3611d01565b5b60006116b2848285016114b3565b91505092915050565b6000602082840312156116d1576116d0611d01565b5b60006116df848285016114c8565b91505092915050565b6000602082840312156116fe576116fd611d01565b5b600061170c848285016114dd565b91505092915050565b61171e81611b6a565b82525050565b600061172f82611b38565b6117398185611b4e565b9350611749818560208601611c13565b80840191505092915050565b61175e81611bcb565b82525050565b61176d81611bdd565b82525050565b600061177e82611b43565b6117888185611b59565b9350611798818560208601611c13565b6117a181611d06565b840191505092915050565b60006117b9602683611b59565b91506117c482611d17565b604082019050919050565b60006117dc602683611b59565b91506117e782611d66565b604082019050919050565b60006117ff601083611b59565b915061180a82611db5565b602082019050919050565b6000611822601283611b59565b915061182d82611dde565b602082019050919050565b6000611845602083611b59565b915061185082611e07565b602082019050919050565b6000611868601d83611b59565b915061187382611e30565b602082019050919050565b600061188b602a83611b59565b915061189682611e59565b604082019050919050565b60006118ae601f83611b59565b91506118b982611ea8565b602082019050919050565b60006118d1603683611b59565b91506118dc82611ed1565b604082019050919050565b6118f081611b88565b82525050565b6118ff81611bc1565b82525050565b60006119118284611724565b915081905092915050565b60006020820190506119316000830184611715565b92915050565b600060408201905061194c6000830185611715565b6119596020830184611715565b9392505050565b60006040820190506119756000830185611715565b61198260208301846118f6565b9392505050565b600060608201905061199e6000830186611755565b6119ab60208301856118e7565b6119b86040830184611715565b949350505050565b60006020820190506119d56000830184611764565b92915050565b600060208201905081810360008301526119f58184611773565b905092915050565b60006020820190508181036000830152611a16816117ac565b9050919050565b60006020820190508181036000830152611a36816117cf565b9050919050565b60006020820190508181036000830152611a56816117f2565b9050919050565b60006020820190508181036000830152611a7681611815565b9050919050565b60006020820190508181036000830152611a9681611838565b9050919050565b60006020820190508181036000830152611ab68161185b565b9050919050565b60006020820190508181036000830152611ad68161187e565b9050919050565b60006020820190508181036000830152611af6816118a1565b9050919050565b60006020820190508181036000830152611b16816118c4565b9050919050565b6000602082019050611b3260008301846118f6565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000611b7582611ba1565b9050919050565b60008115159050919050565b60006cffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000611bd682611bef565b9050919050565b6000611be882611bef565b9050919050565b6000611bfa82611c01565b9050919050565b6000611c0c82611ba1565b9050919050565b60005b83811015611c31578082015181840152602081019050611c16565b83811115611c40576000848401525b50505050565b6000611c5182611bc1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611c8457611c83611c8f565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f756e6d617463686564206c656e67746800000000000000000000000000000000600082015250565b7f6e6f74206465706f73697420776f726b65720000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b611f2981611b6a565b8114611f3457600080fd5b50565b611f4081611b7c565b8114611f4b57600080fd5b50565b611f5781611b88565b8114611f6257600080fd5b50565b611f6e81611bc1565b8114611f7957600080fd5b5056fea26469706673582212203e52a57cd5ae56e48867a55ba980a71880fcd7f92f5f5da69d4eba75da714cec64736f6c63430008070033
Verified Source Code Partial Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: No
ZksTreasury.sol 684 lines
// File: @openzeppelin/contracts/utils/Address.sol
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts v4.4.1 (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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
address recipient,
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);
}
// File: github/RevelationOfTuring/zks_treasury/contracts/interface/ZksCore.sol
pragma solidity 0.8.7;
interface ZksCore {
function depositERC20(IERC20 _token, uint104 _amount, address _franklinAddr) external;
function depositETH(address _franklinAddr) external payable;
}
// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
/**
* @title SafeERC20
* @dev Wrappers around ERC20 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 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @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).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// 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;
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
}
// File: github/RevelationOfTuring/zks_treasury/contracts/ZksTreasury.sol
pragma solidity 0.8.7;
contract ZksTreasury is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
event DepositETH(address indexed depositer, uint amount);
ZksCore public zksCoreAddress;
address public receiverLayer2;
address public depositWorker;
modifier onlyDepositWorker() {
require(depositWorker == msg.sender, "not deposit worker");
_;
}
constructor(address receiverL2, address depositWorkerAddr, address zksCoreAddr){
receiverLayer2 = receiverL2;
depositWorker = depositWorkerAddr;
zksCoreAddress = ZksCore(zksCoreAddr);
}
receive() external payable {
emit DepositETH(msg.sender, msg.value);
}
// deposit eth locked in this contract to layer2
function depositEthToZksCore(uint amount) external onlyDepositWorker {
zksCoreAddress.depositETH{value : amount}(receiverLayer2);
}
// deposit erc20 locked in this contract to layer2
function depositErc20ToZksCore(
address[] calldata tokenAddresses,
uint104[] calldata amounts
)
external
nonReentrant
onlyDepositWorker
{
require(tokenAddresses.length == amounts.length, "unmatched length");
for (uint i = 0; i < tokenAddresses.length; ++i) {
zksCoreAddress.depositERC20(IERC20(tokenAddresses[i]), amounts[i], receiverLayer2);
}
}
// receiverLayer2 setter
function setReceiverLayer2(address newReceiverLayer2) external onlyOwner {
receiverLayer2 = newReceiverLayer2;
}
// zksCoreAddress setter
function setZksCoreAddress(address newZksCoreAddress) external onlyOwner {
zksCoreAddress = ZksCore(newZksCoreAddress);
}
// depositWorker setter
function setDepositWorker(address newDepositWorker) external onlyOwner {
depositWorker = newDepositWorker;
}
// give erc20 approval to Zks core contract
function approveToZksCore(
address[] calldata tokenAddresses,
uint[] calldata allowances
)
external
nonReentrant
onlyOwner
{
require(tokenAddresses.length == allowances.length, "unmatched length");
for (uint i = 0; i < tokenAddresses.length; ++i) {
IERC20(tokenAddresses[i]).safeApprove(address(zksCoreAddress), allowances[i]);
}
}
// for emergency
function emergencyWithdraw(address tokenAddress, uint amount) external onlyOwner nonReentrant {
if (tokenAddress != address(0)) {
// withdraw ERC20
IERC20(tokenAddress).safeTransfer(msg.sender, amount);
return;
}
// withdraw eth
payable(msg.sender).transfer(amount);
}
}
Read Contract
depositWorker 0x319f0cb2 → address
owner 0x8da5cb5b → address
receiverLayer2 0xb328cc50 → address
zksCoreAddress 0x4c346223 → address
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
approveToZksCore 0xfec4d537
address[] tokenAddresses
uint256[] allowances
depositErc20ToZksCore 0x3ad5c594
address[] tokenAddresses
uint104[] amounts
depositEthToZksCore 0xcc0a8520
uint256 amount
emergencyWithdraw 0x95ccea67
address tokenAddress
uint256 amount
renounceOwnership 0x715018a6
No parameters
setDepositWorker 0xf0b2cb16
address newDepositWorker
setReceiverLayer2 0x6b7d2811
address newReceiverLayer2
setZksCoreAddress 0x1547915d
address newZksCoreAddress
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address