Address Contract Verified
Address
0x8005e7626a079e07F16CC59c01e1Be6Cb54d1d24
Balance
0 ETH
Nonce
1
Code Size
4220 bytes
Creator
0x7f478864...2236 at tx 0x4c6cfacf...97f296
Indexed Transactions
0
Contract Bytecode
4220 bytes
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b146101d6578063c9a3911e146101f1578063cb81480814610204578063f2fde38b14610232578063f559ec1014610245578063fd9d142a1461025857600080fd5b8063150b7a02146100b95780635d375a79146100f65780635dbe47561461012957806363c28db11461013e578063715018a61461015f5780637bbfc69e14610167575b600080fd5b6100d86100c7366004610c7f565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b610119610104366004610d1e565b60026020526000908152604090205460ff1681565b60405190151581526020016100ed565b61013c610137366004610d42565b610278565b005b61015161014c366004610d1e565b6105f6565b6040516100ed929190610dca565b61013c6107a4565b6101ae610175366004610e91565b60046020908152600092835260408084209091529082529020546001600160a01b03811690600160a01b900467ffffffffffffffff1682565b604080516001600160a01b03909316835267ffffffffffffffff9091166020830152016100ed565b6000546040516001600160a01b0390911681526020016100ed565b61013c6101ff366004610d42565b6107b8565b610224610212366004610d1e565b60036020526000908152604090205481565b6040519081526020016100ed565b61013c610240366004610d1e565b610ad3565b61013c610253366004610ebd565b610b16565b61026b610266366004610efb565b610b49565b6040516100ed9190610f29565b610280610bc3565b3360008181526005602090815260408083206001600160a01b0388168452909152812085915b848110156104425760008686838181106102c2576102c2610f6d565b855460209091029290920135925060009050805b8281101561037f57838682815481106102f1576102f1610f6d565b906000526020600020015403610377578561030d600185610f99565b8154811061031d5761031d610f6d565b906000526020600020015486828154811061033a5761033a610f6d565b90600052602060002001819055508580548061035857610358610fac565b600190038181906000526020600020016000905590556001915061037f565b6001016102d6565b508061039e57604051630a49bbc360e21b815260040160405180910390fd5b6001600160a01b038a811660009081526004602081815260408084208885529091529182902080546001600160e01b03191690559051632142170760e11b81523091810191909152888216602482015260448101859052908716906342842e0e90606401600060405180830381600087803b15801561041c57600080fd5b505af1158015610430573d6000803e3d6000fd5b505050508360010193505050506102a6565b508054600003610567576001600160a01b0383166000908152600560205260408120600101805490915b8181101561056357886001600160a01b031683828154811061049057610490610f6d565b6000918252602090912001546001600160a01b03160361055b57826104b6600184610f99565b815481106104c6576104c6610f6d565b9060005260206000200160009054906101000a90046001600160a01b03168382815481106104f6576104f6610f6d565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508280548061053457610534610fac565b600082815260209020810160001990810180546001600160a01b0319169055019055610563565b60010161046c565b5050505b6001600160a01b0386166000908152600360205260408120805486929061058f908490610f99565b92505081905550826001600160a01b0316866001600160a01b03167ff199e772ccf97f2d912ffc7f331d5df5af212192cefd4515c8590def0428858a8787426040516105dd93929190610fc2565b60405180910390a35050506105f160018055565b505050565b6001600160a01b0381166000908152600560205260409020600181015460609182918067ffffffffffffffff81111561063157610631611000565b60405190808252806020026020018201604052801561065a578160200160208202803683370190505b5093508067ffffffffffffffff81111561067657610676611000565b6040519080825280602002602001820160405280156106a957816020015b60608152602001906001900390816106945790505b50925060005b8181101561079c5760008360010182815481106106ce576106ce610f6d565b9060005260206000200160009054906101000a90046001600160a01b031690508086838151811061070157610701610f6d565b6001600160a01b0392831660209182029290920181019190915290821660009081528582526040908190208054825181850281018501909352808352919290919083018282801561077157602002820191906000526020600020905b81548152602001906001019080831161075d575b505050505085838151811061078857610788610f6d565b6020908102919091010152506001016106af565b505050915091565b6107ac610bed565b6107b66000610c1a565b565b6107c0610bc3565b6001600160a01b03831660009081526002602052604090205460ff166107f9576040516397872d7560e01b815260040160405180910390fd5b3360009081526005602090815260408083206001600160a01b038716845290915281208054909190151590839086905b82811015610a0e57600087878381811061084557610845610f6d565b6001600160a01b038c811660009081526004602090815260408083209482029690960135808352939052939093205490935090911615905061089a576040516316e9ad8f60e01b815260040160405180910390fd5b6040516331a9108f60e11b81526004810182905233906001600160a01b03851690636352211e90602401602060405180830381865afa1580156108e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109059190611016565b6001600160a01b03161461092c576040516359dc379f60e01b815260040160405180910390fd5b6040805180820182523380825267ffffffffffffffff42811660208085019182526001600160a01b038f8116600090815260048084528882208a83528452888220975188549551909616600160a01b026001600160e01b031990951695831695909517939093179095558b54600181018d558c83529120018590559251632142170760e11b815292830152306024830152604482018390528416906342842e0e90606401600060405180830381600087803b1580156109ea57600080fd5b505af11580156109fe573d6000803e3d6000fd5b5050505081600101915050610829565b5082610a50573360009081526005602090815260408220600190810180549182018155835291200180546001600160a01b0319166001600160a01b0389161790555b6001600160a01b03871660009081526003602052604081208054849290610a78908490611033565b909155505060405133906001600160a01b038916907f2b8a7b8ab56b2c1730de65e466e60e3b49e01df9ac36c2377d71d562d9e0e0d690610abe908a908a904290610fc2565b60405180910390a3505050506105f160018055565b610adb610bed565b6001600160a01b038116610b0a57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610b1381610c1a565b50565b610b1e610bed565b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b6001600160a01b038083166000908152600560209081526040808320938516835292815290829020805483518184028101840190945280845260609392830182828015610bb557602002820191906000526020600020905b815481526020019060010190808311610ba1575b505050505090505b92915050565b600260015403610be657604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6000546001600160a01b031633146107b65760405163118cdaa760e01b8152336004820152602401610b01565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381168114610b1357600080fd5b600080600080600060808688031215610c9757600080fd5b8535610ca281610c6a565b94506020860135610cb281610c6a565b935060408601359250606086013567ffffffffffffffff80821115610cd657600080fd5b818801915088601f830112610cea57600080fd5b813581811115610cf957600080fd5b896020828501011115610d0b57600080fd5b9699959850939650602001949392505050565b600060208284031215610d3057600080fd5b8135610d3b81610c6a565b9392505050565b600080600060408486031215610d5757600080fd5b8335610d6281610c6a565b9250602084013567ffffffffffffffff80821115610d7f57600080fd5b818601915086601f830112610d9357600080fd5b813581811115610da257600080fd5b8760208260051b8501011115610db757600080fd5b6020830194508093505050509250925092565b604080825283519082018190526000906020906060840190828701845b82811015610e0c5781516001600160a01b031684529284019290840190600101610de7565b50505083810382850152845180825282820190600581901b8301840187850160005b83811015610e8257858303601f1901855281518051808552908801908885019060005b81811015610e6d5783518352928a0192918a0191600101610e51565b50509588019593505090860190600101610e2e565b50909998505050505050505050565b60008060408385031215610ea457600080fd5b8235610eaf81610c6a565b946020939093013593505050565b60008060408385031215610ed057600080fd5b8235610edb81610c6a565b915060208301358015158114610ef057600080fd5b809150509250929050565b60008060408385031215610f0e57600080fd5b8235610f1981610c6a565b91506020830135610ef081610c6a565b6020808252825182820181905260009190848201906040850190845b81811015610f6157835183529284019291840191600101610f45565b50909695505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610bbd57610bbd610f83565b634e487b7160e01b600052603160045260246000fd5b6040808252810183905260006001600160fb1b03841115610fe257600080fd5b8360051b808660608501376020830193909352500160600192915050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561102857600080fd5b8151610d3b81610c6a565b80820180821115610bbd57610bbd610f8356fea2646970667358221220b5ea56ec6565c7017b9c14b3632bcc534872ebca2b0c2d91868b339fceacab4a64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: paris
Optimization: Yes (200 runs)
PlanetXStakingV1.sol 247 lines
/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ @@@, @@@@@( @@@ @/ &# @ .@@@@@@ *@@@@@@@@@@* %@@@
@@ V. @@@@@ @@@ / @ @ %@@@ @@, @@
@@ @> @. @@@@@ @@ @ @@@@@@, @@@@@@@ @@@ /@* *@@
@@ ^. @@@@ (@ @ /@@@, @& #& %@@@@@@@@@@
@@ (@, @@@@ % (@ @ /@@@, @ @& .@@@@@@@@@@@
@@ ,@@@@@, @@@# @ @ @@@@@@, @@@@@@@* @ @@@ @@@
@@ ,@@@@@, # #% @ @ @ @@@, @@@@@@ /@@& @@
@@ ,@@@@@, # #@, @ @/ @ @@@, @@@@@@@ @@@@@@@( *@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Planet-X Staking V1
playplanetx.com
PLAY PLANET X LIMITED © 2024 | All rights reserved
*/
// SPDX-License-Identifier: UNLICENCED
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/interfaces/IERC721Receiver.sol";
import "@openzeppelin/contracts/interfaces/IERC721.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
struct StakedToken {
address owner; // 20 bytes
uint64 stakedAt; // 8 bytes
}
struct UserStakedTokens {
mapping(address contractAddress => uint256[] tokenIds) tokens;
address[] contracts;
}
error TokenAlreadyStaked();
error TokenNotStaked();
error NotTokenOwner();
error UnsupportedStakingContract();
interface StakingEvents {
event TokensStaked(
address indexed contractAddress,
address indexed owner,
uint256[] tokenIds,
uint256 timestamp
);
event TokensUnstaked(
address indexed contractAddress,
address indexed owner,
uint256[] tokenIds,
uint256 timestamp
);
}
contract PlanetXStakingV1 is IERC721Receiver, Ownable, ReentrancyGuard, StakingEvents {
mapping(address contractAddress => bool) public isContractSupported;
mapping(address contractAddress => uint256 totalStaked) public stakeCountsPerContract;
mapping(address contractAddress => mapping(uint256 tokenId => StakedToken))
public vaults;
mapping(address user => UserStakedTokens) userStakedTokens;
constructor() Ownable(msg.sender) {}
/// @notice allows a user to stake their tokens
/// @param contractAddress address of the NFT contract
/// @param tokenIds array of token ids to stake
function stake(
address contractAddress,
uint256[] calldata tokenIds
) external nonReentrant {
// check that we accept stakes for this contract
if (!isContractSupported[contractAddress]) {
revert UnsupportedStakingContract();
}
uint256[] storage userTokens = userStakedTokens[msg.sender].tokens[
contractAddress
];
bool userHadPreviousStakedInContract = userTokens.length > 0;
uint256 stakedCount = tokenIds.length;
IERC721 nftContract = IERC721(contractAddress);
for (uint256 i; i < stakedCount; ) {
uint256 tokenId = tokenIds[i];
// check that the token is not already staked
if (vaults[contractAddress][tokenId].owner != address(0)) {
revert TokenAlreadyStaked();
}
// check that the sender is the owner of the token
if (nftContract.ownerOf(tokenId) != msg.sender) {
revert NotTokenOwner();
}
// save the staking information
vaults[contractAddress][tokenId] = StakedToken({
owner: msg.sender,
stakedAt: uint64(block.timestamp)
});
// add the token to the user's staked tokens
userTokens.push(tokenId);
// transfer the nft to this contract
nftContract.safeTransferFrom(msg.sender, address(this), tokenId);
unchecked {
++i;
}
}
// if contract is not in the user's contracts, add it
if (!userHadPreviousStakedInContract) {
userStakedTokens[msg.sender].contracts.push(contractAddress);
}
// update the total staked count
stakeCountsPerContract[contractAddress] += stakedCount;
// emit final event after for loop to save gas
emit TokensStaked(contractAddress, msg.sender, tokenIds, block.timestamp);
}
/// @notice allows a user to unstake their tokens
/// @param contractAddress address of the NFT contract
/// @param tokenIds array of token ids to unstake
function unstake(
address contractAddress,
uint256[] calldata tokenIds
) external nonReentrant {
address user = msg.sender;
IERC721 nftContract = IERC721(contractAddress);
uint256[] storage userTokens = userStakedTokens[user].tokens[contractAddress];
for (uint256 i; i < tokenIds.length; ) {
uint256 tokenId = tokenIds[i];
// remove the token from the user's staked tokens
uint256 len = userTokens.length;
bool tokenFound = false;
for (uint256 j; j < len; ) {
if (userTokens[j] == tokenId) {
userTokens[j] = userTokens[len - 1];
userTokens.pop();
tokenFound = true;
break;
}
unchecked {
++j;
}
}
if (!tokenFound) {
revert TokenNotStaked();
}
delete vaults[contractAddress][tokenId];
// transfer the token back to the user
nftContract.safeTransferFrom(address(this), user, tokenId);
unchecked {
++i;
}
}
// remove the contract from the user's staked contracts if they have no more tokens staked in it
if (userTokens.length == 0) {
address[] storage userStakedContracts = userStakedTokens[user].contracts;
uint256 len = userStakedContracts.length;
for (uint256 i; i < len; ) {
if (userStakedContracts[i] == contractAddress) {
userStakedContracts[i] = userStakedContracts[len - 1];
userStakedContracts.pop();
break;
}
unchecked {
++i;
}
}
}
stakeCountsPerContract[contractAddress] -= tokenIds.length;
// emit final event after for loop to save gas
emit TokensUnstaked(contractAddress, user, tokenIds, block.timestamp);
}
function setSupportedContract(
address contractAddress,
bool isSupported
) external onlyOwner {
isContractSupported[contractAddress] = isSupported;
}
// ********* //
// GETTERS //
// ********* //
/// @notice get all staked tokens for a user in a contract
/// @param user address of user to get staked tokens for
function getStakedTokens(
address user,
address contractAddress
) external view returns (uint256[] memory tokenIds) {
return userStakedTokens[user].tokens[contractAddress];
}
/// @notice get all staked tokens for a user
/// @param user address of user to get staked tokens for
function getStakedTokens(
address user
) external view returns (address[] memory contracts, uint256[][] memory tokenIds) {
UserStakedTokens storage userStake = userStakedTokens[user];
uint256 contractLen = userStake.contracts.length;
contracts = new address[](contractLen);
tokenIds = new uint256[][](contractLen);
for (uint256 i; i < contractLen; ) {
address contractAddress = userStake.contracts[i];
contracts[i] = contractAddress;
tokenIds[i] = userStake.tokens[contractAddress];
unchecked {
++i;
}
}
return (contracts, tokenIds);
}
function onERC721Received(
address /**operator*/,
address /**from*/,
uint256 /**amount*/,
bytes calldata //data
) external pure override returns (bytes4) {
return IERC721Receiver.onERC721Received.selector;
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC721.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../token/ERC721/IERC721.sol";
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-721 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 ERC-721 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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* 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 address zero.
*
* 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);
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
IERC721Receiver.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721Receiver.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../token/ERC721/IERC721Receiver.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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);
}
IERC721Receiver.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC-721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC-721 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
getStakedTokens 0x63c28db1 → address[], uint256[][]
getStakedTokens 0xfd9d142a → uint256[]
isContractSupported 0x5d375a79 → bool
onERC721Received 0x150b7a02 → bytes4
owner 0x8da5cb5b → address
stakeCountsPerContract 0xcb814808 → uint256
vaults 0x7bbfc69e → address, uint64
Write Contract 5 functions
These functions modify contract state and require a wallet transaction to execute.
renounceOwnership 0x715018a6
No parameters
setSupportedContract 0xf559ec10
address contractAddress
bool isSupported
stake 0xc9a3911e
address contractAddress
uint256[] tokenIds
transferOwnership 0xf2fde38b
address newOwner
unstake 0x5dbe4756
address contractAddress
uint256[] tokenIds
Recent Transactions
No transactions found for this address