Contract Overview
Balance:
0 ETH
ETH Value:
$0.00
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x7604ab8d50a170ad8d30ace2dd4931ce3fef87865644d575dc04dbf2d971c282 | 0x60806040 | 32255995 | 95 days 17 hrs ago | 0xb013abd83f0bd173e9f14ce7d6e420ad711483b4 | IN | Create: Barracks | 0 ETH | 0.00093623 |
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
Barracks
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes 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-upgradeable/proxy/utils/Initializable.sol"; import "./BarracksContracts.sol"; contract Barracks is Initializable, BarracksContracts { function initialize() external initializer { BarracksContracts.__BarracksContracts_init(); } function setMagicCostPerLegion(uint256 _magicCostPerLegion) external onlyAdminOrOwner { magicCostPerLegion = _magicCostPerLegion; } function trainRecruit() external whenNotPaused onlyEOA contractsAreSet { require(!addressToHasTrained[msg.sender], "Already trained"); require(magicCostPerLegion > 0, "Magic cost not set"); addressToHasTrained[msg.sender] = true; bool _wasMagicTransferred = magic.transferFrom(msg.sender, address(treasury), magicCostPerLegion); require(_wasMagicTransferred, "Magic not transferred"); treasury.forwardCoinsToMine(magicCostPerLegion); uint256 _newlyMintedTokenId = legion.safeMint(msg.sender); legionMetadataStore.setInitialMetadataForLegion(msg.sender, _newlyMintedTokenId, LegionGeneration.RECRUIT, LegionClass.RECRUIT, LegionRarity.RECRUIT, 0); emit RecruitTrained(msg.sender, _newlyMintedTokenId); } function trainRecruitAdmin(address _to) external whenNotPaused onlyEOA contractsAreSet onlyAdminOrOwner { require(!addressToHasTrained[_to], "Already trained"); addressToHasTrained[_to] = true; uint256 _newlyMintedTokenId = legion.safeMint(_to); legionMetadataStore.setInitialMetadataForLegion(_to, _newlyMintedTokenId, LegionGeneration.RECRUIT, LegionClass.RECRUIT, LegionRarity.RECRUIT, 0); emit RecruitTrained(_to, _newlyMintedTokenId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./BarracksState.sol"; abstract contract BarracksContracts is Initializable, BarracksState { function __BarracksContracts_init() internal initializer { BarracksState.__BarracksState_init(); } function setContracts( address _randomizerAddress, address _magicAddress, address _legionAddress, address _legionMetadataStoreAddress, address _treasuryAddress) external onlyAdminOrOwner { randomizer = IRandomizer(_randomizerAddress); magic = IMagic(_magicAddress); legion = ILegion(_legionAddress); legionMetadataStore = ILegionMetadataStore(_legionMetadataStoreAddress); treasury = ITreasury(_treasuryAddress); } modifier contractsAreSet() { require(areContractsSet(), "Barracks: Contracts aren't set"); _; } function areContractsSet() public view returns(bool) { return address(randomizer) != address(0) && address(magic) != address(0) && address(legionMetadataStore) != address(0) && address(treasury) != address(0) && address(legion) != address(0); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "../../shared/randomizer/IRandomizer.sol"; import "./IBarracks.sol"; import "../external/IMagic.sol"; import "../legion/ILegion.sol"; import "../treasury/ITreasury.sol"; import "../legionmetadatastore/ILegionMetadataStore.sol"; import "../../shared/AdminableUpgradeable.sol"; abstract contract BarracksState is Initializable, IBarracks, AdminableUpgradeable { event RecruitTrained(address indexed _owner, uint256 indexed _tokenId); IRandomizer public randomizer; IMagic public magic; ILegion public legion; ILegionMetadataStore public legionMetadataStore; ITreasury public treasury; uint256 public magicCostPerLegion; mapping(address => bool) public addressToHasTrained; function __BarracksState_init() internal initializer { AdminableUpgradeable.__Adminable_init(); magicCostPerLegion = 10 ether; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IRandomizer { // Sets the number of blocks that must pass between increment the commitId and seeding the random // Admin function setNumBlocksAfterIncrement(uint8 _numBlocksAfterIncrement) external; // Increments the commit id. // Admin function incrementCommitId() external; // Adding the random number needs to be done AFTER incrementing the commit id on a separate transaction. If // these are done together, there is a potential vulnerability to front load a commit when the bad actor // sees the value of the random number. function addRandomForCommit(uint256 _seed) external; // Returns a request ID for a random number. This is unique. function requestRandomNumber() external returns(uint256); // Returns the random number for the given request ID. Will revert // if the random is not ready. function revealRandomNumber(uint256 _requestId) external view returns(uint256); // Returns if the random number for the given request ID is ready or not. Call // before calling revealRandomNumber. function isRandomReady(uint256 _requestId) external view returns(bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IBarracks { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IMagic { // Transfers the given amount to the recipient's wallet. Returns a boolean indicating if it was // successful or not. function transferFrom(address _sender, address _recipient, uint256 _amount) external returns(bool); // Transfer the given amount to the recipient's wallet. The sender is the caller of this function. // Returns a boolean indicating if it was successful or not. function transfer(address _recipient, uint256 _amount) external returns(bool); function approve(address _spender, uint256 _amount) external returns(bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol"; interface ILegion is IERC721MetadataUpgradeable { // Mints a legion to the given address. Returns the token ID. // Admin only. function safeMint(address _to) external returns(uint256); // Sets the URI for the given token id. Token must exist. // Admin only. function setTokenURI(uint256 _tokenId, string calldata _tokenURI) external; // Transfers the token to the given address. Does not need approval. _from still must be the owner of the token. // Admin only. function adminSafeTransferFrom(address _from, address _to, uint256 _tokenId) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ITreasury { function isBridgeWorldPowered() external view returns(bool); function forwardCoinsToMine(uint256 _totalMagicSent) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LegionMetadataStoreState.sol"; interface ILegionMetadataStore { // Sets the intial metadata for a token id. // Admin only. function setInitialMetadataForLegion(address _owner, uint256 _tokenId, LegionGeneration _generation, LegionClass _class, LegionRarity _rarity, uint256 _oldId) external; // Increases the quest level by one. It is up to the calling contract to regulate the max quest level. No validation. // Admin only. function increaseQuestLevel(uint256 _tokenId) external; // Increases the craft level by one. It is up to the calling contract to regulate the max craft level. No validation. // Admin only. function increaseCraftLevel(uint256 _tokenId) external; // Increases the rank of the given constellation to the given number. It is up to the calling contract to regulate the max constellation rank. No validation. // Admin only. function increaseConstellationRank(uint256 _tokenId, Constellation _constellation, uint8 _to) external; // Returns the metadata for the given legion. function metadataForLegion(uint256 _tokenId) external view returns(LegionMetadata memory); // Returns the tokenUri for the given token. function tokenURI(uint256 _tokenId) external view returns(string memory); } // As this will likely change in the future, this should not be used to store state, but rather // as parameters and return values from functions. struct LegionMetadata { LegionGeneration legionGeneration; LegionClass legionClass; LegionRarity legionRarity; uint8 questLevel; uint8 craftLevel; uint8[6] constellationRanks; uint256 oldId; } enum Constellation { FIRE, EARTH, WIND, WATER, LIGHT, DARK } enum LegionRarity { LEGENDARY, RARE, SPECIAL, UNCOMMON, COMMON, RECRUIT } enum LegionClass { RECRUIT, SIEGE, FIGHTER, ASSASSIN, RANGED, SPELLCASTER, RIVERMAN, NUMERAIRE, ALL_CLASS, ORIGIN } enum LegionGeneration { GENESIS, AUXILIARY, RECRUIT }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./UtilitiesUpgradeable.sol"; // Do not add state to this contract. // contract AdminableUpgradeable is UtilitiesUpgradeable { mapping(address => bool) private admins; function __Adminable_init() internal initializer { UtilitiesUpgradeable.__Utilities__init(); } function addAdmin(address _address) external onlyOwner { admins[_address] = true; } function addAdmins(address[] calldata _addresses) external onlyOwner { for(uint256 i = 0; i < _addresses.length; i++) { admins[_addresses[i]] = true; } } function removeAdmin(address _address) external onlyOwner { admins[_address] = false; } function removeAdmins(address[] calldata _addresses) external onlyOwner { for(uint256 i = 0; i < _addresses.length; i++) { admins[_addresses[i]] = false; } } function setPause(bool _shouldPause) external onlyAdminOrOwner { if(_shouldPause) { _pause(); } else { _unpause(); } } function isAdmin(address _address) public view returns(bool) { return admins[_address]; } modifier onlyAdmin() { require(admins[msg.sender], "Not admin"); _; } modifier onlyAdminOrOwner() { require(admins[msg.sender] || isOwner(), "Not admin or owner"); _; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @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`, 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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 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); /** * @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; }
// 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 IERC165Upgradeable { /** * @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); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "../../shared/AdminableUpgradeable.sol"; import "./ILegionMetadataStore.sol"; abstract contract LegionMetadataStoreState is Initializable, AdminableUpgradeable { event LegionQuestLevelUp(uint256 indexed _tokenId, uint8 _questLevel); event LegionCraftLevelUp(uint256 indexed _tokenId, uint8 _craftLevel); event LegionConstellationRankUp(uint256 indexed _tokenId, Constellation indexed _constellation, uint8 _rank); event LegionCreated(address indexed _owner, uint256 indexed _tokenId, LegionGeneration _generation, LegionClass _class, LegionRarity _rarity); mapping(uint256 => LegionGeneration) internal idToGeneration; mapping(uint256 => LegionClass) internal idToClass; mapping(uint256 => LegionRarity) internal idToRarity; mapping(uint256 => uint256) internal idToOldId; mapping(uint256 => uint8) internal idToQuestLevel; mapping(uint256 => uint8) internal idToCraftLevel; mapping(uint256 => uint8[6]) internal idToConstellationRanks; mapping(LegionGeneration => mapping(LegionClass => mapping(LegionRarity => mapping(uint256 => string)))) internal _genToClassToRarityToOldIdToUri; function __LegionMetadataStoreState_init() internal initializer { AdminableUpgradeable.__Adminable_init(); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; contract UtilitiesUpgradeable is Initializable, OwnableUpgradeable, PausableUpgradeable { function __Utilities__init() internal initializer { OwnableUpgradeable.__Ownable_init(); PausableUpgradeable.__Pausable_init(); _pause(); } modifier nonZeroAddress(address _address) { require(address(0) != _address, "0 address"); _; } modifier nonZeroLength(uint[] memory _array) { require(_array.length > 0, "Empty array"); _; } modifier lengthsAreEqual(uint[] memory _array1, uint[] memory _array2) { require(_array1.length == _array2.length, "Unequal lengths"); _; } modifier onlyEOA() { /* solhint-disable avoid-tx-origin */ require(msg.sender == tx.origin, "No contracts"); _; } function isOwner() internal view returns(bool) { return owner() == msg.sender; } function compareStrings(string memory a, string memory b) internal pure returns (bool) { return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"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":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"RecruitTrained","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"}],"name":"addAdmins","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressToHasTrained","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"areContractsSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"legion","outputs":[{"internalType":"contract ILegion","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"legionMetadataStore","outputs":[{"internalType":"contract ILegionMetadataStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"magic","outputs":[{"internalType":"contract IMagic","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"magicCostPerLegion","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":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randomizer","outputs":[{"internalType":"contract IRandomizer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"removeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"}],"name":"removeAdmins","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_randomizerAddress","type":"address"},{"internalType":"address","name":"_magicAddress","type":"address"},{"internalType":"address","name":"_legionAddress","type":"address"},{"internalType":"address","name":"_legionMetadataStoreAddress","type":"address"},{"internalType":"address","name":"_treasuryAddress","type":"address"}],"name":"setContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_magicCostPerLegion","type":"uint256"}],"name":"setMagicCostPerLegion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldPause","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trainRecruit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"trainRecruitAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"contract ITreasury","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506115b0806100206000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c80638129fc1c116100c3578063a5e0ac521161007c578063a5e0ac52146102ab578063bedb86fb146102ce578063ee8b9bd2146102e1578063f10fb584146102f4578063f2fde38b14610307578063f63bf8bd1461031a57600080fd5b80638129fc1c1461025c5780638a7bf804146102645780638cdcc4b4146102775780638da5cb5b1461027f5780639405f1e2146102905780639c54df641461029857600080fd5b80635c975abb116101155780635c975abb146101f957806361d027b314610204578063675857eb146102175780636bcf8ea51461022a5780637048027514610241578063715018a61461025457600080fd5b80630d854646146101525780631785f53c1461018257806324d7806c14610197578063377e11e0146101d35780634121cdcd146101e6575b600080fd5b60cb54610165906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610195610190366004611226565b61032d565b005b6101c36101a5366004611226565b6001600160a01b031660009081526097602052604090205460ff1690565b6040519015158152602001610179565b6101956101e1366004611248565b610381565b6101956101f4366004611226565b610422565b60655460ff166101c3565b60ce54610165906001600160a01b031681565b60cc54610165906001600160a01b031681565b61023360cf5481565b604051908152602001610179565b61019561024f366004611226565b6106a5565b6101956106f3565b610195610729565b60cd54610165906001600160a01b031681565b6101c36107a3565b6033546001600160a01b0316610165565b610195610811565b6101956102a6366004611248565b610bc0565b6101c36102b9366004611226565b60d06020526000908152604090205460ff1681565b6101956102dc3660046112cb565b610c5c565b6101956102ef3660046112e8565b610caf565b60ca54610165906001600160a01b031681565b610195610315366004611226565b610cf1565b610195610328366004611301565b610d89565b6033546001600160a01b031633146103605760405162461bcd60e51b815260040161035790611366565b60405180910390fd5b6001600160a01b03166000908152609760205260409020805460ff19169055565b6033546001600160a01b031633146103ab5760405162461bcd60e51b815260040161035790611366565b60005b8181101561041d576000609760008585858181106103ce576103ce61139b565b90506020020160208101906103e39190611226565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610415816113b1565b9150506103ae565b505050565b60655460ff16156104455760405162461bcd60e51b8152600401610357906113d8565b3332146104835760405162461bcd60e51b815260206004820152600c60248201526b4e6f20636f6e74726163747360a01b6044820152606401610357565b61048b6107a3565b6104d75760405162461bcd60e51b815260206004820152601e60248201527f4261727261636b733a20436f6e747261637473206172656e27742073657400006044820152606401610357565b3360009081526097602052604090205460ff16806104f857506104f8610e25565b6105145760405162461bcd60e51b815260040161035790611402565b6001600160a01b038116600090815260d0602052604090205460ff161561056f5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e481d1c985a5b9959608a1b6044820152606401610357565b6001600160a01b03818116600081815260d06020526040808220805460ff1916600117905560cc5490516340d097c360e01b81526004810193909352909216906340d097c3906024016020604051808303816000875af11580156105d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fb919061142e565b60cd546040516307d1b76f60e41b81529192506001600160a01b031690637d1b76f0906106399085908590600290600090600590829060040161145d565b600060405180830381600087803b15801561065357600080fd5b505af1158015610667573d6000803e3d6000fd5b50506040518392506001600160a01b03851691507f71768d9e271e9e584a4d5f6af201c0e8923336846e3ef91b5ea111f8dc3d83e990600090a35050565b6033546001600160a01b031633146106cf5760405162461bcd60e51b815260040161035790611366565b6001600160a01b03166000908152609760205260409020805460ff19166001179055565b6033546001600160a01b0316331461071d5760405162461bcd60e51b815260040161035790611366565b6107276000610e49565b565b600054610100900460ff166107445760005460ff1615610748565b303b155b6107645760405162461bcd60e51b8152600401610357906114c4565b600054610100900460ff16158015610786576000805461ffff19166101011790555b61078e610e9b565b80156107a0576000805461ff00191690555b50565b60ca546000906001600160a01b0316158015906107ca575060cb546001600160a01b031615155b80156107e0575060cd546001600160a01b031615155b80156107f6575060ce546001600160a01b031615155b801561080c575060cc546001600160a01b031615155b905090565b60655460ff16156108345760405162461bcd60e51b8152600401610357906113d8565b3332146108725760405162461bcd60e51b815260206004820152600c60248201526b4e6f20636f6e74726163747360a01b6044820152606401610357565b61087a6107a3565b6108c65760405162461bcd60e51b815260206004820152601e60248201527f4261727261636b733a20436f6e747261637473206172656e27742073657400006044820152606401610357565b33600090815260d0602052604090205460ff16156109185760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e481d1c985a5b9959608a1b6044820152606401610357565b600060cf541161095f5760405162461bcd60e51b8152602060048201526012602482015271135859da58c818dbdcdd081b9bdd081cd95d60721b6044820152606401610357565b33600081815260d06020526040808220805460ff1916600117905560cb5460ce5460cf5492516323b872dd60e01b815260048101959095526001600160a01b039081166024860152604485019290925291929116906323b872dd906064016020604051808303816000875af11580156109dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a009190611512565b905080610a475760405162461bcd60e51b8152602060048201526015602482015274135859da58c81b9bdd081d1c985b9cd9995c9c9959605a1b6044820152606401610357565b60ce5460cf546040516359193fc560e01b81526001600160a01b03909216916359193fc591610a7c9160040190815260200190565b600060405180830381600087803b158015610a9657600080fd5b505af1158015610aaa573d6000803e3d6000fd5b505060cc546040516340d097c360e01b8152336004820152600093506001600160a01b0390911691506340d097c3906024016020604051808303816000875af1158015610afb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1f919061142e565b60cd546040516307d1b76f60e41b81529192506001600160a01b031690637d1b76f090610b5d9033908590600290600090600590829060040161145d565b600060405180830381600087803b158015610b7757600080fd5b505af1158015610b8b573d6000803e3d6000fd5b50506040518392503391507f71768d9e271e9e584a4d5f6af201c0e8923336846e3ef91b5ea111f8dc3d83e990600090a35050565b6033546001600160a01b03163314610bea5760405162461bcd60e51b815260040161035790611366565b60005b8181101561041d57600160976000858585818110610c0d57610c0d61139b565b9050602002016020810190610c229190611226565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610c54816113b1565b915050610bed565b3360009081526097602052604090205460ff1680610c7d5750610c7d610e25565b610c995760405162461bcd60e51b815260040161035790611402565b8015610ca7576107a0610f00565b6107a0610f75565b3360009081526097602052604090205460ff1680610cd05750610cd0610e25565b610cec5760405162461bcd60e51b815260040161035790611402565b60cf55565b6033546001600160a01b03163314610d1b5760405162461bcd60e51b815260040161035790611366565b6001600160a01b038116610d805760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610357565b6107a081610e49565b3360009081526097602052604090205460ff1680610daa5750610daa610e25565b610dc65760405162461bcd60e51b815260040161035790611402565b60ca80546001600160a01b03199081166001600160a01b039788161790915560cb805482169587169590951790945560cc805485169386169390931790925560cd8054841691851691909117905560ce80549092169216919091179055565b600033610e3a6033546001600160a01b031690565b6001600160a01b031614905090565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610eb65760005460ff1615610eba565b303b155b610ed65760405162461bcd60e51b8152600401610357906114c4565b600054610100900460ff16158015610ef8576000805461ffff19166101011790555b61078e610fef565b60655460ff1615610f235760405162461bcd60e51b8152600401610357906113d8565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610f583390565b6040516001600160a01b03909116815260200160405180910390a1565b60655460ff16610fbe5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610357565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33610f58565b600054610100900460ff1661100a5760005460ff161561100e565b303b155b61102a5760405162461bcd60e51b8152600401610357906114c4565b600054610100900460ff1615801561104c576000805461ffff19166101011790555b611054611074565b678ac7230489e8000060cf5580156107a0576000805461ff001916905550565b600054610100900460ff1661108f5760005460ff1615611093565b303b155b6110af5760405162461bcd60e51b8152600401610357906114c4565b600054610100900460ff161580156110d1576000805461ffff19166101011790555b61078e600054610100900460ff166110ef5760005460ff16156110f3565b303b155b61110f5760405162461bcd60e51b8152600401610357906114c4565b600054610100900460ff16158015611131576000805461ffff19166101011790555b611139611149565b611141611178565b61078e610f00565b600054610100900460ff166111705760405162461bcd60e51b81526004016103579061152f565b6107276111a7565b600054610100900460ff1661119f5760405162461bcd60e51b81526004016103579061152f565b6107276111d7565b600054610100900460ff166111ce5760405162461bcd60e51b81526004016103579061152f565b61072733610e49565b600054610100900460ff166111fe5760405162461bcd60e51b81526004016103579061152f565b6065805460ff19169055565b80356001600160a01b038116811461122157600080fd5b919050565b60006020828403121561123857600080fd5b6112418261120a565b9392505050565b6000806020838503121561125b57600080fd5b823567ffffffffffffffff8082111561127357600080fd5b818501915085601f83011261128757600080fd5b81358181111561129657600080fd5b8660208260051b85010111156112ab57600080fd5b60209290920196919550909350505050565b80151581146107a057600080fd5b6000602082840312156112dd57600080fd5b8135611241816112bd565b6000602082840312156112fa57600080fd5b5035919050565b600080600080600060a0868803121561131957600080fd5b6113228661120a565b94506113306020870161120a565b935061133e6040870161120a565b925061134c6060870161120a565b915061135a6080870161120a565b90509295509295909350565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000600182016113d157634e487b7160e01b600052601160045260246000fd5b5060010190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601290820152712737ba1030b236b4b71037b91037bbb732b960711b604082015260600190565b60006020828403121561144057600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b03871681526020810186905260c081016003861061148457611484611447565b856040830152600a851061149a5761149a611447565b846060830152600684106114b0576114b0611447565b608082019390935260a00152949350505050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60006020828403121561152457600080fd5b8151611241816112bd565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220cc6ac7f500ab334f14811bc1f2e90ede4a4f33e9ed90c68c4f7d4b68d2904ba964736f6c634300080d0033
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.