Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00Latest 25 from a total of 4,519 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Pay Homage | 170367020 | 750 days ago | IN | 0 ETH | 0.00038883 | ||||
| Pay Homage | 170357366 | 750 days ago | IN | 0 ETH | 0.0002789 | ||||
| Pay Homage | 170357285 | 750 days ago | IN | 0 ETH | 0.00028257 | ||||
| Pay Homage | 170357170 | 750 days ago | IN | 0 ETH | 0.00030962 | ||||
| Pay Homage | 170342824 | 750 days ago | IN | 0 ETH | 0.0003071 | ||||
| Pay Homage | 170316658 | 750 days ago | IN | 0 ETH | 0.00026285 | ||||
| Pay Homage | 170281102 | 750 days ago | IN | 0 ETH | 0.0003594 | ||||
| Pay Homage | 170274506 | 750 days ago | IN | 0 ETH | 0.00027227 | ||||
| Pay Homage | 170273579 | 750 days ago | IN | 0 ETH | 0.00034402 | ||||
| Pay Homage | 170246027 | 750 days ago | IN | 0 ETH | 0.00011765 | ||||
| Pay Homage | 170239313 | 750 days ago | IN | 0 ETH | 0.00017066 | ||||
| Pay Homage | 170225027 | 750 days ago | IN | 0 ETH | 0.00012644 | ||||
| Pay Homage | 170216171 | 750 days ago | IN | 0 ETH | 0.00012359 | ||||
| Pay Homage | 170128210 | 751 days ago | IN | 0 ETH | 0.00026487 | ||||
| Pay Homage | 170095139 | 751 days ago | IN | 0 ETH | 0.0002298 | ||||
| Pay Homage | 170085904 | 751 days ago | IN | 0 ETH | 0.00013694 | ||||
| Pay Homage | 170081122 | 751 days ago | IN | 0 ETH | 0.00015752 | ||||
| Pay Homage | 170027719 | 751 days ago | IN | 0 ETH | 0.00038543 | ||||
| Pay Homage | 169938988 | 751 days ago | IN | 0 ETH | 0.00012399 | ||||
| Pay Homage | 169930045 | 751 days ago | IN | 0 ETH | 0.00011553 | ||||
| Pay Homage | 169918338 | 751 days ago | IN | 0 ETH | 0.00010883 | ||||
| Pay Homage | 169858390 | 751 days ago | IN | 0 ETH | 0.00033327 | ||||
| Pay Homage | 169829678 | 752 days ago | IN | 0 ETH | 0.00013541 | ||||
| Pay Homage | 169796346 | 752 days ago | IN | 0 ETH | 0.00034894 | ||||
| Pay Homage | 169775584 | 752 days ago | IN | 0 ETH | 0.00059092 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MonumentHomage
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
import "../Action/Actions.sol";
import "../Action/ILastActionMarkerStorage.sol";
import "../Adventurer/IAdventurerData.sol";
import "../Adventurer/IAdventurerGateway.sol";
import "../Adventurer/TraitConstants.sol";
import "../Anima/Anima.sol";
import "../BatchStaker/IBatchBurnableStaker.sol";
import "../Lootbox/Rewards/IRewardsPool.sol";
import "../Manager/IManager.sol";
import "../Manager/ManagerModifier.sol";
import "../Realm/IRealm.sol";
import "../Resource/IResource.sol";
import "../Resource/ResourceConstants.sol";
import "../Utils/Epoch.sol";
import "../Utils/Random.sol";
import "./IMonumentHomage.sol";
import "./Monument.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
pragma solidity ^0.8.17;
contract MonumentHomage is
IMonumentHomage,
ManagerModifier,
Pausable,
ReentrancyGuard
{
using Epoch for uint256;
// Struct used for unwrapping the rewards received from paying homage
struct RewardsUnwrapper {
uint256[] tokenTypes;
address[] tokenAddresses;
uint256[] tokenIds;
uint256[] amounts;
}
// Struct used for tracking the structures that need to be burned
struct StructuresToBurn {
uint256 totalDestinations;
uint256 totalStructures;
uint256[] realmIds;
uint256[] structureIds;
uint256[] amounts;
}
// Emitted when a successful homage transaction occurs
event HomageResult(
uint256 homageId,
uint256 realmId,
uint256 structureId,
address adventurerAddress,
uint256 adventurerId,
uint256[] tokenTypes,
address[] tokenAddresses,
uint256[] tokenIds,
uint256[] amounts
);
// Monument configuration
struct MonumentHomageConfig {
uint64 minimumLevel;
uint256 animaCost;
uint64 epochCost;
uint64 rewardPoolId;
uint256 animaCapacity;
}
//=======================================
// Constants
//=======================================
uint256 private constant EPOCH_DURATION = 1 days;
uint256 private constant EPOCH_OFFSET = 12 hours;
//=======================================
// Immutables
//=======================================
Monument public immutable MONUMENT;
IAdventurerGateway public immutable GATEWAY;
Anima public immutable ANIMA;
IBatchBurnableStaker public immutable BATCH_STAKER;
ILastActionMarkerStorage public immutable ACTION_STORAGE;
IAdventurerData public immutable ADVENTURER_DATA;
IRewardsPool public immutable REWARDS_POOL;
//=======================================
// References
//=======================================
IResource public RESOURCE;
//=======================================
// Mappings
//=======================================
mapping(uint256 => MonumentHomageConfig) public HOMAGE_CONFIG;
//=======================================
// Uints
//=======================================
uint256 public nextHomageId;
uint256 MINIMUM_GAS_PER_HOMAGE;
uint256 public MAX_HOMAGE_POINTS;
//=======================================
// Addresses
//=======================================
address public BURN_TARGET;
//=======================================
// Constructor
//=======================================
// The constructor for the MonumentHomage contract.
// It initializes the contract with necessary contract addresses for inter-contract interactions,
// sets the maximum number of homage points an adventurer can have, and defines the minimum gas required for paying homage.
constructor(
address _manager,
address _structureStaker,
address _actionStorage,
address _monument,
address _gateway,
address _resource,
address _adventurerData,
address _anima,
address _rewardsPool
) ManagerModifier(_manager) {
BATCH_STAKER = IBatchBurnableStaker(_structureStaker);
ACTION_STORAGE = ILastActionMarkerStorage(_actionStorage);
MONUMENT = Monument(_monument);
GATEWAY = IAdventurerGateway(_gateway);
RESOURCE = IResource(_resource);
ADVENTURER_DATA = IAdventurerData(_adventurerData);
ANIMA = Anima(_anima);
REWARDS_POOL = IRewardsPool(_rewardsPool);
MAX_HOMAGE_POINTS = 7;
MINIMUM_GAS_PER_HOMAGE = 300000;
}
//=======================================
// Functions
//=======================================
// The payHomage function allows an adventurer to pay homage to a monument.
// This function checks that the adventurer owns the adventurer token, validates the adventurer's address,
// checks that the adventurer is allowed to pay homage (based on the last time they paid homage),
// increases the amount of Anima Capacity in the realm, burns the necessary structures, and burns Anima from the adventurer.
// The function also emits a HomageResult event for each homage paid and emits rewards for the Adventurer (usually in the form of lootboxes).
function payHomage(
HomageRequest[] calldata _requests
) external nonReentrant whenNotPaused {
// Ensure homage is paid directly by an adventurer, not through another contract
require(
msg.sender == tx.origin,
"MonumentHomage: Homage is not allowed through another contract"
);
// Prepare a batch of structures to burn
StructuresToBurn memory structuresToBurn;
uint256 i;
for (i = 0; i < _requests.length; i++) {
HomageRequest calldata request = _requests[i];
structuresToBurn.totalDestinations += request.destinations.length;
for (uint256 j = 0; j < request.destinations.length; j++) {
structuresToBurn.totalStructures += request
.destinations[j]
.structureAmount;
}
}
// Allocate memory for storing realms and structures to burn
structuresToBurn.realmIds = new uint256[](
structuresToBurn.totalDestinations
);
structuresToBurn.structureIds = new uint256[](
structuresToBurn.totalDestinations
);
structuresToBurn.amounts = new uint256[](
structuresToBurn.totalDestinations
);
// Ensure enough gas is available to prevent manipulation of randomness
require(
gasleft() > (MINIMUM_GAS_PER_HOMAGE * structuresToBurn.totalStructures),
"MonumentHomage: Manual gas reduction is not allowed"
);
// Start the homage process, prepare intermediate variables
uint256 currentEpoch = block.timestamp.toEpoch(
EPOCH_DURATION,
EPOCH_OFFSET
);
uint256 totalAnima;
uint256 destinationIterator;
uint256 destinationCost;
uint256 homageIndex = nextHomageId;
uint256 randomBase = Random.startRandomBase(
uint256(uint160(address(this))),
nextHomageId
);
// Process each homage request
for (i = 0; i < _requests.length; i++) {
HomageRequest calldata request = _requests[i];
address owner = ERC721(request.adventurerAddress).ownerOf(
request.adventurerId
);
// Ensure the homage is paid by the adventurer owner and that the adventurer is eligible to pay homage
require(owner == msg.sender, "MonumentHomage: You do not own Adventurer");
GATEWAY.checkAddress(request.adventurerAddress, request.proofs);
// Calculate the number of epochs since the last homage
uint256 epochsSinceLastHomage = _getHomagePoints(
currentEpoch,
request.adventurerAddress,
request.adventurerId
);
// Process each destination for the homage
for (uint256 j = 0; j < request.destinations.length; j++) {
HomageDestination calldata destination = request.destinations[j];
MonumentHomageConfig storage homageConfig = HOMAGE_CONFIG[
destination.structureId
];
require(
homageConfig.animaCost > 0,
"MonumentHomage: Structure not configured"
);
destinationCost = destination.structureAmount * homageConfig.epochCost;
// Ensure the adventurer has enough homage points (epochs since last homage)
require(
epochsSinceLastHomage >= destinationCost,
"MonumentHomage: Adventurer is already paid homage this epoch"
);
// Ensure the adventurer's level is high enough to pay homage
require(
ADVENTURER_DATA.aov(
request.adventurerAddress,
request.adventurerId,
traits.ADVENTURER_TRAIT_LEVEL
) >= homageConfig.minimumLevel,
"MonumentHomage: Adventurer can't pay homage to this monument, transcendence level too low"
);
// Subtract this destination's cost from remaining homage points
epochsSinceLastHomage -= destinationCost;
// Add to the total anima cost for the homage
totalAnima += homageConfig.animaCost * destination.structureAmount;
// Add the anima capacity to the realm
RESOURCE.add(
destination.realmId,
resources.ANIMA_CAPACITY,
homageConfig.animaCapacity * destination.structureAmount
);
// Save the details of the structures to be burnt later
structuresToBurn.realmIds[destinationIterator] = destination.realmId;
structuresToBurn.structureIds[destinationIterator] = destination
.structureId;
structuresToBurn.amounts[destinationIterator] = destination
.structureAmount;
// Increment destinationIterator
destinationIterator++;
// Dispense rewards for each structure in the homage
for (uint256 k = 0; k < destination.structureAmount; k++) {
// Dispense rewards
DispensedRewards memory dispensedRewards = REWARDS_POOL
.dispenseRewards(homageConfig.rewardPoolId, randomBase, msg.sender);
// Update random base for the next reward
randomBase = dispensedRewards.nextRandomBase;
// Emit event for the dispensed rewards
_emitRewards(
dispensedRewards,
homageIndex++,
destination.realmId,
destination.structureId,
request.adventurerAddress,
request.adventurerId
);
}
}
// Mark the last pay homage time for the adventurer
ACTION_STORAGE.setActionMarker(
request.adventurerAddress,
request.adventurerId,
ACTION_ADVENTURER_HOMAGE,
block.timestamp
);
}
nextHomageId = homageIndex;
// Burn the structures in the realms as part of the homage
BATCH_STAKER.burnBatchFor(
address(MONUMENT),
structuresToBurn.realmIds,
structuresToBurn.structureIds,
structuresToBurn.amounts
);
// Burn the total anima cost from the adventurer
ANIMA.burnFrom(msg.sender, totalAnima);
}
// The _emitRewards function emits the HomageResult event with the rewards dispensed to the adventurer.
// It creates an array of the dispensed rewards and includes them in the HomageResult event.
function _emitRewards(
DispensedRewards memory dispensedRewards,
uint256 homageIndex,
uint256 realmId,
uint256 structureId,
address advAddress,
uint256 advId
) internal {
RewardsUnwrapper memory emittedRewards;
emittedRewards.tokenTypes = new uint256[](dispensedRewards.rewards.length);
emittedRewards.tokenAddresses = new address[](
dispensedRewards.rewards.length
);
emittedRewards.tokenIds = new uint256[](dispensedRewards.rewards.length);
emittedRewards.amounts = new uint256[](dispensedRewards.rewards.length);
for (uint i = 0; i < emittedRewards.tokenTypes.length; i++) {
DispensedReward memory reward = dispensedRewards.rewards[i];
emittedRewards.tokenTypes[i] = (uint256)(reward.tokenType);
emittedRewards.tokenAddresses[i] = reward.token;
emittedRewards.tokenIds[i] = reward.tokenId;
emittedRewards.amounts[i] = reward.amount;
}
emit HomageResult(
homageIndex,
realmId,
structureId,
advAddress,
advId,
emittedRewards.tokenTypes,
emittedRewards.tokenAddresses,
emittedRewards.tokenIds,
emittedRewards.amounts
);
}
//=======================================
// Views
//=======================================
// The getEligibleStructureAmounts function returns the amounts of each structure that the Monument contract is allowed to burn.
// It fetches the staker balance for each structure for the Monument contract.
function getEligibleStructureAmounts(
uint256[] calldata _realmIds,
uint256[] calldata _tokenIds
) external view returns (uint256[] memory) {
uint256[] memory result = new uint256[](_realmIds.length);
for (uint256 i = 0; i < _realmIds.length; i++) {
result[i] = BATCH_STAKER.stakerBalance(
_realmIds[i],
address(MONUMENT),
_tokenIds[i]
);
}
return result;
}
// The getAdventurerHomagePoints function returns the number of homage points each adventurer has.
// It calculates the number of epochs since each adventurer's last action and returns the smaller of that number and the maximum number of homage points.
function getAdventurerHomagePoints(
address[] calldata _addresses,
uint256[] calldata _adventurerIds
) external view override returns (uint256[] memory result) {
uint256 currentEpoch = block.timestamp.toEpoch(
EPOCH_DURATION,
EPOCH_OFFSET
);
result = new uint256[](_addresses.length);
for (uint256 i = 0; i < _addresses.length; i++) {
result[i] = _getHomagePoints(
currentEpoch,
_addresses[i],
_adventurerIds[i]
);
}
}
function _getHomagePoints(
uint256 _epoch,
address _address,
uint256 _tokenId
) internal view returns (uint256) {
uint256 epochsSinceLastAction = _epoch -
ACTION_STORAGE
.getActionMarker(_address, _tokenId, ACTION_ADVENTURER_HOMAGE)
.toEpoch(EPOCH_DURATION, EPOCH_OFFSET);
return
epochsSinceLastAction > MAX_HOMAGE_POINTS
? MAX_HOMAGE_POINTS
: epochsSinceLastAction;
}
//=======================================
// Admin
//=======================================
// The configureStructures function allows the admin to configure the homage costs and rewards for each structure.
// It sets the minimum level, Anima cost, epoch cost, reward pool ID, and Anima capacity for each structure.
function configureStructures(
uint256[] calldata _tokenIds,
uint64[] calldata _minimumLevels,
uint256[] calldata _animaCosts,
uint64[] calldata _epochCosts,
uint64[] calldata _tokenIdRewardPoolIds,
uint256[] calldata _animaCapacity
) public onlyAdmin {
require(_tokenIds.length == _minimumLevels.length);
require(_tokenIds.length == _epochCosts.length);
require(_tokenIds.length == _animaCosts.length);
require(_tokenIds.length == _tokenIdRewardPoolIds.length);
for (uint256 i = 0; i < _tokenIds.length; i++) {
HOMAGE_CONFIG[_tokenIds[i]] = MonumentHomageConfig(
_minimumLevels[i],
_animaCosts[i],
_epochCosts[i],
_tokenIdRewardPoolIds[i],
_animaCapacity[i]
);
}
}
// Set minimum gas required (per lootbox)
function updateMinimumGas(uint256 _minimumGas) external onlyAdmin {
MINIMUM_GAS_PER_HOMAGE = _minimumGas;
}
// Set maximum number of epochs that the Adventurer can stack
function updateMaxHomagePoints(uint256 _maxHomage) external onlyAdmin {
MAX_HOMAGE_POINTS = _maxHomage;
}
// Set maximum number of epochs that the Adventurer can stack
function updateResourceStorage(address _resource) external onlyAdmin {
RESOURCE = IResource(_resource);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.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 Pausable is Context {
/**
* @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.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
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());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `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 memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - 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[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* 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 _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 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;
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner or approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_safeTransfer(from, to, tokenId, data);
}
/**
* @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.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _ownerOf(tokenId) != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId, 1);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId, 1);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256, /* firstTokenId */
uint256 batchSize
) internal virtual {
if (batchSize > 1) {
if (from != address(0)) {
_balances[from] -= batchSize;
}
if (to != address(0)) {
_balances[to] += batchSize;
}
}
}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @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 (last updated v4.8.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 have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the 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);
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// 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 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;
}
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; uint256 constant ACTION_ADVENTURER_HOMAGE = 1001;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "../Manager/ManagerModifier.sol";
interface ILastActionMarkerStorage {
function setActionMarker(
address _tokenAddress,
uint256 _tokenId,
uint256 _action,
uint256 _marker
) external;
function getActionMarker(
address _tokenAddress,
uint256 _tokenId,
uint256 _action
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IAdventurerData {
function initData(
address[] calldata _addresses,
uint256[] calldata _ids,
bytes32[][] calldata _proofs,
uint256[] calldata _professions,
uint256[][] calldata _points
) external;
function baseProperties(
address _addr,
uint256 _id,
uint256 _start,
uint256 _end
) external view returns (uint256[] memory);
function aovProperties(
address _addr,
uint256 _id,
uint256 _start,
uint256 _end
) external view returns (uint256[] memory);
function extensionProperties(
address _addr,
uint256 _id,
uint256 _start,
uint256 _end
) external view returns (uint256[] memory);
function createFor(
address _addr,
uint256 _id,
uint256[] calldata _points
) external;
function createFor(address _addr, uint256 _id, uint256 _archetype) external;
function addToBase(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function updateBase(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function removeFromBase(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function addToAov(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function updateAov(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function removeFromAov(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function addToExtension(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function updateExtension(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function removeFromExtension(
address _addr,
uint256 _id,
uint256 _prop,
uint256 _val
) external;
function base(
address _addr,
uint256 _id,
uint256 _prop
) external view returns (uint256);
function aov(
address _addr,
uint256 _id,
uint256 _prop
) external view returns (uint256);
function extension(
address _addr,
uint256 _id,
uint256 _prop
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IAdventurerGateway {
function checkAddress(address _addr, bytes32[] calldata _proof) external view;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
library traits {
// List of Adventurer traits
// Not using an enum for future proofing and we already have some non-character
// traits that have the same int values like Realm resources, etc
uint256 public constant ADVENTURER_TRAIT_LEVEL = 0;
uint256 public constant ADVENTURER_TRAIT_XP = 1;
uint256 public constant ADVENTURER_TRAIT_STRENGTH = 2;
uint256 public constant ADVENTURER_TRAIT_DEXTERITY = 3;
uint256 public constant ADVENTURER_TRAIT_CONSTITUTION = 4;
uint256 public constant ADVENTURER_TRAIT_INTELLIGENCE = 5;
uint256 public constant ADVENTURER_TRAIT_WISDOM = 6;
uint256 public constant ADVENTURER_TRAIT_CHARISMA = 7;
uint256 public constant ADVENTURER_TRAIT_HP = 8;
function traitNames() public pure returns (string[9] memory) {
return [
"Level",
"XP",
"Strength",
"Dexterity",
"Constitution",
"Intelligence",
"Wisdom",
"Charisma",
"HP"
];
}
function traitName(uint256 traitId) public pure returns (string memory) {
return traitNames()[traitId];
}
struct TraitBonus {
uint256 traitId;
uint256 traitValue;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "../Bound/IERC20Bound.sol";
import "./IAnima.sol";
import "../Manager/ManagerModifier.sol";
contract Anima is
IAnima,
ERC20,
ERC20Burnable,
ManagerModifier,
ReentrancyGuard,
Pausable
{
//=======================================
// Immutables
//=======================================
IERC20Bound public immutable BOUND;
uint256 public immutable CAP;
//=======================================
// Constructor
//=======================================
constructor(
address _manager,
address _bound,
uint256 _cap
) ERC20("Anima", "ANIMA") ManagerModifier(_manager) {
BOUND = IERC20Bound(_bound);
CAP = _cap;
}
//=======================================
// External
//=======================================
function mintFor(
address _for,
uint256 _amount
) external override onlyTokenMinter {
// Check amount doesn't exceed cap
require(ERC20.totalSupply() + _amount <= CAP, "Anima: Cap exceeded");
// Mint
_mint(_for, _amount);
}
//=======================================
// Admin
//=======================================
function pause() external onlyAdmin {
_pause();
}
function unpause() external onlyAdmin {
_unpause();
}
//=======================================
// Internal
//=======================================
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override {
// Call super
super._beforeTokenTransfer(from, to, amount);
// Check if sender is manager
if (!MANAGER.isManager(msg.sender, 0)) {
// Check if minting or burning
if (from != address(0) && to != address(0)) {
// Check if token is unbound
require(BOUND.isUnbound(address(this)), "Anima: Token not unbound");
}
}
// Check if contract is paused
require(!paused(), "Anima: Paused");
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IAnima is IERC20 {
function mintFor(address _for, uint256 _amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IBatchBurnableStaker {
function stakeBatchFor(
address _staker,
address _addr,
uint256[] calldata _realmIds,
uint256[] calldata _ids,
uint256[] calldata _amounts
) external;
function unstakeBatchFor(
address _staker,
address _addr,
uint256[] calldata _realmIds,
uint256[] calldata _ids,
uint256[] calldata _amounts
) external;
function burnBatchFor(
address _addr,
uint256[] calldata _realmIds,
uint256[] calldata _ids,
uint256[] calldata _amounts
) external;
function hasStaked(
uint256 _realmId,
address _addr,
uint256 _id,
uint256 _count
) external view returns (bool);
function stakerBalance(
uint256 _realmId,
address _addr,
uint256 _id
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IBatchBurnableStructure {
function burnBatchFor(
address _from,
uint256[] calldata ids,
uint256[] calldata amounts
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IERC20Bound {
function unbind(address _addresses) external;
function isUnbound(address _addr) external view returns (bool);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
//=======================================
// Enums
//=======================================
enum RewardTokenType {
ERC20,
ERC721,
ERC1155
}
//=======================================
// Structs
//=======================================
struct DispensedRewards {
uint256 nextRandomBase;
DispensedReward[] rewards;
}
struct DispensedReward {
RewardTokenType tokenType;
address token;
uint256 tokenId;
uint256 amount;
}
//=========================================================================================================================================
// Rewards will use 10^3 decimal point to calculate drop rates. This means if something has a drop rate of 100% it's represented as 100000
//=========================================================================================================================================
uint256 constant DECIMAL_POINT = 1000;
uint256 constant ONE_HUNDRED = 100 * DECIMAL_POINT;
//=======================================================================================================================================================
// Dispenser contract for rewards. Each RewardPool is divided into subpools (in case of lootboxes: for different rarities, or realm specific pools, etc).
//=======================================================================================================================================================
interface IRewardsPool {
//==============================================================================================================================
// Dispenses random rewards from the pool
//==============================================================================================================================
function dispenseRewards(
uint64 subPoolId,
uint256 randomNumberBase,
address receiver
) external returns (DispensedRewards memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IManager {
function isAdmin(address _addr) external view returns (bool);
function isManager(address _addr, uint256 _type) external view returns (bool);
function addManager(address _addr, uint256 _type) external;
function removeManager(address _addr, uint256 _type) external;
function addAdmin(address _addr) external;
function removeAdmin(address _addr) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "../Manager/IManager.sol";
abstract contract ManagerModifier {
//=======================================
// Immutables
//=======================================
IManager public immutable MANAGER;
//=======================================
// Constructor
//=======================================
constructor(address _manager) {
MANAGER = IManager(_manager);
}
//=======================================
// Modifiers
//=======================================
modifier onlyAdmin() {
require(MANAGER.isAdmin(msg.sender), "Manager: Not an Admin");
_;
}
modifier onlyManager() {
require(MANAGER.isManager(msg.sender, 0), "Manager: Not manager");
_;
}
modifier onlyMinter() {
require(MANAGER.isManager(msg.sender, 1), "Manager: Not minter");
_;
}
modifier onlyTokenMinter() {
require(MANAGER.isManager(msg.sender, 2), "Manager: Not token minter");
_;
}
modifier onlyBinder() {
require(MANAGER.isManager(msg.sender, 3), "Manager: Not binder");
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "../BatchStaker/IBatchBurnableStructure.sol";
interface IMonument is IBatchBurnableStructure {
function mintFor(address _for, uint256 _id, uint256 _amount) external;
function mintBatchFor(
address _for,
uint256[] calldata _ids,
uint256[] calldata _amounts
) external;
function burn(uint256 _id, uint256 _amount) external;
function burnBatch(
uint256[] calldata ids,
uint256[] calldata amounts
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IMonumentHomage {
struct StakedMonument {
uint256 tokenId;
uint256 amount;
}
struct HomageDestination {
uint256 realmId;
uint256 structureId;
uint256 structureAmount;
}
struct HomageRequest {
address adventurerAddress;
uint256 adventurerId;
bytes32[] proofs;
HomageDestination[] destinations;
}
function payHomage(HomageRequest[] calldata _requests) external;
function getEligibleStructureAmounts(
uint256[] calldata _realmIds,
uint256[] calldata _tokenIds
) external view returns (uint256[] calldata);
function getAdventurerHomagePoints(
address[] calldata _addresses,
uint256[] calldata _adventurerIds
) external view returns (uint256[] calldata);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../Manager/ManagerModifier.sol";
import "../BatchStaker/IBatchBurnableStructure.sol";
import "./IMonument.sol";
contract Monument is ERC1155, ReentrancyGuard, ManagerModifier, IMonument {
//=======================================
// Constructor
//=======================================
constructor(address _manager) ERC1155("") ManagerModifier(_manager) {}
//=======================================
// External
//=======================================
function mintFor(
address _for,
uint256 _id,
uint256 _amount
) external nonReentrant onlyMinter {
_mint(_for, _id, _amount, "");
}
function mintBatchFor(
address _for,
uint256[] calldata _ids,
uint256[] calldata _amounts
) external nonReentrant onlyMinter {
_mintBatch(_for, _ids, _amounts, "");
}
// TODO: do we need this?
function burnFor(
address _for,
uint256 _id,
uint256 _amount
) external nonReentrant onlyMinter {
_burn(_for, _id, _amount);
}
// TODO: do we need this?
function burnBatchFor(
address _for,
uint256[] calldata _ids,
uint256[] calldata _amounts
) external nonReentrant onlyMinter {
_burnBatch(_for, _ids, _amounts);
}
function burn(uint256 _id, uint256 _amount) external nonReentrant {
_burn(msg.sender, _id, _amount);
}
function burnBatch(
uint256[] calldata ids,
uint256[] calldata amounts
) external nonReentrant {
_burnBatch(msg.sender, ids, amounts);
}
//=======================================
// Admin
//=======================================
function setUri(string memory _uri) external onlyAdmin {
_setURI(_uri);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IRealm {
function balanceOf(address owner) external view returns (uint256);
function ownerOf(uint256 _realmId) external view returns (address owner);
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function isApprovedForAll(
address owner,
address operator
) external returns (bool);
function realmFeatures(
uint256 realmId,
uint256 index
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IResource {
function data(
uint256 _realmId,
uint256 _resourceId
) external view returns (uint256);
function add(uint256 _realmId, uint256 _resourceId, uint256 _amount) external;
function remove(
uint256 _realmId,
uint256 _resourceId,
uint256 _amount
) external;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
library resources {
// Season 1 resources
uint256 public constant MINERAL_DEPOSIT = 0;
uint256 public constant LAND_ABUNDANCE = 1;
uint256 public constant AQUATIC_RESOURCES = 2;
uint256 public constant ANCIENT_ARTIFACTS = 3;
// Staking capacities
uint256 public constant ANIMA_CAPACITY = 100;
}pragma solidity ^0.8.17;
// SPDX-License-Identifier: MIT
library Epoch {
// Converts a given timestamp to an epoch using the specified duration and offset.
// Example for battle timers resetting at noon UTC is: _duration = 1 days; _offset = 12 hours;
function toEpoch(
uint256 _timestamp,
uint256 _duration,
uint256 _offset
) internal pure returns (uint256) {
return (_timestamp + _offset) / _duration;
}
}// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.4.21 <0.9.0;
/**
* @title System level functionality
* @notice For use by contracts to interact with core L2-specific functionality.
* Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064.
*/
interface ArbSys {
/**
* @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)
* @return block number as int
*/
function arbBlockNumber() external view returns (uint256);
/**
* @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum)
* @return block hash
*/
function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);
/**
* @notice Gets the rollup's unique chain identifier
* @return Chain identifier as int
*/
function arbChainID() external view returns (uint256);
/**
* @notice Get internal version number identifying an ArbOS build
* @return version number as int
*/
function arbOSVersion() external view returns (uint256);
/**
* @notice Returns 0 since Nitro has no concept of storage gas
* @return uint 0
*/
function getStorageGasAvailable() external view returns (uint256);
/**
* @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract)
* @dev this call has been deprecated and may be removed in a future release
* @return true if current execution frame is not a call by another L2 contract
*/
function isTopLevelCall() external view returns (bool);
/**
* @notice map L1 sender contract address to its L2 alias
* @param sender sender address
* @param unused argument no longer used
* @return aliased sender address
*/
function mapL1SenderContractAddressToL2Alias(
address sender,
address unused
) external pure returns (address);
/**
* @notice check if the caller (of this caller of this) is an aliased L1 contract address
* @return true iff the caller's address is an alias for an L1 contract address
*/
function wasMyCallersAddressAliased() external view returns (bool);
/**
* @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing
* @return address of the caller's caller, without applying L1 contract address aliasing
*/
function myCallersAddressWithoutAliasing() external view returns (address);
/**
* @notice Send given amount of Eth to dest from sender.
* This is a convenience function, which is equivalent to calling sendTxToL1 with empty data.
* @param destination recipient address on L1
* @return unique identifier for this L2-to-L1 transaction.
*/
function withdrawEth(address destination) external payable returns (uint256);
/**
* @notice Send a transaction to L1
* @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data
* to a contract address without any code (as enforced by the Bridge contract).
* @param destination recipient address on L1
* @param data (optional) calldata for L1 contract call
* @return a unique identifier for this L2-to-L1 transaction.
*/
function sendTxToL1(
address destination,
bytes calldata data
) external payable returns (uint256);
/**
* @notice Get send Merkle tree state
* @return size number of sends in the history
* @return root root hash of the send history
* @return partials hashes of partial subtrees in the send history tree
*/
function sendMerkleTreeState()
external
view
returns (uint256 size, bytes32 root, bytes32[] memory partials);
/**
* @notice creates a send txn from L2 to L1
* @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf
*/
event L2ToL1Tx(
address caller,
address indexed destination,
uint256 indexed hash,
uint256 indexed position,
uint256 arbBlockNum,
uint256 ethBlockNum,
uint256 timestamp,
uint256 callvalue,
bytes data
);
/// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade
event L2ToL1Transaction(
address caller,
address indexed destination,
uint256 indexed uniqueId,
uint256 indexed batchNumber,
uint256 indexInBatch,
uint256 arbBlockNum,
uint256 ethBlockNum,
uint256 timestamp,
uint256 callvalue,
bytes data
);
/**
* @notice logs a merkle branch for proof synthesis
* @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event
* @param hash the merkle hash
* @param position = (level << 192) + leaf
*/
event SendMerkleUpdate(
uint256 indexed reserved,
bytes32 indexed hash,
uint256 indexed position
);
error InvalidBlockNumber(uint256 requested, uint256 current);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "./IArbSys.sol";
//=========================================================================================================================================
// We're trying to normalize all chances close to 100%, which is 100 000 with decimal point 10^3. Assuming this, we can get more "random"
// numbers by dividing the "random" number by this prime. To be honest most primes larger than 100% should work, but to be safe we'll
// use an order of magnitude higher (10^3) relative to the decimal point
// We're using uint256 (2^256 ~= 10^77), which means we're safe to derive 8 consecutive random numbers from each hash.
// If we, by any chance, run out of random numbers (hash being lower than the range) we can in turn
// use the remainder of the hash to regenerate a new random number.
// Example: assuming our hash function result would be 1132134687911000 (shorter number picked for explanation) and we're using
// % 100000 range for our drop chance. The first "random" number is 11000. We then divide 1000000011000 by the 100000037 prime,
// leaving us at 11321342. The second derived random number would be 11321342 % 100000 = 21342. 11321342/100000037 is in turn less than
// 100000037, so we'll instead regenerate a new hash using 11321342.
// Primes are used for additional safety, but we could just deal with the "range".
//=========================================================================================================================================
uint256 constant MIN_SAFE_NEXT_NUMBER_PRIME = 1000033;
uint256 constant HIGH_RANGE_PRIME_OFFSET = 13;
library Random {
function startRandomBase(
uint256 _highSalt,
uint256 _lowSalt
) internal view returns (uint256) {
return
uint256(
keccak256(
abi.encodePacked(
ArbSys(address(0x64)).arbBlockHash(
ArbSys(address(0x64)).arbBlockNumber() - 1
),
msg.sender,
_lowSalt,
_highSalt
)
)
);
}
function getNextRandom(
uint256 randomBase,
uint256 range
) internal view returns (uint256 random, uint256 nextBase) {
uint256 nextNumberSeparator = MIN_SAFE_NEXT_NUMBER_PRIME > range
? MIN_SAFE_NEXT_NUMBER_PRIME
: (range + HIGH_RANGE_PRIME_OFFSET);
uint256 nextBaseNumber = randomBase / nextNumberSeparator;
if (nextBaseNumber > nextNumberSeparator) {
return (randomBase % range, nextBaseNumber);
}
nextBaseNumber = uint256(
keccak256(
abi.encodePacked(
ArbSys(address(0x64)).arbBlockHash(
ArbSys(address(0x64)).arbBlockNumber() - 1
),
msg.sender,
randomBase,
range
)
)
);
return (nextBaseNumber % range, nextBaseNumber / nextNumberSeparator);
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_manager","type":"address"},{"internalType":"address","name":"_structureStaker","type":"address"},{"internalType":"address","name":"_actionStorage","type":"address"},{"internalType":"address","name":"_monument","type":"address"},{"internalType":"address","name":"_gateway","type":"address"},{"internalType":"address","name":"_resource","type":"address"},{"internalType":"address","name":"_adventurerData","type":"address"},{"internalType":"address","name":"_anima","type":"address"},{"internalType":"address","name":"_rewardsPool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"homageId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"realmId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"structureId","type":"uint256"},{"indexed":false,"internalType":"address","name":"adventurerAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"adventurerId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"tokenTypes","type":"uint256[]"},{"indexed":false,"internalType":"address[]","name":"tokenAddresses","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"HomageResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ACTION_STORAGE","outputs":[{"internalType":"contract ILastActionMarkerStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADVENTURER_DATA","outputs":[{"internalType":"contract IAdventurerData","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ANIMA","outputs":[{"internalType":"contract Anima","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BATCH_STAKER","outputs":[{"internalType":"contract IBatchBurnableStaker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BURN_TARGET","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GATEWAY","outputs":[{"internalType":"contract IAdventurerGateway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"HOMAGE_CONFIG","outputs":[{"internalType":"uint64","name":"minimumLevel","type":"uint64"},{"internalType":"uint256","name":"animaCost","type":"uint256"},{"internalType":"uint64","name":"epochCost","type":"uint64"},{"internalType":"uint64","name":"rewardPoolId","type":"uint64"},{"internalType":"uint256","name":"animaCapacity","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER","outputs":[{"internalType":"contract IManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_HOMAGE_POINTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MONUMENT","outputs":[{"internalType":"contract Monument","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESOURCE","outputs":[{"internalType":"contract IResource","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARDS_POOL","outputs":[{"internalType":"contract IRewardsPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint64[]","name":"_minimumLevels","type":"uint64[]"},{"internalType":"uint256[]","name":"_animaCosts","type":"uint256[]"},{"internalType":"uint64[]","name":"_epochCosts","type":"uint64[]"},{"internalType":"uint64[]","name":"_tokenIdRewardPoolIds","type":"uint64[]"},{"internalType":"uint256[]","name":"_animaCapacity","type":"uint256[]"}],"name":"configureStructures","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"},{"internalType":"uint256[]","name":"_adventurerIds","type":"uint256[]"}],"name":"getAdventurerHomagePoints","outputs":[{"internalType":"uint256[]","name":"result","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_realmIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"getEligibleStructureAmounts","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextHomageId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"adventurerAddress","type":"address"},{"internalType":"uint256","name":"adventurerId","type":"uint256"},{"internalType":"bytes32[]","name":"proofs","type":"bytes32[]"},{"components":[{"internalType":"uint256","name":"realmId","type":"uint256"},{"internalType":"uint256","name":"structureId","type":"uint256"},{"internalType":"uint256","name":"structureAmount","type":"uint256"}],"internalType":"struct IMonumentHomage.HomageDestination[]","name":"destinations","type":"tuple[]"}],"internalType":"struct IMonumentHomage.HomageRequest[]","name":"_requests","type":"tuple[]"}],"name":"payHomage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxHomage","type":"uint256"}],"name":"updateMaxHomagePoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimumGas","type":"uint256"}],"name":"updateMinimumGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_resource","type":"address"}],"name":"updateResourceStorage","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6101806040523480156200001257600080fd5b5060405162002715380380620027158339810160408190526200003591620000c1565b6001600160a01b039889166080526000805460ff1916905560018055968816610100529487166101205292861660a05290851660c052600280546001600160a01b031916918616919091179055831661014052821660e05216610160526007600655620493e06005556200017c565b80516001600160a01b0381168114620000bc57600080fd5b919050565b60008060008060008060008060006101208a8c031215620000e157600080fd5b620000ec8a620000a4565b9850620000fc60208b01620000a4565b97506200010c60408b01620000a4565b96506200011c60608b01620000a4565b95506200012c60808b01620000a4565b94506200013c60a08b01620000a4565b93506200014c60c08b01620000a4565b92506200015c60e08b01620000a4565b91506200016d6101008b01620000a4565b90509295985092959850929598565b60805160a05160c05160e051610100516101205161014051610160516124d162000244600039600081816101fe0152610dcb0152600081816103e80152610b010152600081816102c201528181610ead015261194301526000818161026101528181610f91015261151801526000818161028801526110340152600081816101d701526108ea0152600081816103b801528181610fbe01526115600152600081816101720152818161041f015281816110c40152818161116d015261165c01526124d16000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c806380c08107116100b8578063ad0409161161007c578063ad04091614610304578063b5e6e8b214610317578063b716890c146103a0578063dc40fe8c146103b3578063ea3b341d146103da578063fcac0892146103e357600080fd5b806380c081071461025c578063816738531461028357806399b7d8a4146102aa5780639cb8fa83146102bd578063a03b6d35146102e457600080fd5b8063338c5371116100ff578063338c5371146101d2578063482d3281146101f95780635c975abb146102205780636d0e43781461023657806376d2dfc51461024957600080fd5b8063011068061461013c5780631597fd1d146101515780631b2df8501461016d5780631fdfd757146101ac5780632b3ed84e146101bf575b600080fd5b61014f61014a366004611c9b565b61040a565b005b61015a60065481565b6040519081526020015b60405180910390f35b6101947f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610164565b61014f6101ba366004611cff565b6104bc565b600254610194906001600160a01b031681565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b60005460ff166040519015158152602001610164565b600754610194906001600160a01b031681565b61014f610257366004611c9b565b6110af565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b61014f6102b8366004611d40565b611158565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b6102f76102f2366004611e7d565b6113dc565b6040516101649190611f23565b6102f7610312366004611e7d565b6114c3565b610365610325366004611c9b565b600360208190526000918252604090912080546001820154600283015492909301546001600160401b03918216939280831692600160401b909104169085565b604080516001600160401b0396871681526020810195909552928516928401929092529092166060820152608081019190915260a001610164565b61014f6103ae366004611f55565b611647565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b61015a60045481565b6101947f000000000000000000000000000000000000000000000000000000000000000081565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa15801561046e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104929190611f72565b6104b75760405162461bcd60e51b81526004016104ae90611f94565b60405180910390fd5b600655565b6104c461170d565b6104cc611766565b3332146105415760405162461bcd60e51b815260206004820152603e60248201527f4d6f6e756d656e74486f6d6167653a20486f6d616765206973206e6f7420616c60448201527f6c6f776564207468726f75676820616e6f7468657220636f6e7472616374000060648201526084016104ae565b6105736040518060a0016040528060008152602001600081526020016060815260200160608152602001606081525090565b60005b82811015610643573684848381811061059157610591611fc3565b90506020028101906105a39190611fd9565b90506105b26060820182611ff9565b9050836000018181516105c59190612057565b90525060005b6105d86060830183611ff9565b905081101561062e576105ee6060830183611ff9565b828181106105fe576105fe611fc3565b90506060020160400135846020018181516106199190612057565b905250806106268161206a565b9150506105cb565b5050808061063b9061206a565b915050610576565b81516001600160401b0381111561065c5761065c612083565b604051908082528060200260200182016040528015610685578160200160208202803683370190505b50604083015281516001600160401b038111156106a4576106a4612083565b6040519080825280602002602001820160405280156106cd578160200160208202803683370190505b50606083015281516001600160401b038111156106ec576106ec612083565b604051908082528060200260200182016040528015610715578160200160208202803683370190505b506080830152602082015160055461072d9190612099565b5a116107975760405162461bcd60e51b815260206004820152603360248201527f4d6f6e756d656e74486f6d6167653a204d616e75616c206761732072656475636044820152721d1a5bdb881a5cc81b9bdd08185b1b1bddd959606a1b60648201526084016104ae565b60006107a9426201518061a8c06117ae565b60045490915060009081908190816107c130836117cd565b9050600096505b88871015610f6657368a8a898181106107e3576107e3611fc3565b90506020028101906107f59190611fd9565b905060006108066020830183611f55565b6040516331a9108f60e11b8152602084013560048201526001600160a01b039190911690636352211e90602401602060405180830381865afa158015610850573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087491906120b0565b90506001600160a01b03811633146108e05760405162461bcd60e51b815260206004820152602960248201527f4d6f6e756d656e74486f6d6167653a20596f7520646f206e6f74206f776e2041604482015268323b32b73a3ab932b960b91b60648201526084016104ae565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663417c530261091c6020850185611f55565b61092960408601866120cd565b6040518463ffffffff1660e01b815260040161094793929190612116565b60006040518083038186803b15801561095f57600080fd5b505afa158015610973573d6000803e3d6000fd5b506000925061099791508a905061098d6020860186611f55565b8560200135611903565b905060005b6109a96060850185611ff9565b9050811015610ea257366109c06060860186611ff9565b838181106109d0576109d0611fc3565b90506060020190506000600360008360200135815260200190815260200160002090506000816001015411610a585760405162461bcd60e51b815260206004820152602860248201527f4d6f6e756d656e74486f6d6167653a20537472756374757265206e6f7420636f6044820152671b999a59dd5c995960c21b60648201526084016104ae565b6002810154610a74906001600160401b03166040840135612099565b985088841015610aec5760405162461bcd60e51b815260206004820152603c60248201527f4d6f6e756d656e74486f6d6167653a20416476656e747572657220697320616c60448201527f7265616479207061696420686f6d61676520746869732065706f63680000000060648201526084016104ae565b80546001600160401b03166001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663220ae2c1610b3360208a018a611f55565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260208a0135602482015260006044820152606401602060405180830381865afa158015610b88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bac9190612160565b1015610c465760405162461bcd60e51b815260206004820152605960248201527f4d6f6e756d656e74486f6d6167653a20416476656e74757265722063616e277460448201527f2070617920686f6d61676520746f2074686973206d6f6e756d656e742c20747260648201527f616e7363656e64656e6365206c6576656c20746f6f206c6f7700000000000000608482015260a4016104ae565b610c508985612179565b935081604001358160010154610c669190612099565b610c70908c612057565b6002546003830154919c506001600160a01b03169063505fb46c90843590606490610ca090604088013590612099565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b158015610ce657600080fd5b505af1158015610cfa573d6000803e3d6000fd5b5050505081600001358e604001518b81518110610d1957610d19611fc3565b60200260200101818152505081602001358e606001518b81518110610d4057610d40611fc3565b60200260200101818152505081604001358e608001518b81518110610d6757610d67611fc3565b602090810291909101015289610d7c8161206a565b9a505060005b8260400135811015610e8c576002820154604051600162ab802760e01b03198152600160401b9091046001600160401b03166004820152602481018990523360448201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ff547fd9906064016000604051808303816000875af1158015610e1c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e449190810190612206565b805199509050610e79818b610e588161206a565b9c50863560208089013590610e6f908e018e611f55565b8d602001356119df565b5080610e848161206a565b915050610d82565b5050508080610e9a9061206a565b91505061099c565b506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016636b2b43f9610edf6020860186611f55565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602086013560248201526103e96044820152426064820152608401600060405180830381600087803b158015610f3857600080fd5b505af1158015610f4c573d6000803e3d6000fd5b505050505050508680610f5e9061206a565b9750506107c8565b60048281556040808a015160608b015160808c0151925163c98fab5f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169463c98fab5f94610fe8947f0000000000000000000000000000000000000000000000000000000000000000949093909201612336565b600060405180830381600087803b15801561100257600080fd5b505af1158015611016573d6000803e3d6000fd5b505060405163079cc67960e41b8152336004820152602481018890527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031692506379cc67909150604401600060405180830381600087803b15801561108257600080fd5b505af1158015611096573d6000803e3d6000fd5b5050505050505050505050506110ab60018055565b5050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015611113573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111379190611f72565b6111535760405162461bcd60e51b81526004016104ae90611f94565b600555565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156111bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e09190611f72565b6111fc5760405162461bcd60e51b81526004016104ae90611f94565b8a891461120857600080fd5b8a851461121457600080fd5b8a871461122057600080fd5b8a831461122c57600080fd5b60005b8b8110156113cd576040518060a001604052808c8c8481811061125457611254611fc3565b9050602002016020810190611269919061238b565b6001600160401b031681526020018a8a8481811061128957611289611fc3565b9050602002013581526020018888848181106112a7576112a7611fc3565b90506020020160208101906112bc919061238b565b6001600160401b031681526020018686848181106112dc576112dc611fc3565b90506020020160208101906112f1919061238b565b6001600160401b0316815260200184848481811061131157611311611fc3565b90506020020135815250600360008f8f8581811061133157611331611fc3565b602090810292909201358352508181019290925260409081016000208351815467ffffffffffffffff19166001600160401b039182161782559284015160018201559083015160028201805460608601519285166fffffffffffffffffffffffffffffffff1990911617600160401b929094169190910292909217909155608090910151600390910155806113c58161206a565b91505061122f565b50505050505050505050505050565b606060006113f0426201518061a8c06117ae565b9050846001600160401b0381111561140a5761140a612083565b604051908082528060200260200182016040528015611433578160200160208202803683370190505b50915060005b858110156114b95761148a8288888481811061145757611457611fc3565b905060200201602081019061146c9190611f55565b87878581811061147e5761147e611fc3565b90506020020135611903565b83828151811061149c5761149c611fc3565b6020908102919091010152806114b18161206a565b915050611439565b5050949350505050565b60606000846001600160401b038111156114df576114df612083565b604051908082528060200260200182016040528015611508578160200160208202803683370190505b50905060005b8581101561163d577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c84550e688888481811061155757611557611fc3565b905060200201357f000000000000000000000000000000000000000000000000000000000000000088888681811061159157611591611fc3565b6040516001600160e01b031960e088901b16815260048101959095526001600160a01b03909316602485015250602090910201356044820152606401602060405180830381865afa1580156115ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160e9190612160565b82828151811061162057611620611fc3565b6020908102919091010152806116358161206a565b91505061150e565b5095945050505050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf9190611f72565b6116eb5760405162461bcd60e51b81526004016104ae90611f94565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60026001540361175f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104ae565b6002600155565b60005460ff16156117ac5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016104ae565b565b6000826117bb8386612057565b6117c591906123b4565b949350505050565b600060646001600160a01b0316632b407a82600160646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611820573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118449190612160565b61184e9190612179565b6040518263ffffffff1660e01b815260040161186c91815260200190565b602060405180830381865afa158015611889573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ad9190612160565b6040805160208101929092526bffffffffffffffffffffffff193360601b169082015260548101839052607481018490526094016040516020818303038152906040528051906020012060001c90505b92915050565b6040516314cf79b160e01b81526001600160a01b038381166004830152602482018390526103e9604483015260009182916119b791620151809161a8c0917f0000000000000000000000000000000000000000000000000000000000000000909116906314cf79b190606401602060405180830381865afa15801561198c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b09190612160565b91906117ae565b6119c19086612179565b905060065481116119d257806119d6565b6006545b95945050505050565b611a0a6040518060800160405280606081526020016060815260200160608152602001606081525090565b8660200151516001600160401b03811115611a2757611a27612083565b604051908082528060200260200182016040528015611a50578160200160208202803683370190505b5081526020870151516001600160401b03811115611a7057611a70612083565b604051908082528060200260200182016040528015611a99578160200160208202803683370190505b5081602001819052508660200151516001600160401b03811115611abf57611abf612083565b604051908082528060200260200182016040528015611ae8578160200160208202803683370190505b5060408201526020870151516001600160401b03811115611b0b57611b0b612083565b604051908082528060200260200182016040528015611b34578160200160208202803683370190505b50606082015260005b815151811015611c3a57600088602001518281518110611b5f57611b5f611fc3565b6020026020010151905080600001516002811115611b7f57611b7f6123d6565b8351805184908110611b9357611b93611fc3565b602002602001018181525050806020015183602001518381518110611bba57611bba611fc3565b60200260200101906001600160a01b031690816001600160a01b031681525050806040015183604001518381518110611bf557611bf5611fc3565b602002602001018181525050806060015183606001518381518110611c1c57611c1c611fc3565b60209081029190910101525080611c328161206a565b915050611b3d565b507fda7f3de4ba96dd945547be667d35677e50eeac2a1a7f6cd8c93254fe3de9f27086868686868660000151876020015188604001518960600151604051611c8a999897969594939291906123ec565b60405180910390a150505050505050565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b5081356001600160401b03811115611cdd57600080fd5b6020830191508360208260051b8501011115611cf857600080fd5b9250929050565b60008060208385031215611d1257600080fd5b82356001600160401b03811115611d2857600080fd5b611d3485828601611cb4565b90969095509350505050565b60008060008060008060008060008060008060c08d8f031215611d6257600080fd5b6001600160401b038d351115611d7757600080fd5b611d848e8e358f01611cb4565b909c509a506001600160401b0360208e01351115611da157600080fd5b611db18e60208f01358f01611cb4565b909a5098506001600160401b0360408e01351115611dce57600080fd5b611dde8e60408f01358f01611cb4565b90985096506001600160401b0360608e01351115611dfb57600080fd5b611e0b8e60608f01358f01611cb4565b90965094506001600160401b0360808e01351115611e2857600080fd5b611e388e60808f01358f01611cb4565b90945092506001600160401b0360a08e01351115611e5557600080fd5b611e658e60a08f01358f01611cb4565b81935080925050509295989b509295989b509295989b565b60008060008060408587031215611e9357600080fd5b84356001600160401b0380821115611eaa57600080fd5b611eb688838901611cb4565b90965094506020870135915080821115611ecf57600080fd5b50611edc87828801611cb4565b95989497509550505050565b600081518084526020808501945080840160005b83811015611f1857815187529582019590820190600101611efc565b509495945050505050565b602081526000611f366020830184611ee8565b9392505050565b6001600160a01b0381168114611f5257600080fd5b50565b600060208284031215611f6757600080fd5b8135611f3681611f3d565b600060208284031215611f8457600080fd5b81518015158114611f3657600080fd5b60208082526015908201527426b0b730b3b2b91d102737ba1030b71020b236b4b760591b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60008235607e19833603018112611fef57600080fd5b9190910192915050565b6000808335601e1984360301811261201057600080fd5b8301803591506001600160401b0382111561202a57600080fd5b6020019150606081023603821315611cf857600080fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156118fd576118fd612041565b60006001820161207c5761207c612041565b5060010190565b634e487b7160e01b600052604160045260246000fd5b80820281158282048414176118fd576118fd612041565b6000602082840312156120c257600080fd5b8151611f3681611f3d565b6000808335601e198436030181126120e457600080fd5b8301803591506001600160401b038211156120fe57600080fd5b6020019150600581901b3603821315611cf857600080fd5b6001600160a01b0384168152604060208201819052810182905260006001600160fb1b0383111561214657600080fd5b8260051b8085606085013791909101606001949350505050565b60006020828403121561217257600080fd5b5051919050565b818103818111156118fd576118fd612041565b604080519081016001600160401b03811182821017156121ae576121ae612083565b60405290565b604051608081016001600160401b03811182821017156121ae576121ae612083565b604051601f8201601f191681016001600160401b03811182821017156121fe576121fe612083565b604052919050565b6000602080838503121561221957600080fd5b82516001600160401b038082111561223057600080fd5b8185019150604080838803121561224657600080fd5b61224e61218c565b83518152848401518381111561226357600080fd5b80850194505087601f85011261227857600080fd5b83518381111561228a5761228a612083565b612298868260051b016121d6565b818152868101945060079190911b8501860190898211156122b857600080fd5b948601945b81861015612324576080868b0312156122d65760008081fd5b6122de6121b4565b8651600381106122ee5760008081fd5b8152868801516122fd81611f3d565b818901528685015185820152606080880151908201528552608090950194938601936122bd565b95820195909552979650505050505050565b6001600160a01b038516815260806020820181905260009061235a90830186611ee8565b828103604084015261236c8186611ee8565b905082810360608401526123808185611ee8565b979650505050505050565b60006020828403121561239d57600080fd5b81356001600160401b0381168114611f3657600080fd5b6000826123d157634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fd5b60006101208b835260208b818501528a604085015260018060a01b03808b1660608601528960808601528260a08601526124288386018a611ee8565b85810360c08701528851808252838a0194509083019060005b8181101561245f578551841683529484019491840191600101612441565b505085810360e08701526124738189611ee8565b935050505082810361010084015261248b8185611ee8565b9c9b50505050505050505050505056fea26469706673582212209040a204935377a55385f1d9333671dbf9ffc351cf889a3b7cbaf6c7b264569b64736f6c634300081100330000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861000000000000000000000000eb55ae0113039f7d7001c43538c350f89aa3177900000000000000000000000039224dc1a5303151be7ccf1e9504aeb616f2f3e3000000000000000000000000a56aa79eef0651a0d04b00da4f6263bcec8411840000000000000000000000009a9bbffe07ea36295a26b54379596b6d25234dc3000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f57000000000000000000000000c9797a6be31f052cdfbdcc7264005c1eea0f69b9000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f00000000000000000000000045c9e1055d6f57711e172133e22e707e8441078a
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806380c08107116100b8578063ad0409161161007c578063ad04091614610304578063b5e6e8b214610317578063b716890c146103a0578063dc40fe8c146103b3578063ea3b341d146103da578063fcac0892146103e357600080fd5b806380c081071461025c578063816738531461028357806399b7d8a4146102aa5780639cb8fa83146102bd578063a03b6d35146102e457600080fd5b8063338c5371116100ff578063338c5371146101d2578063482d3281146101f95780635c975abb146102205780636d0e43781461023657806376d2dfc51461024957600080fd5b8063011068061461013c5780631597fd1d146101515780631b2df8501461016d5780631fdfd757146101ac5780632b3ed84e146101bf575b600080fd5b61014f61014a366004611c9b565b61040a565b005b61015a60065481565b6040519081526020015b60405180910390f35b6101947f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b5825286181565b6040516001600160a01b039091168152602001610164565b61014f6101ba366004611cff565b6104bc565b600254610194906001600160a01b031681565b6101947f0000000000000000000000009a9bbffe07ea36295a26b54379596b6d25234dc381565b6101947f00000000000000000000000045c9e1055d6f57711e172133e22e707e8441078a81565b60005460ff166040519015158152602001610164565b600754610194906001600160a01b031681565b61014f610257366004611c9b565b6110af565b6101947f000000000000000000000000eb55ae0113039f7d7001c43538c350f89aa3177981565b6101947f000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f81565b61014f6102b8366004611d40565b611158565b6101947f00000000000000000000000039224dc1a5303151be7ccf1e9504aeb616f2f3e381565b6102f76102f2366004611e7d565b6113dc565b6040516101649190611f23565b6102f7610312366004611e7d565b6114c3565b610365610325366004611c9b565b600360208190526000918252604090912080546001820154600283015492909301546001600160401b03918216939280831692600160401b909104169085565b604080516001600160401b0396871681526020810195909552928516928401929092529092166060820152608081019190915260a001610164565b61014f6103ae366004611f55565b611647565b6101947f000000000000000000000000a56aa79eef0651a0d04b00da4f6263bcec84118481565b61015a60045481565b6101947f000000000000000000000000c9797a6be31f052cdfbdcc7264005c1eea0f69b981565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa15801561046e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104929190611f72565b6104b75760405162461bcd60e51b81526004016104ae90611f94565b60405180910390fd5b600655565b6104c461170d565b6104cc611766565b3332146105415760405162461bcd60e51b815260206004820152603e60248201527f4d6f6e756d656e74486f6d6167653a20486f6d616765206973206e6f7420616c60448201527f6c6f776564207468726f75676820616e6f7468657220636f6e7472616374000060648201526084016104ae565b6105736040518060a0016040528060008152602001600081526020016060815260200160608152602001606081525090565b60005b82811015610643573684848381811061059157610591611fc3565b90506020028101906105a39190611fd9565b90506105b26060820182611ff9565b9050836000018181516105c59190612057565b90525060005b6105d86060830183611ff9565b905081101561062e576105ee6060830183611ff9565b828181106105fe576105fe611fc3565b90506060020160400135846020018181516106199190612057565b905250806106268161206a565b9150506105cb565b5050808061063b9061206a565b915050610576565b81516001600160401b0381111561065c5761065c612083565b604051908082528060200260200182016040528015610685578160200160208202803683370190505b50604083015281516001600160401b038111156106a4576106a4612083565b6040519080825280602002602001820160405280156106cd578160200160208202803683370190505b50606083015281516001600160401b038111156106ec576106ec612083565b604051908082528060200260200182016040528015610715578160200160208202803683370190505b506080830152602082015160055461072d9190612099565b5a116107975760405162461bcd60e51b815260206004820152603360248201527f4d6f6e756d656e74486f6d6167653a204d616e75616c206761732072656475636044820152721d1a5bdb881a5cc81b9bdd08185b1b1bddd959606a1b60648201526084016104ae565b60006107a9426201518061a8c06117ae565b60045490915060009081908190816107c130836117cd565b9050600096505b88871015610f6657368a8a898181106107e3576107e3611fc3565b90506020028101906107f59190611fd9565b905060006108066020830183611f55565b6040516331a9108f60e11b8152602084013560048201526001600160a01b039190911690636352211e90602401602060405180830381865afa158015610850573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087491906120b0565b90506001600160a01b03811633146108e05760405162461bcd60e51b815260206004820152602960248201527f4d6f6e756d656e74486f6d6167653a20596f7520646f206e6f74206f776e2041604482015268323b32b73a3ab932b960b91b60648201526084016104ae565b6001600160a01b037f0000000000000000000000009a9bbffe07ea36295a26b54379596b6d25234dc31663417c530261091c6020850185611f55565b61092960408601866120cd565b6040518463ffffffff1660e01b815260040161094793929190612116565b60006040518083038186803b15801561095f57600080fd5b505afa158015610973573d6000803e3d6000fd5b506000925061099791508a905061098d6020860186611f55565b8560200135611903565b905060005b6109a96060850185611ff9565b9050811015610ea257366109c06060860186611ff9565b838181106109d0576109d0611fc3565b90506060020190506000600360008360200135815260200190815260200160002090506000816001015411610a585760405162461bcd60e51b815260206004820152602860248201527f4d6f6e756d656e74486f6d6167653a20537472756374757265206e6f7420636f6044820152671b999a59dd5c995960c21b60648201526084016104ae565b6002810154610a74906001600160401b03166040840135612099565b985088841015610aec5760405162461bcd60e51b815260206004820152603c60248201527f4d6f6e756d656e74486f6d6167653a20416476656e747572657220697320616c60448201527f7265616479207061696420686f6d61676520746869732065706f63680000000060648201526084016104ae565b80546001600160401b03166001600160a01b037f000000000000000000000000c9797a6be31f052cdfbdcc7264005c1eea0f69b91663220ae2c1610b3360208a018a611f55565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260208a0135602482015260006044820152606401602060405180830381865afa158015610b88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bac9190612160565b1015610c465760405162461bcd60e51b815260206004820152605960248201527f4d6f6e756d656e74486f6d6167653a20416476656e74757265722063616e277460448201527f2070617920686f6d61676520746f2074686973206d6f6e756d656e742c20747260648201527f616e7363656e64656e6365206c6576656c20746f6f206c6f7700000000000000608482015260a4016104ae565b610c508985612179565b935081604001358160010154610c669190612099565b610c70908c612057565b6002546003830154919c506001600160a01b03169063505fb46c90843590606490610ca090604088013590612099565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b158015610ce657600080fd5b505af1158015610cfa573d6000803e3d6000fd5b5050505081600001358e604001518b81518110610d1957610d19611fc3565b60200260200101818152505081602001358e606001518b81518110610d4057610d40611fc3565b60200260200101818152505081604001358e608001518b81518110610d6757610d67611fc3565b602090810291909101015289610d7c8161206a565b9a505060005b8260400135811015610e8c576002820154604051600162ab802760e01b03198152600160401b9091046001600160401b03166004820152602481018990523360448201526000907f00000000000000000000000045c9e1055d6f57711e172133e22e707e8441078a6001600160a01b03169063ff547fd9906064016000604051808303816000875af1158015610e1c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e449190810190612206565b805199509050610e79818b610e588161206a565b9c50863560208089013590610e6f908e018e611f55565b8d602001356119df565b5080610e848161206a565b915050610d82565b5050508080610e9a9061206a565b91505061099c565b506001600160a01b037f00000000000000000000000039224dc1a5303151be7ccf1e9504aeb616f2f3e316636b2b43f9610edf6020860186611f55565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602086013560248201526103e96044820152426064820152608401600060405180830381600087803b158015610f3857600080fd5b505af1158015610f4c573d6000803e3d6000fd5b505050505050508680610f5e9061206a565b9750506107c8565b60048281556040808a015160608b015160808c0151925163c98fab5f60e01b81526001600160a01b037f000000000000000000000000eb55ae0113039f7d7001c43538c350f89aa31779169463c98fab5f94610fe8947f000000000000000000000000a56aa79eef0651a0d04b00da4f6263bcec841184949093909201612336565b600060405180830381600087803b15801561100257600080fd5b505af1158015611016573d6000803e3d6000fd5b505060405163079cc67960e41b8152336004820152602481018890527f000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f6001600160a01b031692506379cc67909150604401600060405180830381600087803b15801561108257600080fd5b505af1158015611096573d6000803e3d6000fd5b5050505050505050505050506110ab60018055565b5050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015611113573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111379190611f72565b6111535760405162461bcd60e51b81526004016104ae90611f94565b600555565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156111bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e09190611f72565b6111fc5760405162461bcd60e51b81526004016104ae90611f94565b8a891461120857600080fd5b8a851461121457600080fd5b8a871461122057600080fd5b8a831461122c57600080fd5b60005b8b8110156113cd576040518060a001604052808c8c8481811061125457611254611fc3565b9050602002016020810190611269919061238b565b6001600160401b031681526020018a8a8481811061128957611289611fc3565b9050602002013581526020018888848181106112a7576112a7611fc3565b90506020020160208101906112bc919061238b565b6001600160401b031681526020018686848181106112dc576112dc611fc3565b90506020020160208101906112f1919061238b565b6001600160401b0316815260200184848481811061131157611311611fc3565b90506020020135815250600360008f8f8581811061133157611331611fc3565b602090810292909201358352508181019290925260409081016000208351815467ffffffffffffffff19166001600160401b039182161782559284015160018201559083015160028201805460608601519285166fffffffffffffffffffffffffffffffff1990911617600160401b929094169190910292909217909155608090910151600390910155806113c58161206a565b91505061122f565b50505050505050505050505050565b606060006113f0426201518061a8c06117ae565b9050846001600160401b0381111561140a5761140a612083565b604051908082528060200260200182016040528015611433578160200160208202803683370190505b50915060005b858110156114b95761148a8288888481811061145757611457611fc3565b905060200201602081019061146c9190611f55565b87878581811061147e5761147e611fc3565b90506020020135611903565b83828151811061149c5761149c611fc3565b6020908102919091010152806114b18161206a565b915050611439565b5050949350505050565b60606000846001600160401b038111156114df576114df612083565b604051908082528060200260200182016040528015611508578160200160208202803683370190505b50905060005b8581101561163d577f000000000000000000000000eb55ae0113039f7d7001c43538c350f89aa317796001600160a01b031663c84550e688888481811061155757611557611fc3565b905060200201357f000000000000000000000000a56aa79eef0651a0d04b00da4f6263bcec84118488888681811061159157611591611fc3565b6040516001600160e01b031960e088901b16815260048101959095526001600160a01b03909316602485015250602090910201356044820152606401602060405180830381865afa1580156115ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160e9190612160565b82828151811061162057611620611fc3565b6020908102919091010152806116358161206a565b91505061150e565b5095945050505050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf9190611f72565b6116eb5760405162461bcd60e51b81526004016104ae90611f94565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60026001540361175f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104ae565b6002600155565b60005460ff16156117ac5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016104ae565b565b6000826117bb8386612057565b6117c591906123b4565b949350505050565b600060646001600160a01b0316632b407a82600160646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611820573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118449190612160565b61184e9190612179565b6040518263ffffffff1660e01b815260040161186c91815260200190565b602060405180830381865afa158015611889573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ad9190612160565b6040805160208101929092526bffffffffffffffffffffffff193360601b169082015260548101839052607481018490526094016040516020818303038152906040528051906020012060001c90505b92915050565b6040516314cf79b160e01b81526001600160a01b038381166004830152602482018390526103e9604483015260009182916119b791620151809161a8c0917f00000000000000000000000039224dc1a5303151be7ccf1e9504aeb616f2f3e3909116906314cf79b190606401602060405180830381865afa15801561198c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b09190612160565b91906117ae565b6119c19086612179565b905060065481116119d257806119d6565b6006545b95945050505050565b611a0a6040518060800160405280606081526020016060815260200160608152602001606081525090565b8660200151516001600160401b03811115611a2757611a27612083565b604051908082528060200260200182016040528015611a50578160200160208202803683370190505b5081526020870151516001600160401b03811115611a7057611a70612083565b604051908082528060200260200182016040528015611a99578160200160208202803683370190505b5081602001819052508660200151516001600160401b03811115611abf57611abf612083565b604051908082528060200260200182016040528015611ae8578160200160208202803683370190505b5060408201526020870151516001600160401b03811115611b0b57611b0b612083565b604051908082528060200260200182016040528015611b34578160200160208202803683370190505b50606082015260005b815151811015611c3a57600088602001518281518110611b5f57611b5f611fc3565b6020026020010151905080600001516002811115611b7f57611b7f6123d6565b8351805184908110611b9357611b93611fc3565b602002602001018181525050806020015183602001518381518110611bba57611bba611fc3565b60200260200101906001600160a01b031690816001600160a01b031681525050806040015183604001518381518110611bf557611bf5611fc3565b602002602001018181525050806060015183606001518381518110611c1c57611c1c611fc3565b60209081029190910101525080611c328161206a565b915050611b3d565b507fda7f3de4ba96dd945547be667d35677e50eeac2a1a7f6cd8c93254fe3de9f27086868686868660000151876020015188604001518960600151604051611c8a999897969594939291906123ec565b60405180910390a150505050505050565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b5081356001600160401b03811115611cdd57600080fd5b6020830191508360208260051b8501011115611cf857600080fd5b9250929050565b60008060208385031215611d1257600080fd5b82356001600160401b03811115611d2857600080fd5b611d3485828601611cb4565b90969095509350505050565b60008060008060008060008060008060008060c08d8f031215611d6257600080fd5b6001600160401b038d351115611d7757600080fd5b611d848e8e358f01611cb4565b909c509a506001600160401b0360208e01351115611da157600080fd5b611db18e60208f01358f01611cb4565b909a5098506001600160401b0360408e01351115611dce57600080fd5b611dde8e60408f01358f01611cb4565b90985096506001600160401b0360608e01351115611dfb57600080fd5b611e0b8e60608f01358f01611cb4565b90965094506001600160401b0360808e01351115611e2857600080fd5b611e388e60808f01358f01611cb4565b90945092506001600160401b0360a08e01351115611e5557600080fd5b611e658e60a08f01358f01611cb4565b81935080925050509295989b509295989b509295989b565b60008060008060408587031215611e9357600080fd5b84356001600160401b0380821115611eaa57600080fd5b611eb688838901611cb4565b90965094506020870135915080821115611ecf57600080fd5b50611edc87828801611cb4565b95989497509550505050565b600081518084526020808501945080840160005b83811015611f1857815187529582019590820190600101611efc565b509495945050505050565b602081526000611f366020830184611ee8565b9392505050565b6001600160a01b0381168114611f5257600080fd5b50565b600060208284031215611f6757600080fd5b8135611f3681611f3d565b600060208284031215611f8457600080fd5b81518015158114611f3657600080fd5b60208082526015908201527426b0b730b3b2b91d102737ba1030b71020b236b4b760591b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60008235607e19833603018112611fef57600080fd5b9190910192915050565b6000808335601e1984360301811261201057600080fd5b8301803591506001600160401b0382111561202a57600080fd5b6020019150606081023603821315611cf857600080fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156118fd576118fd612041565b60006001820161207c5761207c612041565b5060010190565b634e487b7160e01b600052604160045260246000fd5b80820281158282048414176118fd576118fd612041565b6000602082840312156120c257600080fd5b8151611f3681611f3d565b6000808335601e198436030181126120e457600080fd5b8301803591506001600160401b038211156120fe57600080fd5b6020019150600581901b3603821315611cf857600080fd5b6001600160a01b0384168152604060208201819052810182905260006001600160fb1b0383111561214657600080fd5b8260051b8085606085013791909101606001949350505050565b60006020828403121561217257600080fd5b5051919050565b818103818111156118fd576118fd612041565b604080519081016001600160401b03811182821017156121ae576121ae612083565b60405290565b604051608081016001600160401b03811182821017156121ae576121ae612083565b604051601f8201601f191681016001600160401b03811182821017156121fe576121fe612083565b604052919050565b6000602080838503121561221957600080fd5b82516001600160401b038082111561223057600080fd5b8185019150604080838803121561224657600080fd5b61224e61218c565b83518152848401518381111561226357600080fd5b80850194505087601f85011261227857600080fd5b83518381111561228a5761228a612083565b612298868260051b016121d6565b818152868101945060079190911b8501860190898211156122b857600080fd5b948601945b81861015612324576080868b0312156122d65760008081fd5b6122de6121b4565b8651600381106122ee5760008081fd5b8152868801516122fd81611f3d565b818901528685015185820152606080880151908201528552608090950194938601936122bd565b95820195909552979650505050505050565b6001600160a01b038516815260806020820181905260009061235a90830186611ee8565b828103604084015261236c8186611ee8565b905082810360608401526123808185611ee8565b979650505050505050565b60006020828403121561239d57600080fd5b81356001600160401b0381168114611f3657600080fd5b6000826123d157634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fd5b60006101208b835260208b818501528a604085015260018060a01b03808b1660608601528960808601528260a08601526124288386018a611ee8565b85810360c08701528851808252838a0194509083019060005b8181101561245f578551841683529484019491840191600101612441565b505085810360e08701526124738189611ee8565b935050505082810361010084015261248b8185611ee8565b9c9b50505050505050505050505056fea26469706673582212209040a204935377a55385f1d9333671dbf9ffc351cf889a3b7cbaf6c7b264569b64736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861000000000000000000000000eb55ae0113039f7d7001c43538c350f89aa3177900000000000000000000000039224dc1a5303151be7ccf1e9504aeb616f2f3e3000000000000000000000000a56aa79eef0651a0d04b00da4f6263bcec8411840000000000000000000000009a9bbffe07ea36295a26b54379596b6d25234dc3000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f57000000000000000000000000c9797a6be31f052cdfbdcc7264005c1eea0f69b9000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f00000000000000000000000045c9e1055d6f57711e172133e22e707e8441078a
-----Decoded View---------------
Arg [0] : _manager (address): 0x4E572433A3Bfa336b6396D13AfC9F69b58252861
Arg [1] : _structureStaker (address): 0xEb55aE0113039F7D7001c43538c350F89aA31779
Arg [2] : _actionStorage (address): 0x39224DC1A5303151be7CcF1E9504aEB616f2F3e3
Arg [3] : _monument (address): 0xa56aa79EeF0651a0D04B00Da4f6263bcec841184
Arg [4] : _gateway (address): 0x9A9BbFfE07Ea36295A26b54379596B6D25234dc3
Arg [5] : _resource (address): 0xB0171b76b413303aD35e5d7cF9e9586480a87F57
Arg [6] : _adventurerData (address): 0xc9797A6Be31F052cdfbDCc7264005c1EEA0F69B9
Arg [7] : _anima (address): 0xcCd05A0fcfc1380e9Da27862Adb2198E58e0D66f
Arg [8] : _rewardsPool (address): 0x45c9E1055D6f57711E172133e22e707E8441078A
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 0000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861
Arg [1] : 000000000000000000000000eb55ae0113039f7d7001c43538c350f89aa31779
Arg [2] : 00000000000000000000000039224dc1a5303151be7ccf1e9504aeb616f2f3e3
Arg [3] : 000000000000000000000000a56aa79eef0651a0d04b00da4f6263bcec841184
Arg [4] : 0000000000000000000000009a9bbffe07ea36295a26b54379596b6d25234dc3
Arg [5] : 000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f57
Arg [6] : 000000000000000000000000c9797a6be31f052cdfbdcc7264005c1eea0f69b9
Arg [7] : 000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f
Arg [8] : 00000000000000000000000045c9e1055d6f57711e172133e22e707e8441078a
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.