Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x25dF2eE0E2e33f87f7a3dbD8245F49bCf9b7070d
Balance 0 ETH
Nonce 1
Code Size 9285 bytes
Indexed Transactions 0 (1 on-chain, 1.3% indexed)
External Etherscan · Sourcify

Contract Bytecode

9285 bytes
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c806391d1485411610104578063d547741f116100a2578063f23a6e6111610071578063f23a6e61146104d9578063f5bfbd13146104f8578063f706004814610518578063f7c618c114610543576101da565b8063d547741f14610480578063da5da65f14610493578063e467f7e0146104b3578063e683ad44146104c6576101da565b8063aae282e1116100de578063aae282e1146103e3578063b1adb0831461040e578063bc197c8114610421578063d539139314610459576101da565b806391d14854146103b55780639dc29fac146103c8578063a217fddf146103db576101da565b806337e9f64a1161017c5780637709b85d1161014b5780637709b85d146103155780637b0a47ee1461032857806380faa57d146103315780638117fbc714610339576101da565b806337e9f64a146102ad578063399080ec146102b6578063523a3f08146102ef57806370a0823114610302576101da565b8063282c51f3116101b8578063282c51f31461024d578063293be456146102745780632f2ff15d1461028757806336568abe1461029a576101da565b8063018413e7146101df57806301ffc9a7146101f4578063248a9ca31461021c575b600080fd5b6101f26101ed366004611fc0565b610556565b005b610207610202366004612003565b61058b565b60405190151581526020015b60405180910390f35b61023f61022a366004611fc0565b60009081526020819052604090206001015490565b604051908152602001610213565b61023f7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84881565b6101f2610282366004611fc0565b6105d3565b6101f2610295366004611fd8565b6105ff565b6101f26102a8366004611fd8565b61062b565b61023f60045481565b61023f6102c4366004611dae565b6001600160a01b0316600090815260016020526040902054600160a01b90046001600160401b031690565b6101f26102fd366004611fc0565b6106a9565b61023f610310366004611dae565b610785565b6101f2610323366004611f60565b61083d565b61023f60055481565b61023f6108e9565b610382610347366004611dae565b60016020526000908152604090205463ffffffff811690600160201b81046001600160801b031690600160a01b90046001600160401b031683565b6040805163ffffffff90941684526001600160801b0390921660208401526001600160401b031690820152606001610213565b6102076103c3366004611fd8565b6108fc565b6101f26103d6366004611ecf565b610925565b61023f600081565b6006546103f6906001600160a01b031681565b6040516001600160a01b039091168152602001610213565b6101f261041c366004611f60565b610a03565b61044061042f366004611dc8565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610213565b61023f7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6101f261048e366004611fd8565b610d83565b61023f6104a1366004611fc0565b60036020526000908152604090205481565b6101f26104c1366004611ef8565b610da9565b6101f26104d4366004611f60565b610ef3565b6104406104e7366004611e6d565b63f23a6e6160e01b95945050505050565b61050b610506366004611ecf565b6111a5565b60405161021391906121a4565b61023f610526366004611ecf565b600260209081526000928352604080842090915290825290205481565b6007546103f6906001600160a01b031681565b6105616000336103c3565b6105865760405162461bcd60e51b815260040161057d9061223e565b60405180910390fd5b600455565b60006001600160e01b03198216630271189760e51b14806105bc57506001600160e01b03198216637965db0b60e01b145b806105cb57506105cb82611711565b90505b919050565b6105de6000336103c3565b6105fa5760405162461bcd60e51b815260040161057d9061223e565b600555565b60008281526020819052604090206001015461061c81335b611736565b610626838361179a565b505050565b6001600160a01b038116331461069b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161057d565b6106a5828261181e565b5050565b6106b533600080611883565b33600090815260016020526040902080548291906004906106e7908490600160201b90046001600160801b0316612322565b82546001600160801b039182166101009390930a9283029190920219909116179055506007546001600160a01b03166340c10f196107223390565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b15801561076a57600080fd5b505af115801561077e573d6000803e3d6000fd5b5050505050565b6001600160a01b038116600090815260016020526040812054819063ffffffff166107ae6108e9565b1115610802576001600160a01b0383166000908152600160205260409020546107ff906001600160401b03600160a01b8204169063ffffffff166107f06108e9565b6107fa919061234a565b611a07565b90505b6001600160a01b038316600090815260016020526040902054610836908290600160201b90046001600160801b03166122c9565b9392505050565b6108486000336103c3565b6108645760405162461bcd60e51b815260040161057d9061223e565b60005b82518110156106265781818151811061089057634e487b7160e01b600052603260045260246000fd5b6020026020010151600360008584815181106108bc57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000208190555080806108e1906123c8565b915050610867565b60006108f742600454611a22565b905090565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61094f7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a848336103c3565b6109945760405162461bcd60e51b815260206004820152601660248201527531b0b63632b91034b9903737ba103090313ab93732b960511b604482015260640161057d565b6109a082600080611883565b6001600160a01b038216600090815260016020526040902080548291906004906109db908490600160201b90046001600160801b0316612322565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505050565b6000805b8351811015610d7657828181518110610a3057634e487b7160e01b600052603260045260246000fd5b602002602001015160026000610a433390565b6001600160a01b03166001600160a01b031681526020019081526020016000206000868481518110610a8557634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020541015610ade5760405162461bcd60e51b81526020600482015260116024820152706e6f7420656e6f75676820737570706c7960781b604482015260640161057d565b60065484516001600160a01b039091169060009082906301870f0290889086908110610b1a57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610b4091815260200190565b60806040518083038186803b158015610b5857600080fd5b505afa158015610b6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b90919061202b565b600001519050848381518110610bb657634e487b7160e01b600052603260045260246000fd5b602002602001015160036000836001600160801b0316815260200190815260200160002054610be59190612303565b610bef90856122c9565b93506001600160a01b03821663f242432a3033898781518110610c2257634e487b7160e01b600052603260045260246000fd5b6020026020010151898881518110610c4a57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518060400160405280600381526020016203078360ec1b8152506040518663ffffffff1660e01b8152600401610c8e95949392919061215f565b600060405180830381600087803b158015610ca857600080fd5b505af1158015610cbc573d6000803e3d6000fd5b50505050848381518110610ce057634e487b7160e01b600052603260045260246000fd5b602002602001015160026000610cf33390565b6001600160a01b03166001600160a01b031681526020019081526020016000206000888681518110610d3557634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000828254610d5a919061234a565b9250508190555050508080610d6e906123c8565b915050610a07565b5061062633826001611883565b600082815260208190526040902060010154610d9f8133610617565b610626838361181e565b610dd37f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6336103c3565b610e185760405162461bcd60e51b815260206004820152601660248201527531b0b63632b91034b9903737ba10309036b4b73a32b960511b604482015260640161057d565b60005b8381101561077e57828282818110610e4357634e487b7160e01b600052603260045260246000fd5b9050602002013560016000878785818110610e6e57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610e839190611dae565b6001600160a01b0316815260208101919091526040016000208054600490610ebc908490600160201b90046001600160801b031661229e565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508080610eeb906123c8565b915050610e1b565b6000805b83518110156111985760065484516001600160a01b039091169060009082906301870f0290889086908110610f3c57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610f6291815260200190565b60806040518083038186803b158015610f7a57600080fd5b505afa158015610f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb2919061202b565b600001519050848381518110610fd857634e487b7160e01b600052603260045260246000fd5b602002602001015160036000836001600160801b03168152602001908152602001600020546110079190612303565b61101190856122c9565b93506001600160a01b03821663f242432a333089878151811061104457634e487b7160e01b600052603260045260246000fd5b602002602001015189888151811061106c57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518060400160405280600381526020016203078360ec1b8152506040518663ffffffff1660e01b81526004016110b095949392919061215f565b600060405180830381600087803b1580156110ca57600080fd5b505af11580156110de573d6000803e3d6000fd5b5050505084838151811061110257634e487b7160e01b600052603260045260246000fd5b6020026020010151600260006111153390565b6001600160a01b03166001600160a01b03168152602001908152602001600020600088868151811061115757634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600082825461117c91906122c9565b9250508190555050508080611190906123c8565b915050610ef7565b5061062633826000611883565b600654604080516348dd18bd60e11b815290516060926001600160a01b0316916000918591620f42409185916391ba317a916004808301926020929190829003018186803b1580156111f657600080fd5b505afa15801561120a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122e91906120a6565b611238919061234a565b61124291906122c9565b6001600160401b0381111561126757634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561129a57816020015b60608152602001906001900390816112855790505b509050600060015b836001600160a01b03166391ba317a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112db57600080fd5b505afa1580156112ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131391906120a6565b81116114fa5760405162c3878160e11b8152600481018290526000906001600160a01b038616906301870f029060240160806040518083038186803b15801561135b57600080fd5b505afa15801561136f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611393919061202b565b5190506001600160801b0381161580156113af5750620f424182105b156113bb57620f424191505b6001600160a01b038816600090815260026020908152604080832085845290915290205480156114e55760408051600280825260608201835290916020830190803683370190505085858151811061142357634e487b7160e01b600052603260045260246000fd5b60200260200101819052508285858151811061144f57634e487b7160e01b600052603260045260246000fd5b602002602001015160008151811061147757634e487b7160e01b600052603260045260246000fd5b602002602001018181525050808585815181106114a457634e487b7160e01b600052603260045260246000fd5b60200260200101516001815181106114cc57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152836114e1816123c8565b9450505b505080806114f2906123c8565b9150506112a2565b506000816001600160401b0381111561152357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561155657816020015b60608152602001906001900390816115415790505b50905060005b82811015611706576040805160028082526060820183529091602083019080368337019050508282815181106115a257634e487b7160e01b600052603260045260246000fd5b60200260200101819052508381815181106115cd57634e487b7160e01b600052603260045260246000fd5b60200260200101516000815181106115f557634e487b7160e01b600052603260045260246000fd5b602002602001015182828151811061161d57634e487b7160e01b600052603260045260246000fd5b602002602001015160008151811061164557634e487b7160e01b600052603260045260246000fd5b60200260200101818152505083818151811061167157634e487b7160e01b600052603260045260246000fd5b602002602001015160018151811061169957634e487b7160e01b600052603260045260246000fd5b60200260200101518282815181106116c157634e487b7160e01b600052603260045260246000fd5b60200260200101516001815181106116e957634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806116fe816123c8565b91505061155c565b509695505050505050565b60006001600160e01b03198216630271189760e51b14806105cb57506105cb82611a38565b61174082826108fc565b6106a557611758816001600160a01b03166014611a6d565b611763836020611a6d565b6040516020016117749291906120ea565b60408051601f198184030181529082905262461bcd60e51b825261057d9160040161222b565b6117a482826108fc565b6106a5576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556117da3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61182882826108fc565b156106a5576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0383166000908152600160209081526040918290208251606081018452905463ffffffff8116808352600160201b82046001600160801b031693830193909352600160a01b90046001600160401b0316928101929092526118e96108e9565b111561193757600061191582604001516001600160401b0316836000015163ffffffff166107f06108e9565b90508082602001818151611929919061229e565b6001600160801b0316905250505b82156119855781156119665782816040018181516119559190612361565b6001600160401b0316905250611985565b828160400181815161197891906122e1565b6001600160401b03169052505b63ffffffff42811682526001600160a01b03909416600090815260016020908152604091829020835181549285015193909401516001600160401b0316600160a01b0267ffffffffffffffff60a01b196001600160801b03909416600160201b026001600160a01b031990931694909716939093171716939093179092555050565b60008260055483611a189190612303565b6108369190612303565b6000818310611a315781610836565b5090919050565b60006001600160e01b03198216637965db0b60e01b14806105cb57506301ffc9a760e01b6001600160e01b03198316146105cb565b60606000611a7c836002612303565b611a879060026122c9565b6001600160401b03811115611aac57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611ad6576020820181803683370190505b509050600360fc1b81600081518110611aff57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611b3c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611b60846002612303565b611b6b9060016122c9565b90505b6001811115611bff576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611bad57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611bd157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611bf8816123b1565b9050611b6e565b5083156108365760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161057d565b80356001600160a01b03811681146105ce57600080fd5b60008083601f840112611c76578182fd5b5081356001600160401b03811115611c8c578182fd5b6020830191508360208260051b8501011115611ca757600080fd5b9250929050565b600082601f830112611cbe578081fd5b813560206001600160401b03821115611cd957611cd96123f9565b8160051b611ce882820161226e565b838152828101908684018388018501891015611d02578687fd5b8693505b85841015611d24578035835260019390930192918401918401611d06565b50979650505050505050565b600082601f830112611d40578081fd5b81356001600160401b03811115611d5957611d596123f9565b611d6c601f8201601f191660200161226e565b818152846020838601011115611d80578283fd5b816020850160208301379081016020019190915292915050565b805163ffffffff811681146105ce57600080fd5b600060208284031215611dbf578081fd5b61083682611c4e565b600080600080600060a08688031215611ddf578081fd5b611de886611c4e565b9450611df660208701611c4e565b935060408601356001600160401b0380821115611e11578283fd5b611e1d89838a01611cae565b94506060880135915080821115611e32578283fd5b611e3e89838a01611cae565b93506080880135915080821115611e53578283fd5b50611e6088828901611d30565b9150509295509295909350565b600080600080600060a08688031215611e84578081fd5b611e8d86611c4e565b9450611e9b60208701611c4e565b9350604086013592506060860135915060808601356001600160401b03811115611ec3578182fd5b611e6088828901611d30565b60008060408385031215611ee1578182fd5b611eea83611c4e565b946020939093013593505050565b60008060008060408587031215611f0d578384fd5b84356001600160401b0380821115611f23578586fd5b611f2f88838901611c65565b90965094506020870135915080821115611f47578384fd5b50611f5487828801611c65565b95989497509550505050565b60008060408385031215611f72578182fd5b82356001600160401b0380821115611f88578384fd5b611f9486838701611cae565b93506020850135915080821115611fa9578283fd5b50611fb685828601611cae565b9150509250929050565b600060208284031215611fd1578081fd5b5035919050565b60008060408385031215611fea578182fd5b82359150611ffa60208401611c4e565b90509250929050565b600060208284031215612014578081fd5b81356001600160e01b031981168114610836578182fd5b60006080828403121561203c578081fd5b612046608061226e565b82516001600160801b038116811461205c578283fd5b815261206a60208401611d9a565b602082015261207b60408401611d9a565b604082015260608301516001600160f81b03198116811461209a578283fd5b60608201529392505050565b6000602082840312156120b7578081fd5b5051919050565b600081518084526120d6816020860160208601612381565b601f01601f19169290920160200192915050565b60007f416363657373436f6e74726f6c3a206163636f756e742000000000000000000082528351612122816017850160208801612381565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612153816028840160208801612381565b01602801949350505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612199908301846120be565b979650505050505050565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b8281101561221e57878503603f19018452815180518087529087019087870190895b81811015612208578351835292890192918901916001016121ec565b50909650505092850192908501906001016121ca565b5092979650505050505050565b60006020825261083660208301846120be565b60208082526016908201527531b0b63632b91034b9903737ba1030b71037bbb732b960511b604082015260600190565b604051601f8201601f191681016001600160401b0381118282101715612296576122966123f9565b604052919050565b60006001600160801b038083168185168083038211156122c0576122c06123e3565b01949350505050565b600082198211156122dc576122dc6123e3565b500190565b60006001600160401b038083168185168083038211156122c0576122c06123e3565b600081600019048311821515161561231d5761231d6123e3565b500290565b60006001600160801b0383811690831681811015612342576123426123e3565b039392505050565b60008282101561235c5761235c6123e3565b500390565b60006001600160401b0383811690831681811015612342576123426123e3565b60005b8381101561239c578181015183820152602001612384565b838111156123ab576000848401525b50505050565b6000816123c0576123c06123e3565b506000190190565b60006000198214156123dc576123dc6123e3565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212201bc73dd710666d290ff5c98c1b9989d4366df0249c0540eb83e1f95a30e1c6df64736f6c63430008030033

