Contract Overview
Balance:
0 CRO
CRO Value:
$0.00
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
ZoomersBonusTrait
Compiler Version
v0.8.10+commit.fc410830
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; interface IScratch { function balanceOf(address account) external view returns (uint256); function transferFrom(address from, address to, uint256 amount) external returns (bool); } interface IZoom { function ownerOf(uint256 tokenId) external view returns (address); } interface IRando { function getRando(uint256 _id, address _add) external view returns (uint256); } contract ZoomersBonusTrait is Ownable { /** * * Events * */ event TraitUpdate(uint256 tokenId, uint256 trait); /** * * Functions * */ IScratch public scratchContract; function setScratchContract(address _add) external onlyOwner { require(_add != address(0), "null addr"); scratchContract = IScratch(_add); } IZoom public zoomerContract; function setZoomerContract(address _add) external onlyOwner { require(_add != address(0), "null addr"); zoomerContract = IZoom(_add); } IRando public randoContract; function setRandoContract(address _add) external onlyOwner { require(_add != address(0), "null addr"); randoContract = IRando(_add); } address public scratchBurner; function setScratchBurner(address _add) external onlyOwner { require(_add != address(0), "null addr"); scratchBurner = _add; } bool public rollState; function setRollState(bool _state) external onlyOwner { rollState = _state; } mapping(uint256 => uint256) public bonusTrait; function setBonusTrait(uint256 _tokenId, uint256 _trait) external onlyOwner { require(_trait <= 9, "Invalid trait"); require(_tokenId <= 7007, "Invalid tokenId"); bonusTrait[_tokenId] = _trait; emit TraitUpdate(_tokenId, _trait); } uint256 public rollCost; function setRollCost(uint256 _cost) external onlyOwner { rollCost = _cost; } function rollBonusTrait(uint256 _tokenId) external { require(rollState, "Rolls must be active"); require(zoomerContract.ownerOf(_tokenId) == msg.sender, "Must be token owner"); uint256 balance = scratchContract.balanceOf(msg.sender); // verify and send SCRATCH to burner require(rollCost <= balance, "Must have enough SCRATCH"); scratchContract.transferFrom(msg.sender, scratchBurner, rollCost); // get random trait uint256 max = 1000; uint256 rand = randoContract.getRando(_tokenId, msg.sender) % max; uint256 _trait = 0; if (rand >= 0 && rand < 160) { _trait = 1; } else if (rand >= 160 && rand < 320) { _trait = 2; } else if (rand >= 320 && rand < 480) { _trait = 3; } else if (rand >= 480 && rand < 590) { _trait = 4; } else if (rand >= 590 && rand < 700) { _trait = 5; } else if (rand >= 700 && rand < 810) { _trait = 6; } else if (rand >= 810 && rand < 880) { _trait = 7; } else if (rand >= 880 && rand < 950) { _trait = 8; } else if (rand >= 950 && rand < max) { _trait = 9; } else { revert("invalid roll"); } bonusTrait[_tokenId] = _trait; emit TraitUpdate(_tokenId, _trait); } function viewBonusTrait(uint256 _tokenId) external view returns(uint256){ return bonusTrait[_tokenId]; } }
// 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (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 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 { 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); } }
{ "remappings": [], "optimizer": { "details": { "constantOptimizer": true, "cse": true, "deduplicate": true, "inliner": true, "jumpdestRemover": true, "orderLiterals": true, "peephole": true, "yul": false }, "runs": 200 }, "evmVersion": "london", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"trait","type":"uint256"}],"name":"TraitUpdate","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"bonusTrait","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randoContract","outputs":[{"internalType":"contract IRando","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"rollBonusTrait","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rollState","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scratchBurner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scratchContract","outputs":[{"internalType":"contract IScratch","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_trait","type":"uint256"}],"name":"setBonusTrait","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"setRandoContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cost","type":"uint256"}],"name":"setRollCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setRollState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"setScratchBurner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"setScratchContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"setZoomerContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"viewBonusTrait","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"zoomerContract","outputs":[{"internalType":"contract IZoom","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610e638061007e6000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c806391309530116100ad578063d930cc7d11610071578063d930cc7d1461027d578063f2fc35d314610290578063f2fde38b14610299578063f78693a3146102ac578063f9a71c3c146102bf57600080fd5b806391309530146101e957806394383aa4146101fc578063acb164b214610229578063bbc0d75314610249578063d710096a1461025c57600080fd5b80636c9cf9ea116100f45780636c9cf9ea14610197578063715018a6146101aa57806383f015ea146101b25780638da5cb5b146101c55780638df654fb146101d657600080fd5b80631a3ff6a0146101265780632fe565b81461014f5780633cff5ee714610164578063667d8a7c14610177575b600080fd5b600454610139906001600160a01b031681565b60405161014691906109a4565b60405180910390f35b61016261015d3660046109d1565b6102d2565b005b6101626101723660046109d1565b61032b565b60025461018a906001600160a01b031681565b6040516101469190610a2a565b6101626101a53660046109d1565b61037b565b6101626103cb565b60015461018a906001600160a01b031681565b6000546001600160a01b0316610139565b6101626101e4366004610a49565b6103df565b6101626101f7366004610a86565b610479565b61021c61020a366004610a86565b60056020526000908152604090205481565b6040516101469190610aad565b61021c610237366004610a86565b60009081526005602052604090205490565b6101626102573660046109d1565b61084b565b60045461027090600160a01b900460ff1681565b6040516101469190610ac3565b60035461018a906001600160a01b031681565b61021c60065481565b6101626102a73660046109d1565b61089b565b6101626102ba366004610a86565b6108d5565b6101626102cd366004610ae4565b6108e2565b6102da610908565b6001600160a01b0381166103095760405162461bcd60e51b815260040161030090610b28565b60405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b610333610908565b6001600160a01b0381166103595760405162461bcd60e51b815260040161030090610b28565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b610383610908565b6001600160a01b0381166103a95760405162461bcd60e51b815260040161030090610b28565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6103d3610908565b6103dd6000610932565b565b6103e7610908565b60098111156104085760405162461bcd60e51b815260040161030090610b5c565b611b5f82111561042a5760405162461bcd60e51b815260040161030090610b92565b60008281526005602052604090819020829055517f80f63ca6f8c102f833d9bf90fde52d19cbfb627bb7561583beac17b635f1a88c9061046d9084908490610ba2565b60405180910390a15050565b600454600160a01b900460ff166104a25760405162461bcd60e51b815260040161030090610bef565b6002546040516331a9108f60e11b815233916001600160a01b031690636352211e906104d2908590600401610aad565b602060405180830381865afa1580156104ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105139190610c0a565b6001600160a01b0316146105395760405162461bcd60e51b815260040161030090610c55565b6001546040516370a0823160e01b81526000916001600160a01b0316906370a082319061056a9033906004016109a4565b602060405180830381865afa158015610587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ab9190610c70565b90508060065411156105cf5760405162461bcd60e51b815260040161030090610cc5565b600154600480546006546040516323b872dd60e01b81526001600160a01b03948516946323b872dd9461060794339492169201610cd5565b6020604051808303816000875af1158015610626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064a9190610d08565b5060035460405163f693dd2160e01b81526103e89160009183916001600160a01b03169063f693dd21906106849088903390600401610d29565b602060405180830381865afa1580156106a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c59190610c70565b6106cf9190610d5a565b9050600060a08210156106e4575060016107f9565b60a082101580156106f6575061014082105b15610703575060026107f9565b610140821015801561071657506101e082105b15610723575060036107f9565b6101e08210158015610736575061024e82105b15610743575060046107f9565b61024e821015801561075657506102bc82105b15610763575060056107f9565b6102bc8210158015610776575061032a82105b15610783575060066107f9565b61032a8210158015610796575061037082105b156107a3575060076107f9565b61037082101580156107b657506103b682105b156107c3575060086107f9565b6103b682101580156107d457508282105b156107e1575060096107f9565b60405162461bcd60e51b815260040161030090610d91565b60008581526005602052604090819020829055517f80f63ca6f8c102f833d9bf90fde52d19cbfb627bb7561583beac17b635f1a88c9061083c9087908490610ba2565b60405180910390a15050505050565b610853610908565b6001600160a01b0381166108795760405162461bcd60e51b815260040161030090610b28565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6108a3610908565b6001600160a01b0381166108c95760405162461bcd60e51b815260040161030090610da1565b6108d281610932565b50565b6108dd610908565b600655565b6108ea610908565b60048054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146103dd5760405162461bcd60e51b815260040161030090610e1d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160a01b0382165b92915050565b61099e81610982565b82525050565b6020810161098f8284610995565b6109bb81610982565b81146108d257600080fd5b803561098f816109b2565b6000602082840312156109e6576109e6600080fd5b60006109f284846109c6565b949350505050565b60006001600160a01b03821661098f565b600061098f826109fa565b600061098f82610a0b565b61099e81610a16565b6020810161098f8284610a21565b806109bb565b803561098f81610a38565b60008060408385031215610a5f57610a5f600080fd5b6000610a6b8585610a3e565b9250506020610a7c85828601610a3e565b9150509250929050565b600060208284031215610a9b57610a9b600080fd5b60006109f28484610a3e565b8061099e565b6020810161098f8284610aa7565b80151561099e565b6020810161098f8284610abb565b8015156109bb565b803561098f81610ad1565b600060208284031215610af957610af9600080fd5b60006109f28484610ad9565b6009815260006020820168373ab6361030b2323960b91b815291505b5060200190565b6020808252810161098f81610b05565b600d81526000602082016c125b9d985b1a59081d1c985a5d609a1b81529150610b21565b6020808252810161098f81610b38565b600f81526000602082016e125b9d985b1a59081d1bdad95b9259608a1b81529150610b21565b6020808252810161098f81610b6c565b60408101610bb08285610aa7565b610bbd6020830184610aa7565b9392505050565b6014815260006020820173526f6c6c73206d7573742062652061637469766560601b81529150610b21565b6020808252810161098f81610bc4565b805161098f816109b2565b600060208284031215610c1f57610c1f600080fd5b60006109f28484610bff565b601381526000602082017226bab9ba103132903a37b5b2b71037bbb732b960691b81529150610b21565b6020808252810161098f81610c2b565b805161098f81610a38565b600060208284031215610c8557610c85600080fd5b60006109f28484610c65565b601881526000602082017f4d757374206861766520656e6f7567682053435241544348000000000000000081529150610b21565b6020808252810161098f81610c91565b60608101610ce38286610995565b610cf06020830185610995565b6109f26040830184610aa7565b805161098f81610ad1565b600060208284031215610d1d57610d1d600080fd5b60006109f28484610cfd565b60408101610d378285610aa7565b610bbd6020830184610995565b634e487b7160e01b600052601260045260246000fd5b600082610d6957610d69610d44565b500690565b600c81526000602082016b1a5b9d985b1a59081c9bdb1b60a21b81529150610b21565b6020808252810161098f81610d6e565b6020808252810161098f81602681527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160208201526564647265737360d01b604082015260600190565b60208082527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657291019081526000610b21565b6020808252810161098f81610deb56fea2646970667358221220d6af580943ff1007eddabaa930dd1f0b240870672e6c015860224ac2bd41469364736f6c634300080a0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.