Address Contract Verified
Address
0x50D8aae81035A2253CE36433Fa5C6F1d2314c90B
Balance
0 ETH
Nonce
1
Code Size
6453 bytes
Creator
0x58F58f15...77d7 at tx 0xbf0b07ee...1bca5f
Indexed Transactions
0
Contract Bytecode
6453 bytes
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063715018a6116100a2578063d468b38111610071578063d468b381146102cb578063d94757e4146102de578063e9e1921a146102f1578063f23a6e6114610304578063f2fde38b1461032357600080fd5b8063715018a6146102805780638da5cb5b146102885780639524fb5714610299578063bc197c81146102ac57600080fd5b8063229a1132116100e9578063229a1132146101af5780632f57ee41146102275780633d9728391461023a5780634b88bb4c1461024d5780635228cd3f1461026d57600080fd5b806301ffc9a71461011b578063132e8bee14610143578063150b7a0214610158578063222fe91214610184575b600080fd5b61012e610129366004611181565b610336565b60405190151581526020015b60405180910390f35b61015661015136600461125d565b61036d565b005b61016b610166366004611388565b6103b9565b6040516001600160e01b0319909116815260200161013a565b600254610197906001600160a01b031681565b6040516001600160a01b03909116815260200161013a565b6102186101bd3660046113f4565b600460208181526000928352604092839020805484518086018652600183015460ff9081168252600284015482860152865180880190975260038401541686529190930154918401919091526001600160a01b039091169183565b60405161013a9392919061140f565b6101566102353660046113f4565b6103ca565b6101566102483660046113f4565b610739565b61026061025b366004611452565b610992565b60405161013a919061146f565b61015661027b366004611452565b610a26565b610156610a72565b6000546001600160a01b0316610197565b600154610197906001600160a01b031681565b61016b6102ba36600461151d565b63bc197c8160e01b95945050505050565b6101566102d936600461125d565b610aa8565b6101566102ec366004611452565b610b83565b6101566102ff36600461125d565b610bcf565b61016b6103123660046115cb565b63f23a6e6160e01b95945050505050565b610156610331366004611452565b610c17565b60006001600160e01b03198216630271189760e51b148061036757506301ffc9a760e01b6001600160e01b03198316145b92915050565b60005b81518161ffff1610156103b5576103a3828261ffff168151811061039657610396611634565b6020026020010151610739565b806103ad81611660565b915050610370565b5050565b630a85bd0160e11b5b949350505050565b6001546040516331a9108f60e11b815261ffff8316600482015233916001600160a01b031690636352211e90602401602060405180830381865afa158015610416573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043a9190611681565b6001600160a01b0316146104855760405162461bcd60e51b815260206004820152600d60248201526c2932b8bab4b9329037bbb732b960991b60448201526064015b60405180910390fd5b6001546040516323b872dd60e01b81526001600160a01b03909116906323b872dd906104b99033903090869060040161169e565b600060405180830381600087803b1580156104d357600080fd5b505af11580156104e7573d6000803e3d6000fd5b50503360008181526003602090815260408083208054600180820183559185528385206010820401805461ffff8b81166002600f909516949094026101000a84810291021990911617905580855260049384905282852080546001600160a01b031916909617909555549051631c58e79360e01b8152918201939093529093506001600160a01b039091169150631c58e79390602401600060405180830381865afa15801561059a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105c291908101906117c8565b8051909150429060ff166003036106475761ffff8316600081815260046020818152604092839020918201859055600390910154825133815260ff90911691810191909152908101839052600160608201527fe2080b8c2a3df0acd1873f0dfb9fa4cedd8ba11223c2a6e3ba30e5ef6f2b961d906080015b60405180910390a2505050565b61ffff8316600090815260046020526040812060010154835160ff918216929116821015610676578351610678565b815b905060038160ff16106106bc5760405162461bcd60e51b815260206004820152600c60248201526b45786365656420737461746560a01b604482015260640161047c565b61ffff8516600081815260046020908152604080832060018101805460ff191660ff88169081179091556002909101889055815133815292830152810186905260608101919091527fe2080b8c2a3df0acd1873f0dfb9fa4cedd8ba11223c2a6e3ba30e5ef6f2b961d9060800160405180910390a250505b505050565b61ffff81166000908152600460205260409020546001600160a01b031633146107945760405162461bcd60e51b815260206004820152600d60248201526c2932b8bab4b9329037bbb732b960991b604482015260640161047c565b6001546040516323b872dd60e01b81526001600160a01b03909116906323b872dd906107c89030903390869060040161169e565b600060405180830381600087803b1580156107e257600080fd5b505af11580156107f6573d6000803e3d6000fd5b5050505061ffff8116600081815260046020819052604080832080546001600160a01b03191690556001549051631c58e79360e01b81529182019390935290916001600160a01b031690631c58e79390602401600060405180830381865afa158015610866573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261088e91908101906117c8565b8051909150429060ff16600303610917576108a883610cb2565b61ffff83166000818152600460208181526040928390206003810154920154835133815260ff909316918301919091529181019190915260608101839052600160808201527f4ee0576f9ef4cf84c89bdc9eb6a60f957c78e1ab1565ca280b4bed4a15f616629060a00161063a565b61092083610dc8565b61ffff831660008181526004602090815260408083206001810154600290910154825133815260ff90921693820193909352908101919091526060810184905260808101919091527f4ee0576f9ef4cf84c89bdc9eb6a60f957c78e1ab1565ca280b4bed4a15f616629060a00161063a565b6001600160a01b038116600090815260036020908152604091829020805483518184028101840190945280845260609392830182828015610a1a57602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116109e15790505b50505050509050919050565b6000546001600160a01b03163314610a505760405162461bcd60e51b815260040161047c90611882565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610a9c5760405162461bcd60e51b815260040161047c90611882565b610aa66000610f48565b565b6000546001600160a01b03163314610ad25760405162461bcd60e51b815260040161047c90611882565b805160005b8161ffff168161ffff1610156107345760015483516001600160a01b03909116906323b872dd9030903390879061ffff8716908110610b1857610b18611634565b60200260200101516040518463ffffffff1660e01b8152600401610b3e9392919061169e565b600060405180830381600087803b158015610b5857600080fd5b505af1158015610b6c573d6000803e3d6000fd5b505050508080610b7b90611660565b915050610ad7565b6000546001600160a01b03163314610bad5760405162461bcd60e51b815260040161047c90611882565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60005b81518161ffff1610156103b557610c05828261ffff1681518110610bf857610bf8611634565b60200260200101516103ca565b80610c0f81611660565b915050610bd2565b6000546001600160a01b03163314610c415760405162461bcd60e51b815260040161047c90611882565b6001600160a01b038116610ca65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161047c565b610caf81610f48565b50565b6040805160a081018252620d2f00815262278d00602080830191909152624f1a0082840181905260608301526298ee00608083015261ffff841660009081526004918290529283200154909190610d0990426118b7565b61ffff841660009081526004602052604090206003015490915060ff165b60058160ff161015610d9557828160ff1660058110610d4857610d48611634565b602002015162ffffff168210610d9557828160ff1660058110610d6d57610d6d611634565b6020020151610d819062ffffff16836118b7565b915080610d8d816118ca565b915050610d27565b61ffff84166000908152600460205260409020600301805460ff191660ff8316179055610dc23385610f98565b50505050565b60408051606081018252629e34008152625c49006020808301919091526234bc008284015261ffff84166000908152600490915291822060020154909190610e1090426118b7565b61ffff841660009081526004602052604090206001015490915060ff165b60038160ff161015610f1b57828160ff1660038110610e4f57610e4f611634565b602002015162ffffff168210610f1b5760028054604051637921219560e11b815230600482015233602482015260448101929092526001606483015260a06084830152600060a48301526001600160a01b03169063f242432a9060c401600060405180830381600087803b158015610ec657600080fd5b505af1158015610eda573d6000803e3d6000fd5b50505050828160ff1660038110610ef357610ef3611634565b6020020151610f079062ffffff16836118b7565b915080610f13816118ca565b915050610e2e565b61ffff84166000908152600460205260409020600101805460ff191660ff8316179055610dc23385610f98565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000805b6001600160a01b03841660009081526003602052604090205461ffff82161015611035576001600160a01b0384166000908152600360205260409020805461ffff8086169291908416908110610ff457610ff4611634565b60009182526020909120601082040154600f9091166002026101000a900461ffff160361102357809150611035565b8061102d81611660565b915050610f9c565b506001600160a01b03831660009081526003602052604081205461105b906001906118b7565b90508061ffff168261ffff1614611128576001600160a01b0384166000908152600360205260409020805461ffff831690811061109a5761109a611634565b90600052602060002090601091828204019190066002029054906101000a900461ffff1660036000866001600160a01b03166001600160a01b031681526020019081526020016000208361ffff16815481106110f8576110f8611634565b90600052602060002090601091828204019190066002026101000a81548161ffff021916908361ffff1602179055505b6001600160a01b038416600090815260036020526040902080548061114f5761114f6118e9565b600082815260209020601060001990920191820401805461ffff6002600f8516026101000a0219169055905550505050565b60006020828403121561119357600080fd5b81356001600160e01b0319811681146111ab57600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff811182821017156111eb576111eb6111b2565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561121a5761121a6111b2565b604052919050565b600067ffffffffffffffff82111561123c5761123c6111b2565b5060051b60200190565b803561ffff8116811461125857600080fd5b919050565b6000602080838503121561127057600080fd5b823567ffffffffffffffff81111561128757600080fd5b8301601f8101851361129857600080fd5b80356112ab6112a682611222565b6111f1565b81815260059190911b820183019083810190878311156112ca57600080fd5b928401925b828410156112ef576112e084611246565b825292840192908401906112cf565b979650505050505050565b6001600160a01b0381168114610caf57600080fd5b600067ffffffffffffffff821115611329576113296111b2565b50601f01601f191660200190565b600082601f83011261134857600080fd5b81356113566112a68261130f565b81815284602083860101111561136b57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561139e57600080fd5b84356113a9816112fa565b935060208501356113b9816112fa565b925060408501359150606085013567ffffffffffffffff8111156113dc57600080fd5b6113e887828801611337565b91505092959194509250565b60006020828403121561140657600080fd5b6111ab82611246565b6001600160a01b038416815260a081016114396020830185805160ff168252602090810151910152565b825160ff166060830152602083015160808301526103c2565b60006020828403121561146457600080fd5b81356111ab816112fa565b6020808252825182820181905260009190848201906040850190845b818110156114ab57835161ffff168352928401929184019160010161148b565b50909695505050505050565b600082601f8301126114c857600080fd5b813560206114d86112a683611222565b82815260059290921b840181019181810190868411156114f757600080fd5b8286015b8481101561151257803583529183019183016114fb565b509695505050505050565b600080600080600060a0868803121561153557600080fd5b8535611540816112fa565b94506020860135611550816112fa565b9350604086013567ffffffffffffffff8082111561156d57600080fd5b61157989838a016114b7565b9450606088013591508082111561158f57600080fd5b61159b89838a016114b7565b935060808801359150808211156115b157600080fd5b506115be88828901611337565b9150509295509295909350565b600080600080600060a086880312156115e357600080fd5b85356115ee816112fa565b945060208601356115fe816112fa565b93506040860135925060608601359150608086013567ffffffffffffffff81111561162857600080fd5b6115be88828901611337565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600061ffff8083168181036116775761167761164a565b6001019392505050565b60006020828403121561169357600080fd5b81516111ab816112fa565b6001600160a01b03938416815291909216602082015261ffff909116604082015260600190565b805160ff8116811461125857600080fd5b600082601f8301126116e757600080fd5b6040516080810181811067ffffffffffffffff8211171561170a5761170a6111b2565b60405280608084018581111561171f57600080fd5b845b8181101561174057611732816116c5565b835260209283019201611721565b509195945050505050565b805167ffffffffffffffff8116811461125857600080fd5b600082601f83011261177457600080fd5b81516117826112a68261130f565b8181526020858184870101111561179857600080fd5b60005b838110156117b657858101820151838201830152810161179b565b50600092820101919091529392505050565b6000602082840312156117da57600080fd5b815167ffffffffffffffff808211156117f257600080fd5b90830190610100828603121561180757600080fd5b61180f6111c8565b611818836116c5565b81526020830151801515811461182d57600080fd5b602082015261183f86604085016116d6565b604082015261185060c0840161174b565b606082015260e08301518281111561186757600080fd5b61187387828601611763565b60808301525095945050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b818103818111156103675761036761164a565b600060ff821660ff81036118e0576118e061164a565b60010192915050565b634e487b7160e01b600052603160045260246000fdfea26469706673582212201f7e081ff8286f8ddcde8f24a8fb7beb8da5b37c3859b8afd45d59f0b67fdb7764736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
VhilsStaking.sol 195 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IERC721 } from "@openzeppelin/contracts/interfaces/IERC721.sol";
import { IERC1155 } from "@openzeppelin/contracts/interfaces/IERC1155.sol";
import { ERC721Holder } from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import { ERC1155Holder } from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
// Vhils Staking
// Vhils + DRP + Pellar 2022
struct TokenInfo {
uint8 state;
bool locked;
uint8[4] tearIdUsed;
uint64 name;
string uri;
}
interface ILAYERS is IERC721 {
function getTokenInfo(uint16 _tokenId) external view returns (TokenInfo memory);
}
contract VhilsStaking is Ownable, ERC721Holder, ERC1155Holder {
struct TierTear {
uint8 level;
uint256 startTime;
}
struct TierMedal {
uint8 rank;
uint256 startTime;
}
struct StakingInfo {
address owner;
TierTear tierTear;
TierMedal tierMedal;
}
// variables
address public vhilsNFT;
address public vhilsTears;
mapping(address => uint16[]) stakedLayers; // retrieve tokens staked by owner
mapping(uint16 => StakingInfo) public stakingInfo;
event Staked(uint16 indexed tokenId, address from, uint8 currentLevel, uint256 startTime, uint8 stakingType);
event UnStaked(uint16 indexed tokenId, address from, uint8 newLevel, uint256 startTime, uint256 endTime, uint8 stakingType);
constructor() {}
function getStakedLayers(address _owner) external view returns (uint16[] memory) {
return stakedLayers[_owner];
}
// stake for layers/tears
function stake(uint16 _tokenId) public {
require(ILAYERS(vhilsNFT).ownerOf(_tokenId) == msg.sender, "Require owner");
// transfer
ILAYERS(vhilsNFT).transferFrom(msg.sender, address(this), _tokenId);
stakedLayers[msg.sender].push(_tokenId); // add to owner list after transfer
stakingInfo[_tokenId].owner = msg.sender; // owner checkpoint
// detect and stake
TokenInfo memory tokenInfo = ILAYERS(vhilsNFT).getTokenInfo(_tokenId);
uint256 _currentTime = block.timestamp;
if (tokenInfo.state == 3) { // tears
stakingInfo[_tokenId].tierMedal.startTime = _currentTime;
emit Staked(_tokenId, msg.sender, stakingInfo[_tokenId].tierMedal.rank, _currentTime, 1);
} else { // layers
uint8 stakingLevel = stakingInfo[_tokenId].tierTear.level;
uint8 currentLevel = stakingLevel >= tokenInfo.state ? stakingLevel : tokenInfo.state;
require(currentLevel < 3, "Exceed state");
stakingInfo[_tokenId].tierTear.level = currentLevel;
stakingInfo[_tokenId].tierTear.startTime = _currentTime;
emit Staked(_tokenId, msg.sender, currentLevel, _currentTime, 0);
}
}
// withdraw and get rewards
function withdraw(uint16 _tokenId) public {
require(msg.sender == stakingInfo[_tokenId].owner, "Require owner");
ILAYERS(vhilsNFT).transferFrom(address(this), msg.sender, _tokenId);
stakingInfo[_tokenId].owner = address(0); // owner checkpoint
// detect and stake
TokenInfo memory tokenInfo = ILAYERS(vhilsNFT).getTokenInfo(_tokenId);
uint256 _currentTime = block.timestamp;
if (tokenInfo.state == 3) {
_withdrawForMedals(_tokenId);
emit UnStaked(_tokenId, msg.sender, stakingInfo[_tokenId].tierMedal.rank, stakingInfo[_tokenId].tierMedal.startTime, _currentTime, 1);
} else {
_withdrawForTears(_tokenId);
emit UnStaked(_tokenId, msg.sender, stakingInfo[_tokenId].tierTear.level, stakingInfo[_tokenId].tierTear.startTime, _currentTime, 0);
}
}
function _withdrawForMedals(uint16 _tokenId) internal {
// days: 24 * 60 * 60
uint24[5] memory stakingDays = [
10 * 24 * 60 * 60, //
30 * 24 * 60 * 60,
60 * 24 * 60 * 60,
60 * 24 * 60 * 60,
116 * 24 * 60 * 60
];
uint256 durations = block.timestamp - stakingInfo[_tokenId].tierMedal.startTime;
uint8 i = stakingInfo[_tokenId].tierMedal.rank;
for (; i < stakingDays.length; i++) {
if (durations < stakingDays[i]) {
break;
}
durations -= stakingDays[i];
}
stakingInfo[_tokenId].tierMedal.rank = i; // update new rank
_removeTokenFromStakedList(msg.sender, _tokenId);
}
function _withdrawForTears(uint16 _tokenId) internal {
// days: 24 * 60 * 60
uint24[3] memory stakingDays = [120 * 24 * 60 * 60, 70 * 24 * 60 * 60, 40 * 24 * 60 * 60];
uint256 durations = block.timestamp - stakingInfo[_tokenId].tierTear.startTime;
uint8 i = stakingInfo[_tokenId].tierTear.level;
for (; i < stakingDays.length; i++) {
if (durations < stakingDays[i]) {
break;
}
IERC1155(vhilsTears).safeTransferFrom(address(this), msg.sender, 2, 1, "");
durations -= stakingDays[i];
}
stakingInfo[_tokenId].tierTear.level = i; // update new level
_removeTokenFromStakedList(msg.sender, _tokenId);
}
function batchStake(uint16[] memory _tokenIds) external {
for (uint16 i = 0; i < _tokenIds.length; i++) {
stake(_tokenIds[i]);
}
}
function batchWithdraw(uint16[] memory _tokenIds) external {
for (uint16 i = 0; i < _tokenIds.length; i++) {
withdraw(_tokenIds[i]);
}
}
/* View */
function bindVhilsNFT(address _contract) external onlyOwner {
vhilsNFT = _contract;
}
function bindVhilsTears(address _contract) external onlyOwner {
vhilsTears = _contract;
}
// emergency unstake (owner)
function forceWithdrawNFT(uint16[] memory _tokenIds) external onlyOwner {
uint16 size = uint16(_tokenIds.length);
for (uint16 i = 0; i < size; i++) {
ILAYERS(vhilsNFT).transferFrom(address(this), msg.sender, _tokenIds[i]);
}
}
/* internal */
function _removeTokenFromStakedList(address _owner, uint16 _tokenId) internal {
uint16 _index;
for (uint16 i = 0; i < stakedLayers[_owner].length; i++) {
if (stakedLayers[_owner][i] == _tokenId) {
_index = i;
break;
}
}
uint16 _finalIndex = uint16(stakedLayers[_owner].length - 1);
if (_index != _finalIndex) {
stakedLayers[_owner][_index] = stakedLayers[_owner][_finalIndex]; // set current to same as final
}
stakedLayers[_owner].pop();
}
}
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 6 lines
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol";
IERC1155.sol 6 lines
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol) pragma solidity ^0.8.0; import "../token/ERC1155/IERC1155.sol";
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);
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)
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 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
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 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);
}
IERC1155Receiver.sol 58 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
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.
*
* NOTE: 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.
*
* NOTE: 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);
}
ERC721Holder.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.0;
import "../IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
*/
contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address,
address,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC721Received.selector;
}
}
ERC1155Holder.sol 36 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)
pragma solidity ^0.8.0;
import "./ERC1155Receiver.sol";
/**
* Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
* stuck.
*
* @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 19 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)
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
getStakedLayers 0x4b88bb4c → uint16[]
owner 0x8da5cb5b → address
stakingInfo 0x229a1132 → address, tuple, tuple
supportsInterface 0x01ffc9a7 → bool
vhilsNFT 0x9524fb57 → address
vhilsTears 0x222fe912 → address
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
batchStake 0xe9e1921a
uint16[] _tokenIds
batchWithdraw 0x132e8bee
uint16[] _tokenIds
bindVhilsNFT 0xd94757e4
address _contract
bindVhilsTears 0x5228cd3f
address _contract
forceWithdrawNFT 0xd468b381
uint16[] _tokenIds
onERC1155BatchReceived 0xbc197c81
address
address
uint256[]
uint256[]
bytes
returns: bytes4
onERC1155Received 0xf23a6e61
address
address
uint256
uint256
bytes
returns: bytes4
onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
renounceOwnership 0x715018a6
No parameters
stake 0x2f57ee41
uint16 _tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3d972839
uint16 _tokenId
Recent Transactions
No transactions found for this address