Verified Source Code Partial Match

Compiler: v0.8.3+commit.8d00100c EVM: istanbul Optimization: Yes (200 runs)
TLOLStakingPool.sol 233 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.3;

import "./IERC20UtilityToken.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";


interface IRainiNft1155 is IERC1155 {
  
  struct TokenVars {
    uint128 cardId;
    uint32 level;
    uint32 number; // to assign a numbering to NFTs
    bytes1 mintedContractChar;
  }

  function maxTokenId() external view returns (uint256);

  function tokenVars(uint256 _tokenId) external view returns (TokenVars memory);
}

contract TLOLStakingPool is AccessControl, ERC1155Holder {
  
  bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
  bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

  struct AccountRewardVars {
    uint32 lastUpdated;
    uint128 pointsBalance;
    uint64 totalStaked;
  }

  mapping(address => AccountRewardVars) public accountRewardVars;
  mapping(address => mapping(uint256 => uint256)) public stakedNFTs;

  mapping(uint256 => uint256) public cardStakingValues;

  uint256 public rewardEndTime;
  uint256 public rewardRate;
  address public nftContractAddress;
  IERC20UtilityToken public rewardToken;
  
  constructor(uint256 _rewardRate, uint256 _rewardEndTime, address _nftContractAddress, address rewardTokenAddress) {
    _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
    rewardEndTime = _rewardEndTime;
    rewardRate = _rewardRate;
    nftContractAddress = _nftContractAddress;
    rewardToken = IERC20UtilityToken(rewardTokenAddress);
  }

  modifier onlyOwner() {
    require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "caller is not an owner");
    _;
  }

  modifier onlyBurner() {
    require(hasRole(BURNER_ROLE, _msgSender()), "caller is not a burner");
    _;
  }

  modifier onlyMinter() {
    require(hasRole(MINTER_ROLE, _msgSender()), "caller is not a minter");
    _;
  }

  
  function balanceUpdate(address _owner, uint256 _valueStakedDiff, bool isSubtracted) internal {
    AccountRewardVars memory _rewardVars = accountRewardVars[_owner];

    if (lastTimeRewardApplicable() > _rewardVars.lastUpdated) {
      uint256 reward = calculateReward(_rewardVars.totalStaked, lastTimeRewardApplicable() - _rewardVars.lastUpdated);
      _rewardVars.pointsBalance += uint128(reward);
    }

    if (_valueStakedDiff != 0) {
      if (isSubtracted) {
        _rewardVars.totalStaked -=  uint64(_valueStakedDiff);
      } else {
        _rewardVars.totalStaked +=  uint64(_valueStakedDiff);
      }
    }
    
    _rewardVars.lastUpdated = uint32(block.timestamp);

    accountRewardVars[_owner] = _rewardVars;
  }

  function getStaked(address _owner) 
    public view returns(uint256) {
      return accountRewardVars[_owner].totalStaked;
  }

  function getStakedTokens(address _address, uint256 _cardCount) 
    external view returns (uint256[][] memory amounts) {
      IRainiNft1155 tokenContract = IRainiNft1155(nftContractAddress);

      uint256[][] memory _amounts = new uint256[][](tokenContract.maxTokenId() - 1000000 + _cardCount);
      uint256 count;
      for (uint256 i = 1; i <= tokenContract.maxTokenId(); i++) {
        uint128 cardId = tokenContract.tokenVars(i).cardId;
        if (cardId == 0 && i < 1000001) {
          i = 1000001;
        }
        uint256 balance = stakedNFTs[_address][i];
        if (balance != 0) {
          _amounts[count] = new uint256[](2);
          _amounts[count][0] = i;
          _amounts[count][1] = balance;
          count++;
        }
      }

      uint256[][] memory _amounts2 = new uint256[][](count);
      for (uint256 i = 0; i < count; i++) {
        _amounts2[i] = new uint256[](2);
        _amounts2[i][0] = _amounts[i][0];
        _amounts2[i][1] = _amounts[i][1];
      }

      return _amounts2;
  }
  
  function balanceOf(address _owner)
    public view returns(uint256) {
      uint256 reward = 0;
      if (lastTimeRewardApplicable() > accountRewardVars[_owner].lastUpdated) {
        reward = calculateReward(accountRewardVars[_owner].totalStaked, lastTimeRewardApplicable() - accountRewardVars[_owner].lastUpdated);
      }
      return accountRewardVars[_owner].pointsBalance + reward;
  }

  function setReward(uint256 _rewardRate)
    external onlyOwner {
      rewardRate = _rewardRate;
  }

  function setRewardEndTime(uint256 _rewardEndTime)
    external onlyOwner {
    rewardEndTime = _rewardEndTime;
  }

  function setCardStakingValues(uint256[] memory _cardIds, uint256[] memory _values)
    external onlyOwner {
      for (uint256 i = 0; i < _cardIds.length; i++) {
        cardStakingValues[_cardIds[i]] = _values[i];
      }
  }

  function lastTimeRewardApplicable() public view returns (uint256) {
    return Math.min(block.timestamp, rewardEndTime);
  }

  function stake(uint256[] memory _tokenId, uint256[] memory _amount)
    external {

      uint256 addedStakingValue = 0;

      for (uint256 i = 0; i < _tokenId.length; i++) {

        IRainiNft1155 tokenContract = IRainiNft1155(nftContractAddress);

        uint128 cardId = tokenContract.tokenVars(_tokenId[i]).cardId;

        addedStakingValue += cardStakingValues[cardId] * _amount[i];

        tokenContract.safeTransferFrom(_msgSender(), address(this), _tokenId[i], _amount[i], bytes('0x0'));

        stakedNFTs[_msgSender()][_tokenId[i]] += _amount[i];
      }

      balanceUpdate(_msgSender(), addedStakingValue, false);
  }
  
  function unstake(uint256[] memory _tokenId, uint256[] memory _amount)
    external {

      uint256 subtractedStakingValue = 0;

      for (uint256 i = 0; i < _tokenId.length; i++) {

        require(stakedNFTs[_msgSender()][_tokenId[i]] >= _amount[i], 'not enough supply');

        IRainiNft1155 tokenContract = IRainiNft1155(nftContractAddress);

        uint128 cardId = tokenContract.tokenVars(_tokenId[i]).cardId;

        subtractedStakingValue += cardStakingValues[cardId] * _amount[i];

        tokenContract.safeTransferFrom(address(this), _msgSender(), _tokenId[i], _amount[i], bytes('0x0'));

        stakedNFTs[_msgSender()][_tokenId[i]] -= _amount[i];
      }

      balanceUpdate(_msgSender(), subtractedStakingValue, true);
  }
  
  function mint(address[] calldata _addresses, uint256[] calldata _points) 
    external onlyMinter {
      for (uint256 i = 0; i < _addresses.length; i++) {
        accountRewardVars[_addresses[i]].pointsBalance += uint128(_points[i]);
      }
  }
  
  function burn(address _owner, uint256 _amount) 
    external onlyBurner {
      balanceUpdate(_owner, 0, false);
      accountRewardVars[_owner].pointsBalance -= uint128(_amount);
  }
    
  function calculateReward(uint256 _amount, uint256 _duration) 
    private view returns(uint256) {
      return _duration * rewardRate * _amount;
  }

  function withdrawReward(uint256 _amount) 
    external {
      balanceUpdate(_msgSender(), 0, false);
      accountRewardVars[_msgSender()].pointsBalance -= uint128(_amount);
      rewardToken.mint(_msgSender(), _amount);
  }

  function supportsInterface(bytes4 interfaceId) 
    public virtual override(ERC1155Receiver, AccessControl) view returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId
            || interfaceId == type(IAccessControl).interfaceId
            || super.supportsInterface(interfaceId);
  }

}
Context.sol 23 lines
// SPDX-License-Identifier: MIT

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;
    }
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}
Math.sol 42 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}
IERC20UtilityToken.sol 10 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.3;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IERC20UtilityToken is IERC20 {
  function mint(address to, uint256 amount) external;
  function burn(address account, uint256 amount) external;
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT

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);
}
AccessControl.sol 210 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IAccessControl.sol 87 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
IERC1155.sol 124 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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);
}
IERC1155Receiver.sol 52 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
        @dev Handles the receipt of a single ERC1155 token type. This function is
        called at the end of a `safeTransferFrom` after the balance has been updated.
        To accept the transfer, this must return
        `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
        (i.e. 0xf23a6e61, or its own function selector).
        @param operator The address which initiated the transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param id The ID of the token being transferred
        @param value The amount of tokens being transferred
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
    */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
        @dev Handles the receipt of a multiple ERC1155 token types. This function
        is called at the end of a `safeBatchTransferFrom` after the balances have
        been updated. To accept the transfer(s), this must return
        `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
        (i.e. 0xbc197c81, or its own function selector).
        @param operator The address which initiated the batch transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param ids An array containing ids of each token being transferred (order and length must match values array)
        @param values An array containing amounts of each token being transferred (order and length must match ids array)
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
    */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
