Address Contract Verified
Address
0x8229C8afb1dA6eC4d95faf2E3Bd7D5e749C9E7C8
Balance
0 ETH
Nonce
1
Code Size
8760 bytes
Creator
0x3C7A3c7C...E688 at tx 0xaef24769...411ea3
Indexed Transactions
0
Contract Bytecode
8760 bytes
0x608060405234801561001057600080fd5b50600436106101515760003560e01c8063715018a6116100cd578063c59abf9f11610081578063dfa4ce4f11610066578063dfa4ce4f146103ca578063f063642a146103ed578063f2fde38b1461040f57600080fd5b8063c59abf9f146103af578063cf86add5146103b757600080fd5b80638da5cb5b116100b25780638da5cb5b1461034a57806394bcce4b14610389578063bcca1e041461039c57600080fd5b8063715018a61461031f5780637d2d2ea71461032757600080fd5b80634440f780116101245780635028d05a116101095780635028d05a146102bc57806355c99323146102d15780636a76cf26146102e457600080fd5b80634440f780146102475780634f6e98d41461027857600080fd5b80630aa5a00514610156578063150b7a021461019a57806322e2191d146101de5780633388e3a114610234575b600080fd5b610187610164366004611cde565b600460209081526000938452604080852082529284528284209052825290205481565b6040519081526020015b60405180910390f35b6101ad6101a8366004611d20565b610422565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610191565b6101f16101ec366004611dbf565b610516565b6040805163ffffffff95861681529385166020850152919093169082015273ffffffffffffffffffffffffffffffffffffffff9091166060820152608001610191565b6101f1610242366004611dd8565b610580565b610187610255366004611cde565b600360209081526000938452604080852082529284528284209052825290205481565b6102ac610286366004611cde565b600560209081526000938452604080852082529284528284209052825290205460ff1681565b6040519015158152602001610191565b6102cf6102ca366004611e04565b6105f5565b005b6102cf6102df366004611e04565b6106c2565b61030a6102f2366004611e04565b60026020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610191565b6102cf610854565b61033a610335366004611e28565b6108e1565b6040516101919493929190611ecb565b60005473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b610364610397366004611dbf565b610beb565b6102cf6103aa366004611f6f565b610c22565b61033a61138d565b6102cf6103c5366004611f6f565b6113b1565b6102ac6103d8366004611e04565b60016020526000908152604090205460ff1681565b6104006103fb366004611e04565b61185f565b60405161019193929190611fdb565b6102cf61041d366004611e04565b611b17565b6040517fcf86add500000000000000000000000000000000000000000000000000000000602082015260009060240160405160208183030381529060405280519060200120838360405161047792919061201e565b6040518091039020146104eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f21696e76616c696400000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b507f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6007818154811061052657600080fd5b60009182526020909120015463ffffffff80821692506401000000008204811691680100000000000000008104909116906c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1684565b6006602052816000526040600020818154811061059c57600080fd5b60009182526020909120015463ffffffff808216935064010000000082048116925068010000000000000000820416906c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1684565b60005473ffffffffffffffffffffffffffffffffffffffff163314610676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e2565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60005473ffffffffffffffffffffffffffffffffffffffff163314610743576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e2565b600880546001808201835560008390527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee390910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8516179055905482916107c29161205d565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260026020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff9095169490941790935560019081905291902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909117905550565b60005473ffffffffffffffffffffffffffffffffffffffff1633146108d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e2565b6108df6000611c47565b565b60608060608060008567ffffffffffffffff81111561090257610902612082565b60405190808252806020026020018201604052801561092b578160200160208202803683370190505b50905060008667ffffffffffffffff81111561094957610949612082565b604051908082528060200260200182016040528015610972578160200160208202803683370190505b50905060008767ffffffffffffffff81111561099057610990612082565b6040519080825280602002602001820160405280156109b9578160200160208202803683370190505b50905060008867ffffffffffffffff8111156109d7576109d7612082565b604051908082528060200260200182016040528015610a00578160200160208202803683370190505b509050895b89811015610bda57600060078281548110610a2257610a226120b1565b600091825260209182902060408051608081018252929091015463ffffffff808216808552640100000000830482169585019590955268010000000000000000820416918301919091526c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1660608201526008805491935091908110610aae57610aae6120b1565b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16868381518110610aeb57610aeb6120b1565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050806020015163ffffffff16858381518110610b4257610b426120b1565b6020026020010181815250508060600151848381518110610b6557610b656120b1565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050806040015163ffffffff16838381518110610bbc57610bbc6120b1565b60209081029190910101525080610bd2816120e0565b915050610a05565b509299919850965090945092505050565b60088181548110610bfb57600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b828114610c8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600760248201527f21706172616d730000000000000000000000000000000000000000000000000060448201526064016104e2565b60005b83811015611386576000858583818110610caa57610caa6120b1565b9050602002016020810190610cbf9190611e04565b90506000848484818110610cd557610cd56120b1565b73ffffffffffffffffffffffffffffffffffffffff851660009081526005602090815260408083209382029590950135808352928152848220338352905292909220549192505060ff16610d85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600760248201527f217374616b65640000000000000000000000000000000000000000000000000060448201526064016104e2565b3360009081526006602052604090205460011015610faa5773ffffffffffffffffffffffffffffffffffffffff821660009081526004602090815260408083208484528252808320338452825280832054600690925282208054919291610dee90600190612118565b81548110610dfe57610dfe6120b1565b6000918252602080832060408051608081018252919093015463ffffffff80821683526401000000008204811683850152680100000000000000008204168285015273ffffffffffffffffffffffffffffffffffffffff6c01000000000000000000000000909104166060820152338452600690915291208054919250829184908110610e8d57610e8d6120b1565b6000918252602080832084519201805491850151604086015160609096015173ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000026bffffffffffffffffffffffff63ffffffff97881668010000000000000000021667ffffffffffffffff928816640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009095169588169590951793909317169290921717905582516008805486946004949316908110610f5857610f586120b1565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282810193909352604091820181209483015163ffffffff16815293825280842033855290915290912055505b336000908152600660205260409020805480610fc857610fc861212f565b60008281526020812082017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810191909155019055600754600110156112195773ffffffffffffffffffffffffffffffffffffffff8216600090815260036020908152604080832084845282528083203384529091528120546007805491929161105590600190612118565b81548110611065576110656120b1565b600091825260209182902060408051608081018252929091015463ffffffff80821684526401000000008204811694840194909452680100000000000000008104909316908201526c0100000000000000000000000090910473ffffffffffffffffffffffffffffffffffffffff166060820152600780549192508291849081106110f2576110f26120b1565b6000918252602080832084519201805491850151604086015160609096015173ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000026bffffffffffffffffffffffff63ffffffff97881668010000000000000000021667ffffffffffffffff928816640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000090951695881695909517939093171692909217179055825160088054869460039493169081106111bd576111bd6120b1565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff908116845283820194909452604092830182208682015163ffffffff168352815282822060609096015190931681529390915290912055505b600780548061122a5761122a61212f565b600082815260208082207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff908401810183905590920190925573ffffffffffffffffffffffffffffffffffffffff84168083526003825260408084208585528352808420338086529084528185208590558285526004808552828620878752855282862082875285528286208690558386526005855282862087875285528286208287529094529381902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055517f42842e0e00000000000000000000000000000000000000000000000000000000815230928101929092526024820192909252604481018390526342842e0e90606401600060405180830381600087803b15801561135957600080fd5b505af115801561136d573d6000803e3d6000fd5b505050505050808061137e906120e0565b915050610c8e565b5050505050565b6060806060806113a360006007805490506108e1565b935093509350935090919293565b82811461141a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600760248201527f21706172616d730000000000000000000000000000000000000000000000000060448201526064016104e2565b60005b83811015611386576000858583818110611439576114396120b1565b905060200201602081019061144e9190611e04565b90506000848484818110611464576114646120b1565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600160209081526040909120549102929092013592505060ff16611500576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f21636f6c6c656374696f6e00000000000000000000000000000000000000000060448201526064016104e2565b73ffffffffffffffffffffffffffffffffffffffff808316600081815260056020908152604080832086845282528083203380855290835281842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091558251608081018452958552600284528285205463ffffffff9081168752808916948701948552428116938701938452606087019283526007805480840182559681905287517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890970180549651955194519099166c01000000000000000000000000026bffffffffffffffffffffffff94831668010000000000000000029490941667ffffffffffffffff958316640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000090971697909216969096179490941792909216929092179190911790935554909161166791612118565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526003602090815260408083208784528252808320338085529083528184209590955560068252808320805460018181018355828652848620895192018054958a0151948a015160608b01519098166c01000000000000000000000000026bffffffffffffffffffffffff63ffffffff998a1668010000000000000000021667ffffffffffffffff968a16640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009098169990941698909817959095179390931617949094179091559290525461175f9190612118565b73ffffffffffffffffffffffffffffffffffffffff84166000818152600460208181526040808420888552825280842033808652908352938190209590955584517fcf86add500000000000000000000000000000000000000000000000000000000918101919091528451808203909201825260248101948590527fb88d4fde00000000000000000000000000000000000000000000000000000000909452919263b88d4fde9261181792913091889160280161215e565b600060405180830381600087803b15801561183157600080fd5b505af1158015611845573d6000803e3d6000fd5b505050505050508080611857906120e0565b91505061141d565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260066020526040812054606091829182918167ffffffffffffffff8111156118a5576118a5612082565b6040519080825280602002602001820160405280156118ce578160200160208202803683370190505b50905060008267ffffffffffffffff8111156118ec576118ec612082565b604051908082528060200260200182016040528015611915578160200160208202803683370190505b50905060008367ffffffffffffffff81111561193357611933612082565b60405190808252806020026020018201604052801561195c578160200160208202803683370190505b50905060005b84811015611b085773ffffffffffffffffffffffffffffffffffffffff891660009081526006602052604081208054839081106119a1576119a16120b1565b600091825260209182902060408051608081018252929091015463ffffffff808216808552640100000000830482169585019590955268010000000000000000820416918301919091526c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1660608201526008805491935091908110611a2d57611a2d6120b1565b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16858381518110611a6a57611a6a6120b1565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050806020015163ffffffff16848381518110611ac157611ac16120b1565b602002602001018181525050806040015163ffffffff16838381518110611aea57611aea6120b1565b60209081029190910101525080611b00816120e0565b915050611962565b50919790965090945092505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611b98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e2565b73ffffffffffffffffffffffffffffffffffffffff8116611c3b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104e2565b611c4481611c47565b50565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff81168114611c4457600080fd5b600080600060608486031215611cf357600080fd5b8335611cfe81611cbc565b9250602084013591506040840135611d1581611cbc565b809150509250925092565b600080600080600060808688031215611d3857600080fd5b8535611d4381611cbc565b94506020860135611d5381611cbc565b935060408601359250606086013567ffffffffffffffff80821115611d7757600080fd5b818801915088601f830112611d8b57600080fd5b813581811115611d9a57600080fd5b896020828501011115611dac57600080fd5b9699959850939650602001949392505050565b600060208284031215611dd157600080fd5b5035919050565b60008060408385031215611deb57600080fd5b8235611df681611cbc565b946020939093013593505050565b600060208284031215611e1657600080fd5b8135611e2181611cbc565b9392505050565b60008060408385031215611e3b57600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015611e9057815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101611e5e565b509495945050505050565b600081518084526020808501945080840160005b83811015611e9057815187529582019590820190600101611eaf565b608081526000611ede6080830187611e4a565b8281036020840152611ef08187611e9b565b90508281036040840152611f048186611e4a565b90508281036060840152611f188185611e9b565b979650505050505050565b60008083601f840112611f3557600080fd5b50813567ffffffffffffffff811115611f4d57600080fd5b6020830191508360208260051b8501011115611f6857600080fd5b9250929050565b60008060008060408587031215611f8557600080fd5b843567ffffffffffffffff80821115611f9d57600080fd5b611fa988838901611f23565b90965094506020870135915080821115611fc257600080fd5b50611fcf87828801611f23565b95989497509550505050565b606081526000611fee6060830186611e4a565b82810360208401526120008186611e9b565b905082810360408401526120148185611e9b565b9695505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600063ffffffff8381169083168181101561207a5761207a61202e565b039392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036121115761211161202e565b5060010190565b60008282101561212a5761212a61202e565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600073ffffffffffffffffffffffffffffffffffffffff8087168352602081871681850152856040850152608060608501528451915081608085015260005b828110156121b95785810182015185820160a00152810161219d565b828111156121cb57600060a084870101525b5050601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160a0019594505050505056fea2646970667358221220b8a272493123b8ef8ba1dedd7f3ab4bacd8f4b0952c93c1e1197513a025911d064736f6c634300080e0033
Verified Source Code Full Match
Compiler: v0.8.14+commit.80d49f37
EVM: london
Optimization: Yes (10000 runs)
WhiteSandsStaking.sol 185 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.14;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
contract WhiteSandsStaking is IERC721Receiver, Ownable {
struct TokenInfo {
uint32 collectionId;
uint32 id;
uint32 timestamp;
address owner;
}
mapping(IERC721 => bool) public _acceptedCollections;
mapping(IERC721 => uint32) public _collectionToId;
mapping(IERC721 => mapping(uint256 => mapping(address => uint256)))
public _indexOfTokens;
mapping(IERC721 => mapping(uint256 => mapping(address => uint256)))
public _indexOfTokensByOwners;
mapping(IERC721 => mapping(uint256 => mapping(address => bool)))
public _isStaked;
mapping(address => TokenInfo[]) public _stakedByOwners;
TokenInfo[] public _staked;
IERC721[] public _collections;
constructor(address[] memory collections) {
for (uint256 i = 0; i < collections.length; i++) {
acceptCollection(collections[i]);
}
}
function acceptCollection(address collection_) public onlyOwner {
IERC721 collection = IERC721(collection_);
_collections.push(collection);
_collectionToId[collection] = uint32(_collections.length) - 1;
_acceptedCollections[collection] = true;
}
function removeCollection(address collection) external onlyOwner {
delete _acceptedCollections[IERC721(collection)];
}
function stake(address[] calldata collections, uint256[] calldata ids)
external
{
require(collections.length == ids.length, "!params");
for (uint256 i = 0; i < collections.length; i++) {
IERC721 collection = IERC721(collections[i]);
uint256 id = ids[i];
require(_acceptedCollections[collection], "!collection");
_isStaked[collection][id][msg.sender] = true;
TokenInfo memory ti = TokenInfo(
_collectionToId[collection],
uint32(id),
// solhint-disable-next-line not-rely-on-time
uint32(block.timestamp),
msg.sender
);
_staked.push(ti);
_indexOfTokens[collection][id][msg.sender] = _staked.length - 1;
_stakedByOwners[msg.sender].push(ti);
_indexOfTokensByOwners[collection][id][msg.sender] =
_stakedByOwners[msg.sender].length -
1;
collection.safeTransferFrom(
msg.sender,
address(this),
id,
abi.encodePacked(WhiteSandsStaking.stake.selector)
);
}
}
function unstake(address[] calldata collections, uint256[] calldata ids)
external
{
require(collections.length == ids.length, "!params");
for (uint256 i = 0; i < collections.length; i++) {
IERC721 collection = IERC721(collections[i]);
uint256 id = ids[i];
require(_isStaked[collection][id][msg.sender], "!staked");
if (_stakedByOwners[msg.sender].length > 1) {
uint256 index = _indexOfTokensByOwners[collection][id][
msg.sender
];
TokenInfo memory last = _stakedByOwners[msg.sender][
_stakedByOwners[msg.sender].length - 1
];
_stakedByOwners[msg.sender][index] = last;
_indexOfTokensByOwners[_collections[last.collectionId]][
last.id
][msg.sender] = index;
}
_stakedByOwners[msg.sender].pop();
if (_staked.length > 1) {
uint256 index = _indexOfTokens[collection][id][msg.sender];
TokenInfo memory last = _staked[_staked.length - 1];
_staked[index] = last;
_indexOfTokens[_collections[last.collectionId]][last.id][
last.owner
] = index;
}
_staked.pop();
delete _indexOfTokens[collection][id][msg.sender];
delete _indexOfTokensByOwners[collection][id][msg.sender];
delete _isStaked[collection][id][msg.sender];
collection.safeTransferFrom(address(this), msg.sender, id);
}
}
function getStakedByOwner(address owner)
external
view
returns (
address[] memory,
uint256[] memory,
uint256[] memory
)
{
uint256 count = _stakedByOwners[owner].length;
address[] memory collections = new address[](count);
uint256[] memory ids = new uint256[](count);
uint256[] memory timestamps = new uint256[](count);
for (uint256 i = 0; i < count; i++) {
TokenInfo memory ti = _stakedByOwners[owner][i];
collections[i] = address(_collections[ti.collectionId]);
ids[i] = ti.id;
timestamps[i] = ti.timestamp;
}
return (collections, ids, timestamps);
}
function getStaked()
external
view
returns (
address[] memory,
uint256[] memory,
address[] memory,
uint256[] memory
)
{
return getStakedFrom(0, _staked.length);
}
function getStakedFrom(uint256 from, uint256 count)
public
view
returns (
address[] memory,
uint256[] memory,
address[] memory,
uint256[] memory
)
{
address[] memory collections = new address[](count);
uint256[] memory ids = new uint256[](count);
address[] memory owners = new address[](count);
uint256[] memory timestamps = new uint256[](count);
for (uint256 i = from; i < count; i++) {
TokenInfo memory ti = _staked[i];
collections[i] = address(_collections[ti.collectionId]);
ids[i] = ti.id;
owners[i] = ti.owner;
timestamps[i] = ti.timestamp;
}
return (collections, ids, owners, timestamps);
}
function onERC721Received(
address,
address,
uint256,
bytes calldata data
) external pure override returns (bytes4) {
require(
keccak256(data) ==
keccak256(abi.encodePacked(WhiteSandsStaking.stake.selector)),
"!invalid"
);
return IERC721Receiver.onERC721Received.selector;
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
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);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
Read Contract
_acceptedCollections 0xdfa4ce4f → bool
_collectionToId 0x6a76cf26 → uint32
_collections 0x94bcce4b → address
_indexOfTokens 0x4440f780 → uint256
_indexOfTokensByOwners 0x0aa5a005 → uint256
_isStaked 0x4f6e98d4 → bool
_staked 0x22e2191d → uint32, uint32, uint32, address
_stakedByOwners 0x3388e3a1 → uint32, uint32, uint32, address
getStaked 0xc59abf9f → address[], uint256[], address[], uint256[]
getStakedByOwner 0xf063642a → address[], uint256[], uint256[]
getStakedFrom 0x7d2d2ea7 → address[], uint256[], address[], uint256[]
onERC721Received 0x150b7a02 → bytes4
owner 0x8da5cb5b → address
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
acceptCollection 0x55c99323
address collection_
removeCollection 0x5028d05a
address collection
renounceOwnership 0x715018a6
No parameters
stake 0xcf86add5
address[] collections
uint256[] ids
transferOwnership 0xf2fde38b
address newOwner
unstake 0xbcca1e04
address[] collections
uint256[] ids
Recent Transactions
No transactions found for this address