Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xf052290bE5FDc3c406EC104f24596a6F2A1c0cF3
Balance 0 ETH
Nonce 1
Code Size 10549 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

10549 bytes
0x60806040526004361015610011575f80fd5b5f3560e01c80630c9cbf0e1461183e5780630ec693ea146117e1578063196f0f62146117735780631b4fc38b146117565780632f2ff15d1461171057806332df6b0e146110255780633d2339b114610ffe5780633e99c55414610fd75780633fd36a3d14610f09578063547cad1214610e7657806355a5133b14610db9578063590e1ae314610b985780636d88ec2c14610b7a57806379502c5514610b0d5780637f83a4a614610ac15780638bb9c5bf14610aa45780638da5cb5b14610a72578063900cf0cf14610a4b57806391d14854146101a55780639c649fdf1461080b578063a06db7dc146107e1578063a1a227fa146107ae578063a1b5ff0814610784578063aa6ca80814610769578063ac5bc06114610613578063bc1bf148146105ce578063beb701ba1461059b578063c9daddad146104e1578063d547741f1461049b578063d9ab2c5c14610461578063deb9a3a2146103f3578063e1ed0a8214610361578063ebc4524f1461031c578063f2fde38b14610236578063f6443091146102005763f8fc08b9146101a5575f80fd5b346101fc5760406003193601126101fc576101be6118cf565b6004355f52600160205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b5f80fd5b346101fc575f6003193601126101fc57602073ffffffffffffffffffffffffffffffffffffffff600b5460401c16604051908152f35b346101fc5760206003193601126101fc5761024f6118ac565b61027173ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b73ffffffffffffffffffffffffffffffffffffffff8116156102985761029690612896565b005b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b346101fc5760206003193601126101fc5773ffffffffffffffffffffffffffffffffffffffff61034a6118ac565b165f526008602052602060405f2054604051908152f35b346101fc5760206003193601126101fc576004355f52600260205260405f206040519081602082549182815201915f5260205f20905f5b8181106103c7576103c3856103af81870382611973565b604051918291602083526020830190611b99565b0390f35b825473ffffffffffffffffffffffffffffffffffffffff16845260209093019260019283019201610398565b346101fc57610401366119cc565b61042373ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b5f5b8151811015610296578061045b73ffffffffffffffffffffffffffffffffffffffff61045360019486611ca2565b51168561218b565b01610425565b346101fc575f6003193601126101fc5760206040517fe844ed9e40aeb388cb97d2ef796e81de635718f440751efb46753791698f6bde8152f35b346101fc5760406003193601126101fc576102966104b76118cf565b6104d973ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b600435611e90565b346101fc5760406003193601126101fc576104fa611a6e565b335f9081527fb144758eeb56710eff6a145d8babeeaa31da464f00a418b8dabebb1e3bbca10e602052604090205460ff161561053d576102969060243590612830565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f756e617574686f72697a656420726f6c650000000000000000000000000000006044820152fd5b346101fc575f6003193601126101fc57602073ffffffffffffffffffffffffffffffffffffffff60065416604051908152f35b346101fc576106036105fc6105f46105e536611b11565b94969390929591953691611d93565b923691611d93565b92336123e1565b906103c360405192839283611c15565b346101fc5760206003193601126101fc5761062c6118ac565b610634611ddf565b908151917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061067b610665856119b4565b946106736040519687611973565b8086526119b4565b015f5b8181106107465750509073ffffffffffffffffffffffffffffffffffffffff5f9116905b8251811015610738578073ffffffffffffffffffffffffffffffffffffffff6106cd60019386611ca2565b5116835f52600760205260405f2073ffffffffffffffffffffffffffffffffffffffff806106fb8589611ca2565b5116165f5260205260405f20546040519161071583611957565b825260208201526107268287611ca2565b526107318186611ca2565b50016106a2565b604051806103c38682611a85565b60209060405161075581611957565b5f81525f838201528282880101520161067e565b346101fc575f6003193601126101fc576103c36103af611ddf565b346101fc5760206003193601126101fc576004355f526002602052602060405f2054604051908152f35b346101fc575f6003193601126101fc57602073ffffffffffffffffffffffffffffffffffffffff60035416604051908152f35b346101fc575f6003193601126101fc57602067ffffffffffffffff60035460a01c16604051908152f35b346101fc5760806003193601126101fc576108246118ac565b60243567ffffffffffffffff81168091036101fc576044359167ffffffffffffffff83116101fc57366023840112156101fc57826004013567ffffffffffffffff81116101fc578301913660248401116101fc576108806118f2565b5073ffffffffffffffffffffffffffffffffffffffff6003541633036109ed57600b549067ffffffffffffffff82160361098f5773ffffffffffffffffffffffffffffffffffffffff809160401c1691160361093157604090829003126101fc57602481013567ffffffffffffffff811681036101fc5760446109269201359061092167ffffffffffffffff6009541667ffffffffffffffff83161161237c565b612830565b602060405160018152f35b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f696e76616c696420736f7572636520636f6e74726163740000000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f696e76616c696420736f7572636520636861696e0000000000000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f63616c6c6572206973206e6f74206d65737361676520627573000000000000006044820152fd5b346101fc575f6003193601126101fc57602067ffffffffffffffff60095416604051908152f35b346101fc575f6003193601126101fc57602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b346101fc5760206003193601126101fc5761029633600435611e90565b346101fc575f6003193601126101fc57602067ffffffffffffffff610b02610af4600454838160e01c9160a01c16611d71565b8260035460a01c1690611d71565b164211604051908152f35b346101fc575f6003193601126101fc57608060045473ffffffffffffffffffffffffffffffffffffffff600654166040519173ffffffffffffffffffffffffffffffffffffffff8116835267ffffffffffffffff8160a01c16602084015260e01c60408301526060820152f35b346101fc57610603610b916105f46105e536611b11565b92806123e1565b346101fc575f6003193601126101fc5760405160a0810181811067ffffffffffffffff821117610d8c5760405260045473ffffffffffffffffffffffffffffffffffffffff8116825267ffffffffffffffff610c46610af46020850193838160a01c168552604086019060e01c815263ffffffff84610c15611cd7565b966060890197885273ffffffffffffffffffffffffffffffffffffffff6006541660808a0152511691511690611d71565b16421115610d2e575f5b8151805182101561029657610c7a8273ffffffffffffffffffffffffffffffffffffffff92611ca2565b5151169073ffffffffffffffffffffffffffffffffffffffff84511691604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481845afa918215610d23575f92610cef575b5090600193610ce99261229d565b01610c50565b91506020823d8211610d1b575b81610d0960209383611973565b810103126101fc579051906001610cdb565b3d9150610cfc565b6040513d5f823e3d90fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f746f6f20736f6f6e0000000000000000000000000000000000000000000000006044820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b346101fc5760206003193601126101fc577f70270fb8dd97868919b2c758596ceef84c7db4f21790f2619ca490067359ec966020610df5611a6e565b610e1773ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b6003547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff7bffffffffffffffff00000000000000000000000000000000000000008360a01b1691161760035567ffffffffffffffff60405191168152a1005b346101fc5760206003193601126101fc577f3f8223bcd8b3b875473e9f9e14e1ad075451a2b5ffd31591655da9a01516bf5e602073ffffffffffffffffffffffffffffffffffffffff610ec76118ac565b610ed5825f54163314611c3d565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000006003541617600355604051908152a1005b346101fc5760406003193601126101fc577f24230cee9a7f9fdea617f2c4dda21c6bae6dbf4a72c1fde0bab9a92f951b2ff16040610f45611a6e565b73ffffffffffffffffffffffffffffffffffffffff67ffffffffffffffff610f6b6118cf565b92610f7a835f54163314611c3d565b1691600b54837fffffffff000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffff000000000000000084881b1692161717600b558351928352166020820152a1005b346101fc575f6003193601126101fc576103c3610ff2611cd7565b60405191829182611a85565b346101fc575f6003193601126101fc57602067ffffffffffffffff600b5416604051908152f35b346101fc5760c06003193601126101fc5760043567ffffffffffffffff81116101fc5780360360a06003198201126101fc5761105f6118cf565b916044359073ffffffffffffffffffffffffffffffffffffffff8216928383036101fc5761108b6118f2565b926084359467ffffffffffffffff86168096036101fc5760a4359673ffffffffffffffffffffffffffffffffffffffff881688036101fc5773ffffffffffffffffffffffffffffffffffffffff5f54166116b25773ffffffffffffffffffffffffffffffffffffffff8116156116545761110490612896565b61112673ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b5f8181527fb144758eeb56710eff6a145d8babeeaa31da464f00a418b8dabebb1e3bbca10e602052604090205460ff166115f6577fe844ed9e40aeb388cb97d2ef796e81de635718f440751efb46753791698f6bde5f52600260205260405f2090815468010000000000000000811015610d8c577f2ae6a113c0ed5b78a53413ffbb7679881f11145ccfba4fb92e863dfcd5a1d2f3936111d18260409560016111fd95018155611915565b90919073ffffffffffffffffffffffffffffffffffffffff8084549260031b9316831b921b1916179055565b7fe844ed9e40aeb388cb97d2ef796e81de635718f440751efb46753791698f6bde5f526001602052815f20815f52602052815f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790558151907fe844ed9e40aeb388cb97d2ef796e81de635718f440751efb46753791698f6bde82526020820152a173ffffffffffffffffffffffffffffffffffffffff6112a783600401611cb6565b167fffffffffffffffffffffffff00000000000000000000000000000000000000006004541617600455602482013567ffffffffffffffff811681036101fc577fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff7bffffffffffffffff00000000000000000000000000000000000000006004549260a01b16911617600455604482013563ffffffff811681036101fc577bffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffff000000000000000000000000000000000000000000000000000000006004549260e01b169116176004557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdd606483013591018112156101fc57810160048101359067ffffffffffffffff82116101fc576024018160061b360381136101fc57680100000000000000008211610d8c5760055482600555808310611544575b5060055f5260205f205f915b8383106114e257878773ffffffffffffffffffffffffffffffffffffffff888161143d60848b01611cb6565b167fffffffffffffffffffffffff00000000000000000000000000000000000000006006541617600655167fffffffffffffffffffffffff000000000000000000000000000000000000000060035416176003557fffffffff000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffff0000000000000000600b549360401b1692161717600b555f80f35b600260408273ffffffffffffffffffffffffffffffffffffffff611507600195611cb6565b167fffffffffffffffffffffffff000000000000000000000000000000000000000086541617855560208101358486015501920192019190611411565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681036115c9577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831683036115c95760055f5260205f209060011b8101908360011b015b8181106115b85750611405565b5f80825560018201556002016115ab565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f616c72656164792068617320726f6c65000000000000000000000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f20616464726573730000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f6f776e657220616c7265616479207365740000000000000000000000000000006044820152fd5b346101fc5760406003193601126101fc5761029661172c6118cf565b61174e73ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b60043561218b565b346101fc575f6003193601126101fc576020600a54604051908152f35b346101fc57611781366119cc565b6117a373ffffffffffffffffffffffffffffffffffffffff5f54163314611c3d565b5f5b815181101561029657806117db73ffffffffffffffffffffffffffffffffffffffff6117d360019486611ca2565b511685611e90565b016117a5565b346101fc5760406003193601126101fc576024356004355f52600260205260405f209081548110156101fc5761182e73ffffffffffffffffffffffffffffffffffffffff91602093611915565b90549060031b1c16604051908152f35b346101fc5760406003193601126101fc576118576118ac565b73ffffffffffffffffffffffffffffffffffffffff6118746118cf565b91165f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036101fc57565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036101fc57565b6064359073ffffffffffffffffffffffffffffffffffffffff821682036101fc57565b805482101561192a575f5260205f2001905f90565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b6040810190811067ffffffffffffffff821117610d8c57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610d8c57604052565b67ffffffffffffffff8111610d8c5760051b60200190565b9060406003198301126101fc57600435916024359067ffffffffffffffff82116101fc57806023830112156101fc57816004013590611a0a826119b4565b92611a186040519485611973565b8284526024602085019360051b8201019182116101fc57602401915b818310611a415750505090565b823573ffffffffffffffffffffffffffffffffffffffff811681036101fc57815260209283019201611a34565b6004359067ffffffffffffffff821682036101fc57565b60206040818301928281528451809452019201905f5b818110611aa85750505090565b8251805173ffffffffffffffffffffffffffffffffffffffff1685526020908101518186015260409094019390920191600101611a9b565b9181601f840112156101fc5782359167ffffffffffffffff83116101fc576020808501948460051b0101116101fc57565b60806003198201126101fc5760043573ffffffffffffffffffffffffffffffffffffffff811681036101fc579160243567ffffffffffffffff81116101fc5782611b5d91600401611ae0565b9290929160443567ffffffffffffffff811681036101fc57916064359067ffffffffffffffff82116101fc57611b9591600401611ae0565b9091565b90602080835192838152019201905f5b818110611bb65750505090565b825173ffffffffffffffffffffffffffffffffffffffff16845260209384019390920191600101611ba9565b90602080835192838152019201905f5b818110611bff5750505090565b8251845260209384019390920191600101611bf2565b9091611c2c611c3a93604084526040840190611b99565b916020818403910152611be2565b90565b15611c4457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b805182101561192a5760209160051b010190565b3573ffffffffffffffffffffffffffffffffffffffff811681036101fc5790565b60055490611ce4826119b4565b91611cf26040519384611973565b80835260055f9081527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0602085015b838310611d2e5750505050565b60026020600192604051611d4181611957565b73ffffffffffffffffffffffffffffffffffffffff86541681528486015483820152815201920192019190611d21565b9067ffffffffffffffff8091169116019067ffffffffffffffff82116115c957565b929190611d9f816119b4565b93611dad6040519586611973565b602085838152019160051b81019283116101fc57905b828210611dcf57505050565b8135815260209182019101611dc3565b600554611deb816119b4565b611df86040519182611973565b8181527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611e25836119b4565b013660208301375f5b82811015611e8a5760019060055f5273ffffffffffffffffffffffffffffffffffffffff81831b7f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0015416611e838285611ca2565b5201611e2e565b50905090565b90815f52600160205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260ff60405f2054161561212d57815f52600260205260405f20908154927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84019384116115c9575f5b83548110156120cf5773ffffffffffffffffffffffffffffffffffffffff611f2a8286611915565b90549060031b1c1673ffffffffffffffffffffffffffffffffffffffff841614611f5657600101611f02565b8481959293949510612094575b50508254928315612067577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f155aaafb6329a2098580462df33ec4b7441b19729b9601c5fc17ae1cf99a8a52940190611fbd8282611915565b73ffffffffffffffffffffffffffffffffffffffff82549160031b1b1916905555805f52600160205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541690556120626040519283928390929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b0390a1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b6111d173ffffffffffffffffffffffffffffffffffffffff6120b96120c89488611915565b90549060031b1c169186611915565b5f80611f63565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f726f6c65206163636f756e74206e6f7420666f756e64000000000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742068617320726f6c6500000000000000000000000000000000000000006044820152fd5b90815f52600160205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260ff60405f2054166115f657815f52600260205260405f209182549268010000000000000000841015610d8c57826111d1856122169360017f2ae6a113c0ed5b78a53413ffbb7679881f11145ccfba4fb92e863dfcd5a1d2f398018155611915565b805f52600160205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790556120626040519283928390929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b916020915f916040519073ffffffffffffffffffffffffffffffffffffffff858301937fa9059cbb0000000000000000000000000000000000000000000000000000000085521660248301526044820152604481526122fd606482611973565b519082855af115610d23575f513d612373575073ffffffffffffffffffffffffffffffffffffffff81163b155b6123315750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b6001141561232a565b1561238357565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f696e76616c69642065706f6368000000000000000000000000000000000000006044820152fd5b93926124009095919567ffffffffffffffff806009541691161461237c565b612408611ddf565b9160405160208101907fffffffffffffffffffffffffffffffffffffffff00000000000000000000000073ffffffffffffffffffffffffffffffffffffffff88169760601b16825260348101855160208701905f5b818110612804575050508184519160208601925f5b8181106127eb5750506124ac9250037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282611973565b51902094600a5495965f975b86518910156124fa576124cb8988611ca2565b5190818110156124e9575f52602052600160405f205b9801976124b8565b905f52602052600160405f206124e1565b9194975092959194500361278d578451947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061254e612538886119b4565b97612546604051998a611973565b8089526119b4565b013660208801375f945f5b82518110156126d35773ffffffffffffffffffffffffffffffffffffffff6125818285611ca2565b511661258d8288611ca2565b5190865f52600760205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f2054808303928084116115c9576125d1858b611ca2565b51895f52600760205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f20550361261b575b5090600191612614828b611ca2565b5201612559565b90975073ffffffffffffffffffffffffffffffffffffffff6006541680155f1461266f575061264b88868361229d565b5f52600860205260405f209081548881018091116115c95790915560019687612605565b331461264b5760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f756e617574686f72697a65642063616c6c6572000000000000000000000000006044820152fd5b5094909391501561272f576127287f6a8d91c49594226b40d453d563914bd89c00f6859210b5b861b4647c1d87b867916040519182916040835261271a604084018a611be2565b908382036020850152611be2565b0390a29190565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f6e6f20756e636c61696d656420726577617264730000000000000000000000006044820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f766572696669636174696f6e206661696c6564000000000000000000000000006044820152fd5b8451835260209485019486945090920191600101612472565b825173ffffffffffffffffffffffffffffffffffffffff1684526020938401939092019160010161245d565b602067ffffffffffffffff7f67039b7f29c2d4367d3562c53c1d8bf1c9b99e22cb742b7a8c1c78940ae7cf66921692837fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000600954161760095580600a55604051908152a2565b73ffffffffffffffffffffffffffffffffffffffff805f54921691827fffffffffffffffffffffffff00000000000000000000000000000000000000008216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a356fea2646970667358221220a7f6497733d6c477ac7d7cd627b64ef592857c6a5d97a34381f805d594b48b3264736f6c634300081d0033

Verified Source Code Full Match

Compiler: v0.8.29+commit.ab55807c EVM: cancun Optimization: Yes (20000 runs)
CampaignRewardsClaim.sol 219 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/Hashes.sol";

import "../../access/AccessControl.sol";
import "./message/MessageReceiverApp.sol";

struct AddrAmt {
    address token;
    uint256 amount;
}

struct Config {
    address creator;
    uint64 startTime;
    uint32 duration; // how many seconds this campaign is active, end after startTime+duration
    AddrAmt[] rewards; // list of [reward token and total amount]
    // If set, only this address can call claim; rewards are not transferred directly, external address handles payout.
    address externalPayoutAddress;
}

// claim campaign rewards on chain one chain, which was submitted on another chain
contract CampaignRewardsClaim is AccessControl, MessageReceiverApp {
    using SafeERC20 for IERC20;

    // e844ed9e40aeb388cb97d2ef796e81de635718f440751efb46753791698f6bde
    bytes32 public constant ROOT_UPDATER_ROLE = keccak256("root_updater");

    // seconds after campaign end, after which all remaining balance can be refunded to creator
    uint64 public gracePeriod = 3600 * 24 * 180; // default 180 days
    Config public config;

    // user -> token -> claimed amount
    mapping(address => mapping(address => uint256)) public claimed;
    // token -> total claimed amount
    mapping(address => uint256) public tokenClaimedRewards;

    uint64 public epoch;
    bytes32 public topRoot;

    uint64 public submissionChainId;
    address public submissionAddress;

    event TopRootUpdated(uint64 indexed epoch, bytes32 topRoot);
    event RewardsClaimed(address indexed earner, uint256[] newAmount, uint256[] cumulativeAmounts);
    event GracePeriodUpdated(uint64 gracePeriod);
    event MessageBusUpdated(address messageBus);
    event SubmissionContractUpdated(uint64 submissionChainId, address submissionAddress);

    function init(
        Config calldata cfg,
        address owner,
        address root_updater,
        address _messageBus,
        uint64 _submissionChainId,
        address _submissionAddress
    ) external {
        initOwner(owner);
        grantRole(ROOT_UPDATER_ROLE, root_updater);
        config = cfg;
        messageBus = _messageBus;
        submissionChainId = _submissionChainId;
        submissionAddress = _submissionAddress;
    }

    // after grace period, refund all remaining balance to creator
    function refund() external {
        Config memory cfg = config;
        require(block.timestamp > cfg.startTime + cfg.duration + gracePeriod, "too soon");
        for (uint256 i = 0; i < cfg.rewards.length; i++) {
            address token = cfg.rewards[i].token;
            IERC20(token).safeTransfer(cfg.creator, IERC20(token).balanceOf(address(this)));
        }
    }

    function canRefund() external view returns (bool) {
        return block.timestamp > config.startTime + config.duration + gracePeriod;
    }

    // claim reward, send erc20 to earner
    function claim(address earner, uint256[] calldata cumulativeAmounts, uint64 _epoch, bytes32[] calldata proof)
        external
        returns (address[] memory, uint256[] memory)
    {
        return _claim(earner, earner, cumulativeAmounts, _epoch, proof);
    }

    // msg.sender is the earner
    function claimWithRecipient(
        address to,
        uint256[] calldata cumulativeAmounts,
        uint64 _epoch,
        bytes32[] calldata proof
    ) external returns (address[] memory, uint256[] memory) {
        return _claim(msg.sender, to, cumulativeAmounts, _epoch, proof);
    }

    /**
     * @notice Updates the epoch and top Merkle root info
     * @param _epoch The epoch number.
     * @param _topRoot The Merkle root for the top tree.
     */
    function updateRoot(uint64 _epoch, bytes32 _topRoot) external onlyRole(ROOT_UPDATER_ROLE) {
        _updateRoot(_epoch, _topRoot);
    }

    // called by MessageBus contract to receive cross-chain message from the rewards submission contract
    function _executeMessage(address _srcContract, uint64 _srcChainId, bytes calldata _message) internal override {
        require(_srcChainId == submissionChainId, "invalid source chain");
        require(_srcContract == submissionAddress, "invalid source contract");
        (uint64 _epoch, bytes32 _topRoot) = abi.decode((_message), (uint64, bytes32));
        require(_epoch > epoch, "invalid epoch");
        _updateRoot(_epoch, _topRoot);
    }

    function getTokens() public view returns (address[] memory) {
        address[] memory tokens = new address[](config.rewards.length);
        for (uint256 i = 0; i < config.rewards.length; i++) {
            tokens[i] = config.rewards[i].token;
        }
        return tokens;
    }

    function getCampaignRewardConfig() public view returns (AddrAmt[] memory) {
        return config.rewards;
    }

    function viewClaimedRewards(address earner) external view returns (AddrAmt[] memory) {
        address[] memory tokens = getTokens();
        AddrAmt[] memory ret = new AddrAmt[](tokens.length);
        for (uint256 i = 0; i < tokens.length; i++) {
            ret[i] = AddrAmt({token: tokens[i], amount: claimed[earner][tokens[i]]});
        }
        return ret;
    }

    function externalPayoutAddress() external view returns (address) {
        return config.externalPayoutAddress;
    }

    // ----- admin functions -----
    function setSubmissionContract(uint64 _submissionChainId, address _submissionAddress) external onlyOwner {
        submissionChainId = _submissionChainId;
        submissionAddress = _submissionAddress;
        emit SubmissionContractUpdated(_submissionChainId, _submissionAddress);
    }

    function setMessageBus(address _messageBus) external onlyOwner {
        messageBus = _messageBus;
        emit MessageBusUpdated(_messageBus);
    }

    function setGracePeriod(uint64 _gracePeriod) external onlyOwner {
        gracePeriod = _gracePeriod;
        emit GracePeriodUpdated(_gracePeriod);
    }

    // ------------------------------------------
    // -----------  private functions -----------
    /**
     * @notice Claims rewards for a user using a combined sub tree + top tree Merkle proof.
     * @param earner The earner address.
     * @param to Reward recipient address.
     * @param cumulativeAmounts The cumulative reward amount.
     * @param _epoch The epoch of the proof
     * @param proof The Merkle proof from the sub tree leaf node to the top tree root.
     */
    function _claim(
        address earner,
        address to,
        uint256[] memory cumulativeAmounts,
        uint64 _epoch,
        bytes32[] memory proof
    ) private returns (address[] memory, uint256[] memory) {
        require(_epoch == epoch, "invalid epoch");
        address[] memory tokens = getTokens();
        bytes32 leafHash = keccak256(abi.encodePacked(earner, tokens, cumulativeAmounts));
        require(verifyMerkleProof(proof, topRoot, leafHash), "verification failed");

        uint256[] memory newAmount = new uint256[](tokens.length);
        bool hasUnclaimed = false;
        for (uint256 i = 0; i < tokens.length; i++) {
            address erc20 = tokens[i];
            uint256 tosend = cumulativeAmounts[i] - claimed[earner][erc20];
            claimed[earner][erc20] = cumulativeAmounts[i];
            // send token
            if (tosend > 0) {
                if (config.externalPayoutAddress == address(0)) {
                    IERC20(erc20).safeTransfer(to, tosend);
                } else {
                    require(msg.sender == config.externalPayoutAddress, "unauthorized caller");
                }
                tokenClaimedRewards[erc20] += tosend;
                hasUnclaimed = true;
            }
            newAmount[i] = tosend;
        }
        require(hasUnclaimed, "no unclaimed rewards");
        emit RewardsClaimed(earner, newAmount, cumulativeAmounts);
        return (tokens, newAmount);
    }

    function _updateRoot(uint64 _epoch, bytes32 _topRoot) private {
        epoch = _epoch;
        topRoot = _topRoot;
        emit TopRootUpdated(epoch, topRoot);
    }

    function verifyMerkleProof(bytes32[] memory proof, bytes32 root, bytes32 leafHash) private pure returns (bool) {
        bytes32 hash = leafHash;
        for (uint256 i = 0; i < proof.length; i++) {
            hash = Hashes.commutativeKeccak256(hash, proof[i]);
        }
        return hash == root;
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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);
}
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);
    }
}
Hashes.sol 31 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/Hashes.sol)

pragma solidity ^0.8.20;

/**
 * @dev Library of standard hash functions.
 *
 * _Available since v5.1._
 */
library Hashes {
    /**
     * @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
     *
     * NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
     */
    function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
        return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
        assembly ("memory-safe") {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}
AccessControl.sol 81 lines
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.20;

import "./Ownable.sol";

abstract contract AccessControl is Ownable {
    mapping(bytes32 role => mapping(address account => bool)) public roles;
    mapping(bytes32 role => address[] accounts) public roleAccounts;

    event RoleGranted(bytes32 role, address account);
    event RoleRevoked(bytes32 role, address account);

    modifier onlyRole(bytes32 role) {
        require(hasRole(role, msg.sender), "unauthorized role");
        _;
    }

    function hasRole(bytes32 role, address account) public view returns (bool) {
        return roles[role][account];
    }

    function numRoleAccounts(bytes32 role) public view returns (uint256) {
        return roleAccounts[role].length;
    }

    function getRoleAccounts(bytes32 role) public view returns (address[] memory accounts) {
        return roleAccounts[role];
    }

    function grantRole(bytes32 role, address account) public onlyOwner {
        _grantRole(role, account);
    }

    function grantRoles(bytes32 role, address[] memory accounts) public onlyOwner {
        for (uint256 i = 0; i < accounts.length; i++) {
            _grantRole(role, accounts[i]);
        }
    }

    function revokeRole(bytes32 role, address account) public onlyOwner {
        _revokeRole(role, account);
    }

    function revokeRoles(bytes32 role, address[] memory accounts) public onlyOwner {
        for (uint256 i = 0; i < accounts.length; i++) {
            _revokeRole(role, accounts[i]);
        }
    }

    function renounceRole(bytes32 role) public {
        _revokeRole(role, msg.sender);
    }

    // -------------- internal functions --------------

    function _grantRole(bytes32 role, address account) internal {
        require(!hasRole(role, account), "already has role");
        roleAccounts[role].push(account);
        roles[role][account] = true;
        emit RoleGranted(role, account);
    }

    function _revokeRole(bytes32 role, address account) internal {
        require(hasRole(role, account), "not has role");
        address[] storage accountList = roleAccounts[role];
        uint256 lastIndex = accountList.length - 1;
        for (uint256 i = 0; i < accountList.length; i++) {
            if (accountList[i] == account) {
                if (i < lastIndex) {
                    accountList[i] = accountList[lastIndex];
                }
                accountList.pop();
                roles[role][account] = false;
                emit RoleRevoked(role, account);
                return;
            }
        }
        revert("role account not found"); // this should never happen
    }
}
MessageReceiverApp.sol 35 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

abstract contract MessageReceiverApp {
    enum ExecutionStatus {
        Fail,
        Success,
        Retry
    }

    address public messageBus;

    modifier onlyMessageBus() {
        require(msg.sender == messageBus, "caller is not message bus");
        _;
    }

    /**
     * @notice Called by MessageBus to execute a message
     * @param _sender The address of the source app contract
     * @param _srcChainId The source chain ID where the transfer is originated from
     * @param _message Arbitrary message bytes originated from and encoded by the source app contract
     */
    function executeMessage(
        address _sender,
        uint64 _srcChainId,
        bytes calldata _message,
        address // _executor: address who called the MessageBus execution function
    ) external onlyMessageBus returns (ExecutionStatus) {
        _executeMessage(_sender, _srcChainId, _message);
        return ExecutionStatus.Success;
    }

    function _executeMessage(address _sender, uint64 _srcChainId, bytes calldata _message) internal virtual {}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

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);
}
Ownable.sol 78 lines
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * This adds a normal func that setOwner if _owner is address(0). So we can't allow
 * renounceOwnership. So we can support Proxy based upgradable contract
 */
abstract contract Ownable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(msg.sender);
    }

    /**
     * @dev Only to be called by inherit contracts, in their init func called by Proxy
     * we require _owner == address(0), which is only possible when it's a delegateCall
     * because constructor sets _owner in contract state.
     */
    function initOwner() internal {
        require(_owner == address(0), "owner already set");
        _setOwner(msg.sender);
    }

    // allow setting owner different from deployer
    function initOwner(address newowner) internal {
        require(_owner == address(0), "owner already set");
        require(newowner != address(0), "new owner is the zero address");
        _setOwner(newowner);
    }

    /**
     * @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() == msg.sender, "Ownable: caller is not the owner");
        _;
    }

    /**
     * @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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @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

ROOT_UPDATER_ROLE 0xd9ab2c5c → bytes32
canRefund 0x7f83a4a6 → bool
claimed 0x0c9cbf0e → uint256
config 0x79502c55 → address, uint64, uint32, address
epoch 0x900cf0cf → uint64
externalPayoutAddress 0xbeb701ba → address
getCampaignRewardConfig 0x3e99c554 → tuple[]
getRoleAccounts 0xe1ed0a82 → address[]
getTokens 0xaa6ca808 → address[]
gracePeriod 0xa06db7dc → uint64
hasRole 0x91d14854 → bool
messageBus 0xa1a227fa → address
numRoleAccounts 0xa1b5ff08 → uint256
owner 0x8da5cb5b → address
roleAccounts 0x0ec693ea → address
roles 0xf8fc08b9 → bool
submissionAddress 0xf6443091 → address
submissionChainId 0x3d2339b1 → uint64
tokenClaimedRewards 0xebc4524f → uint256
topRoot 0x1b4fc38b → bytes32
viewClaimedRewards 0xac5bc061 → tuple[]

Write Contract 15 functions

These functions modify contract state and require a wallet transaction to execute.

claim 0x6d88ec2c
address earner
uint256[] cumulativeAmounts
uint64 _epoch
bytes32[] proof
returns: address[], uint256[]
claimWithRecipient 0xbc1bf148
address to
uint256[] cumulativeAmounts
uint64 _epoch
bytes32[] proof
returns: address[], uint256[]
executeMessage 0x9c649fdf
address _sender
uint64 _srcChainId
bytes _message
address
returns: uint8
grantRole 0x2f2ff15d
bytes32 role
address account
grantRoles 0xdeb9a3a2
bytes32 role
address[] accounts
init 0xe962e43a
tuple cfg
address owner
address root_updater
address _messageBus
uint64 _submissionChainId
address _submissionAddress
refund 0x590e1ae3
No parameters
renounceRole 0x8bb9c5bf
bytes32 role
revokeRole 0xd547741f
bytes32 role
address account
revokeRoles 0x196f0f62
bytes32 role
address[] accounts
setGracePeriod 0x55a5133b
uint64 _gracePeriod
setMessageBus 0x547cad12
address _messageBus
setSubmissionContract 0x3fd36a3d
uint64 _submissionChainId
address _submissionAddress
transferOwnership 0xf2fde38b
address newOwner
updateRoot 0xc9daddad
uint64 _epoch
bytes32 _topRoot

Recent Transactions

No transactions found for this address