ERC1155Holder.sol 30 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}
ERC1155Receiver.sol 18 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}

Read Contract

BURNER_ROLE 0x282c51f3 → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MINTER_ROLE 0xd5391393 → bytes32
accountRewardVars 0x8117fbc7 → uint32, uint128, uint64
balanceOf 0x70a08231 → uint256
cardStakingValues 0xda5da65f → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getStaked 0x399080ec → uint256
getStakedTokens 0xf5bfbd13 → uint256[][]
hasRole 0x91d14854 → bool
lastTimeRewardApplicable 0x80faa57d → uint256
nftContractAddress 0xaae282e1 → address
rewardEndTime 0x37e9f64a → uint256
rewardRate 0x7b0a47ee → uint256
rewardToken 0xf7c618c1 → address
stakedNFTs 0xf7060048 → uint256
supportsInterface 0x01ffc9a7 → bool

Write Contract 13 functions

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

burn 0x9dc29fac
address _owner
uint256 _amount
grantRole 0x2f2ff15d
bytes32 role
address account
mint 0xe467f7e0
address[] _addresses
uint256[] _points
onERC1155BatchReceived 0xbc197c81
address
address
uint256[]
uint256[]
bytes
returns: bytes4
onERC1155Received 0xf23a6e61
address
address
uint256
uint256
bytes
returns: bytes4
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setCardStakingValues 0x7709b85d
uint256[] _cardIds
uint256[] _values
setReward 0x293be456
uint256 _rewardRate
setRewardEndTime 0x018413e7
uint256 _rewardEndTime
stake 0xe683ad44
uint256[] _tokenId
uint256[] _amount
unstake 0xb1adb083
uint256[] _tokenId
uint256[] _amount
withdrawReward 0x523a3f08
uint256 _amount

Recent Transactions

This address has 1 on-chain transactions, but only 1.3% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →