Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 25 from a total of 519 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Channel Mana Rit... | 17423478 | 991 days ago | IN | 0 ETH | 0.00494629 | ||||
| Channel Mana Rit... | 17117756 | 1034 days ago | IN | 0 ETH | 0.00623419 | ||||
| Transfer Ownersh... | 16385687 | 1137 days ago | IN | 0 ETH | 0.00085046 | ||||
| Channel Mana Rit... | 16193411 | 1164 days ago | IN | 0 ETH | 0.00154926 | ||||
| Channel Mana Rit... | 16193400 | 1164 days ago | IN | 0 ETH | 0.00149441 | ||||
| Channel Mana Rit... | 16192767 | 1164 days ago | IN | 0 ETH | 0.00269615 | ||||
| Set Is Channelin... | 16192682 | 1164 days ago | IN | 0 ETH | 0.00122412 | ||||
| Set Mana Modifie... | 15857461 | 1211 days ago | IN | 0 ETH | 0.00041708 | ||||
| Set Mana Modifie... | 15857443 | 1211 days ago | IN | 0 ETH | 0.0002029 | ||||
| Set Mana Modifie... | 15764190 | 1224 days ago | IN | 0 ETH | 0.00058523 | ||||
| Safe Mana Boost ... | 15537389 | 1256 days ago | IN | 0 ETH | 0.00354584 | ||||
| Safe Mana Boost ... | 15537388 | 1256 days ago | IN | 0 ETH | 0.00444408 | ||||
| Safe Mana Boost ... | 15537359 | 1256 days ago | IN | 0 ETH | 0.00216448 | ||||
| Safe Mana Boost ... | 15537330 | 1256 days ago | IN | 0 ETH | 0.00241803 | ||||
| Safe Mana Boost ... | 15537327 | 1256 days ago | IN | 0 ETH | 0.03858298 | ||||
| Safe Mana Boost ... | 15537322 | 1256 days ago | IN | 0 ETH | 0.00280154 | ||||
| Safe Mana Boost ... | 15537308 | 1256 days ago | IN | 0 ETH | 0.00158242 | ||||
| Safe Mana Boost ... | 15537303 | 1256 days ago | IN | 0 ETH | 0.00363293 | ||||
| Safe Mana Boost ... | 15537297 | 1256 days ago | IN | 0 ETH | 0.00121152 | ||||
| Safe Mana Boost ... | 15537288 | 1256 days ago | IN | 0 ETH | 0.00503563 | ||||
| Safe Mana Boost ... | 15537246 | 1256 days ago | IN | 0 ETH | 0.00299815 | ||||
| Safe Mana Boost ... | 15537240 | 1256 days ago | IN | 0 ETH | 0.00173045 | ||||
| Safe Mana Boost ... | 15537230 | 1256 days ago | IN | 0 ETH | 0.00092847 | ||||
| Safe Mana Boost ... | 15537230 | 1256 days ago | IN | 0 ETH | 0.00100136 | ||||
| Safe Mana Boost ... | 15537185 | 1256 days ago | IN | 0 ETH | 0.00085374 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MergeMana
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './RendererPropsStorage.sol';
import './interfaces/IDataStorage.sol';
import './Merge.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/Base64.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@abf-monorepo/protocol/contracts/renderers/LayerCompositeRenderer.sol';
import '@abf-monorepo/protocol/contracts/libraries/BytesUtils.sol';
contract MergeMana is Ownable {
using Strings for uint256;
Merge public merge;
bool public emergencyShutdown = false;
// mana
uint256 public numDecimals;
IDataStorage public baseManaStorage;
uint256 public baseManaMultiplier;
mapping(address => bool) public manaModifier;
mapping(uint256 => uint256) public boostedMana;
mapping(uint256 => uint256) public consumedMana;
// decay
uint256 public manaDecayPerBlock;
uint256 public manaDecayStartBlock;
// boost
uint256 public manaBoostRitualMultiplier;
uint256 public maxManaBoostRitualBalance;
// channeling
bool public isChannelingRitualActive = false;
mapping(uint256 => uint256) public channelingRitualDestinationTokenId;
mapping(uint256 => uint256) public channeledMana;
mapping(uint256 => uint256) public numChanneledToTokenId;
event ChangedEmergencyShutdown(bool shutdown);
event ConsumedMana(uint256 tokenId, uint256 amount);
event IncreasedMana(uint256 tokenId, uint256 amount);
event ChanneledStatue(uint256 from, uint256 to, uint256 amount);
event BoostedMana(address booster, uint256 tokenId, uint256 amount);
struct DeployMergeManaConfig {
address merge;
address baseManaStorage;
uint256 manaBoostRitualMultiplier;
uint256 maxManaBoostRitualBalance;
uint256 baseManaMultiplier;
uint256 numDecimals;
}
constructor(DeployMergeManaConfig memory config) {
merge = Merge(config.merge);
manaBoostRitualMultiplier = config.manaBoostRitualMultiplier;
baseManaStorage = IDataStorage(config.baseManaStorage);
maxManaBoostRitualBalance = config.maxManaBoostRitualBalance;
baseManaMultiplier = config.baseManaMultiplier;
numDecimals = config.numDecimals;
}
function setNumDecimals(uint256 _numDecimals) public onlyOwner {
numDecimals = _numDecimals;
}
function setBaseManaStorage(address _baseManaStorage) public onlyOwner {
baseManaStorage = IDataStorage(_baseManaStorage);
}
function setBaseManaMultiplier(uint256 _baseManaMultiplier) public onlyOwner {
baseManaMultiplier = _baseManaMultiplier;
}
function setMaxManaBoostRitualBalance(uint256 _maxManaBoostRitualBalance)
public
onlyOwner
{
maxManaBoostRitualBalance = _maxManaBoostRitualBalance;
}
function setManaBoostRitualMultiplier(uint256 _manaBoostRitualMultiplier)
public
onlyOwner
{
manaBoostRitualMultiplier = _manaBoostRitualMultiplier;
}
function setManaDecayPerBlock(uint256 _manaDecayPerBlock) public onlyOwner {
manaDecayPerBlock = _manaDecayPerBlock;
}
function setManaDecayStartBlock(uint256 _manaDecayStartBlock)
public
onlyOwner
{
manaDecayStartBlock = _manaDecayStartBlock;
}
function setManaModifier(address _manaModifier, bool status)
public
onlyOwner
{
manaModifier[_manaModifier] = status;
}
function setMerge(address _merge) public onlyOwner {
merge = Merge(_merge);
}
function setIsChannelingRitualActive(bool _isChannelingRitualActive)
public
onlyOwner
{
isChannelingRitualActive = _isChannelingRitualActive;
emit ChangedEmergencyShutdown(isChannelingRitualActive);
}
function setEmergencyShutdown(bool shutdown) public onlyOwner {
emergencyShutdown = shutdown;
emit ChangedEmergencyShutdown(shutdown);
}
function isMergeByDifficulty() public view virtual returns (bool) {
return (block.difficulty > (2**64)) || (block.difficulty == 0);
}
modifier onlyIsNotShutdown() {
require(!emergencyShutdown, 'MergeMana: Emergency shutdown is in place');
_;
}
modifier onlyIsNotMergeOrChannelingNotActive() {
require(
!isMergeByDifficulty() && !isChannelingRitualActive,
'MergeMana: Action only can occur before merge'
);
_;
}
modifier onlyIsChannelingRitualActive() {
require(
isChannelingRitualActive,
'MergeMana: Action only can occur after merge'
);
_;
}
modifier onlyManaModifier() {
require(manaModifier[msg.sender], 'MergeMana: Not a mana modifier');
_;
}
/**
* Mana based logic
*/
function getTotalMana(uint256 id) public view returns (uint256) {
return getInherentMana(id) + getBoostedMana(id) + getChanneledMana(id);
}
function getTotalManaWithNoPenalties(uint256 id)
public
view
returns (uint256)
{
return
getInherentManaWithNoPenalties(id) + boostedMana[id] + channeledMana[id];
}
function getTotalManaPenalties(uint256 id) public view returns (uint256) {
uint256 decay = getManaDecay();
uint256 consumedAmount = consumedMana[id];
return decay + consumedAmount;
}
function getChanneledMana(uint256 id) public view returns (uint256) {
uint256 totalPenalties = getTotalManaPenalties(id);
if (totalPenalties > channeledMana[id]) {
return 0;
}
return channeledMana[id] - totalPenalties;
}
function getBoostedMana(uint256 id) public view returns (uint256) {
uint256 totalPenalties = getTotalManaPenalties(id);
if (totalPenalties > channeledMana[id]) {
uint256 leftOverManaPenalty = totalPenalties - channeledMana[id];
if (leftOverManaPenalty > boostedMana[id]) {
return 0;
}
return boostedMana[id] - leftOverManaPenalty;
}
return boostedMana[id];
}
function getInherentManaWithNoPenalties(uint256 id)
public
view
returns (uint256)
{
if (channelingRitualDestinationTokenId[id] != 0) {
return 0;
}
if (address(baseManaStorage) == address(0)) {
return 0;
}
return
uint256(uint8(baseManaStorage.indexToData(id)[0])) * baseManaMultiplier;
}
function getInherentMana(uint256 id) public view returns (uint256) {
uint256 lowerMana = boostedMana[id] + channeledMana[id];
uint256 totalPenalties = getTotalManaPenalties(id);
uint256 inherentManaWithNoPenalties = getInherentManaWithNoPenalties(id);
if (totalPenalties > lowerMana) {
uint256 leftOverManaPenalty = totalPenalties - lowerMana;
if (leftOverManaPenalty > inherentManaWithNoPenalties) {
return 0;
}
return inherentManaWithNoPenalties - leftOverManaPenalty;
}
return inherentManaWithNoPenalties;
}
function getManaDecay() public view returns (uint256) {
if (manaDecayStartBlock == 0) {
return 0;
}
return (block.number - manaDecayStartBlock) * manaDecayPerBlock;
}
function consumeMana(uint256 id, uint256 amount)
public
onlyIsNotShutdown
onlyManaModifier
{
require(
amount <= getTotalMana(id),
'MergeMana: Can not consume more mana than what exists in statue'
);
consumedMana[id] += amount;
emit ConsumedMana(id, amount);
}
function increaseMana(uint256 id, uint256 amount)
public
onlyIsNotShutdown
onlyManaModifier
{
if (channelingRitualDestinationTokenId[id] == 0) {
boostedMana[id] += amount;
} else {
channeledMana[channelingRitualDestinationTokenId[id]] += amount;
}
emit IncreasedMana(id, amount);
}
function _channelMana(uint256 from, uint256 to) internal {
uint256 inherentManaAndBoostedMana = getInherentMana(from) +
getBoostedMana(from);
channeledMana[to] += inherentManaAndBoostedMana;
numChanneledToTokenId[to]++;
channelingRitualDestinationTokenId[from] = to;
boostedMana[from] = 0;
emit ChanneledStatue(from, to, inherentManaAndBoostedMana);
}
function safeChannelManaRitual(uint256[] memory from, uint256 to)
public
onlyIsChannelingRitualActive
onlyIsNotShutdown
{
for (uint256 i = 0; i < from.length; ++i) {
if (to != 0 && channelingRitualDestinationTokenId[from[i]] == 0) {
_channelMana(from[i], to);
}
}
}
function channelManaRitual(uint256[] memory from, uint256 to)
public
onlyIsChannelingRitualActive
onlyIsNotShutdown
{
for (uint256 i = 0; i < from.length; ++i) {
require(to != 0, 'MergeMana: Can not channel to tokenId zero');
require(
channelingRitualDestinationTokenId[from[i]] == 0,
'MergeMana: Mana has already been channeled'
);
_channelMana(from[i], to);
}
}
function getBoostManaRitualAmount(address booster)
public
view
returns (uint256)
{
uint256 balance = merge.balanceOf(booster);
return
manaBoostRitualMultiplier *
(
balance > maxManaBoostRitualBalance
? maxManaBoostRitualBalance
: balance
) *
merge.getCurrentRarityScore(booster);
}
function _boostMana(uint256 tokenId, uint256 amount) internal {
boostedMana[tokenId] = amount;
emit BoostedMana(msg.sender, tokenId, amount);
}
function manaBoostRitual(uint256[] memory tokenIds)
public
onlyIsNotMergeOrChannelingNotActive
onlyIsNotShutdown
{
uint256 boostedManaAmount = getBoostManaRitualAmount(msg.sender);
for (uint256 i = 0; i < tokenIds.length; ++i) {
require(
merge.ownerOf(tokenIds[i]) == msg.sender,
'MergeMana: Can not boost token you do not own'
);
require(
boostedMana[tokenIds[i]] == 0,
'MergeMana: Can not boost tokens that are already boosted'
);
_boostMana(tokenIds[i], boostedManaAmount);
}
}
function safeManaBoostRitual(uint256[] memory tokenIds)
public
onlyIsNotMergeOrChannelingNotActive
onlyIsNotShutdown
{
uint256 boostedManaAmount = getBoostManaRitualAmount(msg.sender);
for (uint256 i = 0; i < tokenIds.length; ++i) {
if (
merge.ownerOf(tokenIds[i]) == msg.sender &&
boostedMana[tokenIds[i]] == 0
) {
_boostMana(tokenIds[i], boostedManaAmount);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './libraries/SSTORE2Map.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/Base64.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@abf-monorepo/protocol/contracts/renderers/LayerCompositeRenderer.sol';
import '@abf-monorepo/protocol/contracts/libraries/BytesUtils.sol';
contract RendererPropsStorage is Ownable {
uint256 public constant MAX_UINT_16 = 0xFFFF;
// index starts from zero, useful to use the 0th index as a empty case.
uint16 public currentMaxRendererPropsIndex = 0;
constructor() {}
function batchAddRendererProps(bytes[] calldata rendererProps)
public
onlyOwner
{
for (uint16 i = 0; i < rendererProps.length; ++i) {
SSTORE2Map.write(
bytes32(uint256(currentMaxRendererPropsIndex + i)),
rendererProps[i]
);
}
currentMaxRendererPropsIndex += uint16(rendererProps.length);
require(
currentMaxRendererPropsIndex <= MAX_UINT_16,
'RendererPropsStorage: Exceeds storage limit'
);
}
function indexToRendererProps(uint16 index)
public
view
returns (bytes memory)
{
return SSTORE2Map.read(bytes32(uint256(index)));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
interface IDataStorage is IERC165 {
function indexToData(uint256 index) external view returns (bytes memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './tokens/ERC721A.sol';
import './libraries/SSTORE2Map.sol';
import './SigmoidThreshold.sol';
import './RarityCompositingEngine.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/common/ERC2981.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
contract Merge is ERC721A, ERC2981, Ownable {
using Strings for uint256;
uint256 public MAX_MINTING_PER_BLOCK = 3;
uint256 public deployDate;
bool public isActive;
SigmoidThreshold public curve;
// Price Vars
uint256 public a0;
uint256 public b0;
uint256 public c0;
uint256 public d0;
// Rarity Vars
uint256 public a1;
uint256 public b1;
uint256 public c1;
uint256 public d1;
address public treasury;
address public boostToken;
// RCE
RarityCompositingEngine public rce;
uint256 public boostTokenBaseAmount = 1000;
mapping(uint256 => uint256) public rarityTokenMap; // tokenID => rarityScore
bool public emergencyShutdown = false;
mapping(bytes32 => uint256) public blockMintingGuardMap; // hash(address + block number) => numMinted
mapping(address => bool) public blacklistMap; // hash(address) => boolean
event ChangedIsActive(bool isActive);
event ChangedEmergencyShutdown(bool shutdown);
struct DeployMergeNFTConfig {
string name;
string symbol;
address treasury;
address boostToken;
address rce;
address curve;
uint256 a0;
uint256 b0;
uint256 c0;
uint256 d0;
uint256 a1;
uint256 b1;
uint256 c1;
uint256 d1;
}
struct SetCurveParams {
uint256 a0;
uint256 b0;
uint256 c0;
uint256 d0;
uint256 a1;
uint256 b1;
uint256 c1;
uint256 d1;
}
constructor(DeployMergeNFTConfig memory config) ERC721A() {
_name = config.name;
_symbol = config.symbol;
a0 = config.a0;
b0 = config.b0;
c0 = config.c0;
d0 = config.d0;
a1 = config.a1;
b1 = config.b1;
c1 = config.c1;
d1 = config.d1;
boostToken = config.boostToken;
curve = SigmoidThreshold(config.curve);
deployDate = block.timestamp;
treasury = config.treasury;
rce = RarityCompositingEngine(config.rce);
//_transferOwnership(config.treasury);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721A, ERC2981)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function getTokenBalance(address token, address userAddress)
public
view
returns (uint256)
{
return IERC721(token).balanceOf(userAddress);
}
function currentIndex() public view returns (uint256) {
return _currentIndex;
}
function setIsActive(bool _isActive) public onlyOwner {
isActive = _isActive;
emit ChangedIsActive(isActive);
}
function setEmergencyShutdown(bool shutdown) public onlyOwner {
emergencyShutdown = shutdown;
emit ChangedEmergencyShutdown(shutdown);
}
function setBlacklist(address[] memory _list) public onlyOwner {
for (uint256 i = 0; i < _list.length; ++i) {
blacklistMap[_list[i]] = true;
}
}
function setRoyalty(uint96 newRoyaltyFraction) public onlyOwner {
_setDefaultRoyalty(treasury, newRoyaltyFraction);
}
function setMaxMinting(uint256 _max) public onlyOwner {
MAX_MINTING_PER_BLOCK = _max;
}
function setDeployDate(uint256 _date) public onlyOwner {
deployDate = _date;
}
function setBoostToken(address _boostToken) public onlyOwner {
boostToken = _boostToken;
}
function setBoostTokenBaseAmount(uint256 _amount) public onlyOwner {
boostTokenBaseAmount = _amount;
}
function setTreasury(address _treasury) public onlyOwner {
treasury = _treasury;
}
function setRCE(address _rce) public onlyOwner {
rce = RarityCompositingEngine(_rce);
}
function setCurve(address _curve) public onlyOwner {
curve = SigmoidThreshold(_curve);
}
function setCurveParams(SetCurveParams memory config) public onlyOwner {
a0 = config.a0;
b0 = config.b0;
c0 = config.c0;
a1 = config.a1;
b1 = config.b1;
c1 = config.c1;
}
// X variable in graph. Curve is tuned to
function numSecondsSinceDeploy() public view returns (uint256) {
return (block.timestamp - deployDate);
}
function isMergeByDifficulty() public view virtual returns (bool) {
return (block.difficulty > (2**64)) || (block.difficulty == 0);
}
modifier onlyIsActive() {
require(isActive, 'minting needs to be active to mint');
_;
}
modifier onlyIsNotShutdown() {
require(!emergencyShutdown, 'emergency shutdown is in place');
_;
}
modifier onlyIsNotMerge() {
require(
!isMergeByDifficulty(),
'minting needs to be done before Proof of Stake'
);
_;
}
function getBoostScore(address userAddress) external view returns (uint256) {
uint256 balance = getTokenBalance(boostToken, userAddress);
uint256 maxBalance = balance >= 16 ? 16 : balance;
return maxBalance * boostTokenBaseAmount;
}
function getRarityScoreForToken(uint256 tokenId)
public
view
returns (uint256)
{
uint256 curr = tokenId;
if (_startTokenId() <= curr && curr < _currentIndex) {
while (true) {
if (rarityTokenMap[curr] != 0) {
return rarityTokenMap[curr];
}
curr--;
}
}
revert OwnerQueryForNonexistentToken();
}
function getCurrentRarityScore(address userAddress)
public
view
returns (uint256)
{
SigmoidThreshold.CurveParams memory config;
config._x = numSecondsSinceDeploy();
config.minX = a1;
config.maxX = b1;
config.minY = c1;
config.maxY = d1;
uint256 rarity = curve.getY(config);
try this.getBoostScore(userAddress) returns (uint256 boost) {
return rarity + boost;
} catch {
return rarity;
}
}
function getCurrentPrice() public view returns (uint256) {
SigmoidThreshold.CurveParams memory config;
config._x = numSecondsSinceDeploy();
config.minX = a0;
config.maxX = b0;
config.minY = c0;
config.maxY = d0;
uint256 price = curve.getY(config);
return price; // in GWEI
}
function contractURI() public view returns (string memory) {
return
string(
abi.encodePacked(
'data:application/json;base64,',
Base64.encode(
abi.encodePacked(
'{"name":"',
_name,
'", "description": "A Proof of Beauty project. Fully on-chain generative statues to remember the MERGE.',
'", "external_link": "https://merge.pob.studio/',
'", "image": "https://merge.pob.studio/assets/logo.png" }'
)
)
)
);
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(_exists(tokenId), 'URI query for nonexistent token');
uint256 rarityScore = getRarityScoreForToken(tokenId);
bytes memory seed = abi.encodePacked(rarityScore, tokenId);
(, uint16[] memory attributeIndexes) = rce.getRarity(rarityScore, seed);
string memory image = rce.getRender(attributeIndexes);
return
string(
abi.encodePacked(
'data:application/json;base64,',
Base64.encode(
abi.encodePacked(
'{"name": "Statue #',
tokenId.toString(),
'", "description": "',
'A Proof of Beauty project. Fully on-chain generative statues to remember the MERGE.',
'", "image": "',
image,
'", "aspect_ratio": "1',
'", "attributes": ',
rce.getAttributesJSON(attributeIndexes),
'}'
)
)
)
);
}
function mint(address to, uint256 numMints)
public
payable
onlyIsActive
onlyIsNotMerge
onlyIsNotShutdown
{
bytes32 blockNumHash = keccak256(abi.encode(block.number, msg.sender));
require(
blockMintingGuardMap[blockNumHash] + numMints <= MAX_MINTING_PER_BLOCK,
'exceeded max number of mints'
);
require(!blacklistMap[msg.sender], 'caller is blacklisted');
uint256 totalPrice = getCurrentPrice() * numMints;
require(totalPrice <= msg.value, 'insufficient funds to pay for mint');
uint256 currentRarityScore = getCurrentRarityScore(msg.sender);
rarityTokenMap[_currentIndex] = currentRarityScore;
blockMintingGuardMap[blockNumHash] =
blockMintingGuardMap[blockNumHash] +
numMints;
_mint(to, numMints, '', false);
treasury.call{value: totalPrice}('');
payable(msg.sender).transfer(msg.value - totalPrice);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_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) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @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] = _HEX_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
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*
* _Available since v4.5._
*/
library Base64 {
/**
* @dev Base64 Encoding/Decoding Table
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/**
* @dev Converts a `bytes` to its Bytes64 `string` representation.
*/
function encode(bytes memory data) internal pure returns (string memory) {
/**
* Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
* https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
*/
if (data.length == 0) return "";
// Loads the table into memory
string memory table = _TABLE;
// Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
// and split into 4 numbers of 6 bits.
// The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
// - `data.length + 2` -> Round up
// - `/ 3` -> Number of 3-bytes chunks
// - `4 *` -> 4 characters for each chunk
string memory result = new string(4 * ((data.length + 2) / 3));
/// @solidity memory-safe-assembly
assembly {
// Prepare the lookup table (skip the first "length" byte)
let tablePtr := add(table, 1)
// Prepare result pointer, jump over length
let resultPtr := add(result, 32)
// Run over the input, 3 bytes at a time
for {
let dataPtr := data
let endPtr := add(data, mload(data))
} lt(dataPtr, endPtr) {
} {
// Advance 3 bytes
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
// To write each character, shift the 3 bytes (18 bits) chunk
// 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
// and apply logical AND with 0x3F which is the number of
// the previous character in the ASCII table prior to the Base64 Table
// The result is then added to the table to get the character to write,
// and finally write it in the result pointer but with a left shift
// of 256 (1 byte) - 8 (1 ASCII char) = 248 bits
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
}
// When data `bytes` is not exactly 3 bytes long
// it is padded with `=` characters at the end
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "../interfaces/IRenderer.sol";
import "../libraries/BytesUtils.sol";
import "../libraries/SvgUtils.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import "@openzeppelin/contracts/utils/Base64.sol";
contract LayerCompositeRenderer is IRenderer, Ownable, ERC165 {
using Strings for uint256;
function owner() public override(Ownable, IRenderer) view returns (address) {
return super.owner();
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IRenderer).interfaceId ||
super.supportsInterface(interfaceId);
}
function propsSize() external override pure returns (uint256) {
return 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
}
function additionalMetadataURI() external override pure returns (string memory) {
return "ipfs://bafkreigjwztwrolwcbkbz3ombzkvxg2767bckeobrfwdjfohvxgozbepv4";
}
function renderAttributeKey() external override pure returns (string memory) {
return "image";
}
function name() public override pure returns (string memory) {
return 'Layer Composite';
}
function encodeProps(address[] memory renderers, bytes[] memory rendererProps) public pure returns (bytes memory output) {
for (uint i = 0; i < renderers.length; ++i) {
output = abi.encodePacked(output, renderers[i], rendererProps[i].length, rendererProps[i]);
}
}
function renderRaw(bytes calldata props) public override view returns (bytes memory) {
bytes memory backgroundImages;
for (uint i = 0; i < props.length; i += 0) {
IRenderer destinationRenderer = IRenderer(BytesUtils.toAddress(props, i));
uint start = i + 20 + 32;
uint end = start + BytesUtils.toUint256(props, i + 20);
backgroundImages = abi.encodePacked(backgroundImages, i == 0 ? '' : ',', 'url(',
destinationRenderer.render(props[start:end])
,')');
i = end;
}
return abi.encodePacked(
'<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1200" style="',
'background-image:', backgroundImages, ';background-repeat:no-repeat;background-size:contain;background-position:center;image-rendering:-webkit-optimize-contrast;-ms-interpolation-mode:nearest-neighbor;image-rendering:-moz-crisp-edges;image-rendering:pixelated;">',
'</svg>'
);
}
function render(bytes calldata props) external override view returns (string memory) {
return string(
abi.encodePacked(
'data:image/svg+xml;base64,',
Base64.encode(renderRaw(props))
)
);
}
function attributes(bytes calldata) external override pure returns (string memory) {
return "";
}
}// SPDX-License-Identifier: MIT
/*
* @title Solidity Bytes Arrays Utils
* @author Gonçalo Sá <goncalo.sa@consensys.net>
*
* @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
* The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
*/
pragma solidity ^0.8.4;
library BytesUtils {
function concat(
bytes memory _preBytes,
bytes memory _postBytes
)
internal
pure
returns (bytes memory)
{
bytes memory tempBytes;
assembly {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// Store the length of the first bytes array at the beginning of
// the memory for tempBytes.
let length := mload(_preBytes)
mstore(tempBytes, length)
// Maintain a memory counter for the current write location in the
// temp bytes array by adding the 32 bytes for the array length to
// the starting location.
let mc := add(tempBytes, 0x20)
// Stop copying when the memory counter reaches the length of the
// first bytes array.
let end := add(mc, length)
for {
// Initialize a copy counter to the start of the _preBytes data,
// 32 bytes into its memory.
let cc := add(_preBytes, 0x20)
} lt(mc, end) {
// Increase both counters by 32 bytes each iteration.
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// Write the _preBytes data into the tempBytes memory 32 bytes
// at a time.
mstore(mc, mload(cc))
}
// Add the length of _postBytes to the current length of tempBytes
// and store it as the new length in the first 32 bytes of the
// tempBytes memory.
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
// Move the memory counter back from a multiple of 0x20 to the
// actual end of the _preBytes data.
mc := end
// Stop copying when the memory counter reaches the new combined
// length of the arrays.
end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
// Update the free-memory pointer by padding our last write location
// to 32 bytes: add 31 bytes to the end of tempBytes to move to the
// next 32 byte block, then round down to the nearest multiple of
// 32. If the sum of the length of the two arrays is zero then add
// one before rounding down to leave a blank 32 bytes (the length block with 0).
mstore(0x40, and(
add(add(end, iszero(add(length, mload(_preBytes)))), 31),
not(31) // Round down to the nearest 32 bytes.
))
}
return tempBytes;
}
function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
assembly {
// Read the first 32 bytes of _preBytes storage, which is the length
// of the array. (We don't need to use the offset into the slot
// because arrays use the entire slot.)
let fslot := sload(_preBytes.slot)
// Arrays of 31 bytes or less have an even value in their slot,
// while longer arrays have an odd value. The actual length is
// the slot divided by two for odd values, and the lowest order
// byte divided by two for even values.
// If the slot is even, bitwise and the slot with 255 and divide by
// two to get the length. If the slot is odd, bitwise and the slot
// with -1 and divide by two.
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
let newlength := add(slength, mlength)
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
// Since the new array still fits in the slot, we just need to
// update the contents of the slot.
// uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
sstore(
_preBytes.slot,
// all the modifications to the slot are inside this
// next block
add(
// we can just add to the slot contents because the
// bytes we want to change are the LSBs
fslot,
add(
mul(
div(
// load the bytes from memory
mload(add(_postBytes, 0x20)),
// zero all bytes to the right
exp(0x100, sub(32, mlength))
),
// and now shift left the number of bytes to
// leave space for the length in the slot
exp(0x100, sub(32, newlength))
),
// increase length by the double of the memory
// bytes length
mul(mlength, 2)
)
)
)
}
case 1 {
// The stored value fits in the slot, but the combined value
// will exceed it.
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// The contents of the _postBytes array start 32 bytes into
// the structure. Our first read should obtain the `submod`
// bytes that can fit into the unused space in the last word
// of the stored array. To get this, we read 32 bytes starting
// from `submod`, so the data we read overlaps with the array
// contents by `submod` bytes. Masking the lowest-order
// `submod` bytes allows us to add that value directly to the
// stored value.
let submod := sub(32, slength)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(
sc,
add(
and(
fslot,
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
),
and(mload(mc), mask)
)
)
for {
mc := add(mc, 0x20)
sc := add(sc, 1)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
default {
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
// Start copying to the last used word of the stored array.
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// Copy over the first `submod` bytes of the new data as in
// case 1 above.
let slengthmod := mod(slength, 32)
let mlengthmod := mod(mlength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
sc := add(sc, 1)
mc := add(mc, 0x20)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
}
}
function slice(
bytes memory _bytes,
uint256 _start,
uint256 _length
)
internal
pure
returns (bytes memory)
{
require(_length + 31 >= _length, "slice_overflow");
require(_bytes.length >= _start + _length, "slice_outOfBounds");
bytes memory tempBytes;
assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)
for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
mstore(tempBytes, _length)
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)
mstore(0x40, add(tempBytes, 0x20))
}
}
return tempBytes;
}
function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
address tempAddress;
assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}
return tempAddress;
}
function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
uint8 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x1), _start))
}
return tempUint;
}
function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
uint16 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x2), _start))
}
return tempUint;
}
function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
uint32 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x4), _start))
}
return tempUint;
}
function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
uint64 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x8), _start))
}
return tempUint;
}
function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
uint96 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0xc), _start))
}
return tempUint;
}
function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
uint128 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x10), _start))
}
return tempUint;
}
function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
uint256 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x20), _start))
}
return tempUint;
}
function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
bool success = true;
assembly {
let length := mload(_preBytes)
// if lengths don't match the arrays are not equal
switch eq(length, mload(_postBytes))
case 1 {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
let mc := add(_preBytes, 0x20)
let end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
} eq(add(lt(mc, end), cb), 2) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// if any of these checks fails then arrays are not equal
if iszero(eq(mload(mc), mload(cc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
function equalStorage(
bytes storage _preBytes,
bytes memory _postBytes
)
internal
view
returns (bool)
{
bool success = true;
assembly {
// we know _preBytes_offset is 0
let fslot := sload(_preBytes.slot)
// Decode the length of the stored array like in concatStorage().
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
// if lengths don't match the arrays are not equal
switch eq(slength, mlength)
case 1 {
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
// blank the last byte which is the length
fslot := mul(div(fslot, 0x100), 0x100)
if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
// unsuccess:
success := 0
}
}
default {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := keccak256(0x0, 0x20)
let mc := add(_postBytes, 0x20)
let end := add(mc, mlength)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
for {} eq(add(lt(mc, end), cb), 2) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
if iszero(eq(sload(sc), mload(mc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './Create3.sol';
import './Bytecode.sol';
/**
@title A write-once key-value storage for storing chunks of data with a lower write & read cost.
@author Agustin Aguilar <aa@horizon.io>
Readme: https://github.com/0xsequence/sstore2#readme
*/
library SSTORE2Map {
error WriteError();
// keccak256(bytes('@0xSequence.SSTORE2Map.slot'))
bytes32 private constant SLOT_KEY_PREFIX =
0xd351a9253491dfef66f53115e9e3afda3b5fdef08a1de6937da91188ec553be5;
function internalKey(bytes32 _key) internal pure returns (bytes32) {
// Mutate the key so it doesn't collide
// if the contract is also using CREATE3 for other things
return keccak256(abi.encode(SLOT_KEY_PREFIX, _key));
}
/**
@notice Stores `_data` and returns `pointer` as key for later retrieval
@dev The pointer is a contract address with `_data` as code
@param _data To be written
@param _key unique string key for accessing the written data (can only be used once)
@return pointer Pointer to the written `_data`
*/
function write(string memory _key, bytes memory _data)
internal
returns (address pointer)
{
return write(keccak256(bytes(_key)), _data);
}
/**
@notice Stores `_data` and returns `pointer` as key for later retrieval
@dev The pointer is a contract address with `_data` as code
@param _data to be written
@param _key unique bytes32 key for accessing the written data (can only be used once)
@return pointer Pointer to the written `_data`
*/
function write(bytes32 _key, bytes memory _data)
internal
returns (address pointer)
{
// Append 00 to _data so contract can't be called
// Build init code
bytes memory code = Bytecode.creationCodeFor(
abi.encodePacked(hex'00', _data)
);
// Deploy contract using create3
pointer = Create3.create3(internalKey(_key), code);
}
/**
@notice Reads the contents for a given `_key`, it maps to a contract code as data, skips the first byte
@dev The function is intended for reading pointers first written by `write`
@param _key string key that constains the data
@return data read from contract associated with `_key`
*/
function read(string memory _key) internal view returns (bytes memory) {
return read(keccak256(bytes(_key)));
}
/**
@notice Reads the contents for a given `_key`, it maps to a contract code as data, skips the first byte
@dev The function is intended for reading pointers first written by `write`
@param _key string key that constains the data
@param _start number of bytes to skip
@return data read from contract associated with `_key`
*/
function read(string memory _key, uint256 _start)
internal
view
returns (bytes memory)
{
return read(keccak256(bytes(_key)), _start);
}
/**
@notice Reads the contents for a given `_key`, it maps to a contract code as data, skips the first byte
@dev The function is intended for reading pointers first written by `write`
@param _key string key that constains the data
@param _start number of bytes to skip
@param _end index before which to end extraction
@return data read from contract associated with `_key`
*/
function read(
string memory _key,
uint256 _start,
uint256 _end
) internal view returns (bytes memory) {
return read(keccak256(bytes(_key)), _start, _end);
}
/**
@notice Reads the contents for a given `_key`, it maps to a contract code as data, skips the first byte
@dev The function is intended for reading pointers first written by `write`
@param _key bytes32 key that constains the data
@return data read from contract associated with `_key`
*/
function read(bytes32 _key) internal view returns (bytes memory) {
return
Bytecode.codeAt(
Create3.addressOf(internalKey(_key)),
1,
type(uint256).max
);
}
/**
@notice Reads the contents for a given `_key`, it maps to a contract code as data, skips the first byte
@dev The function is intended for reading pointers first written by `write`
@param _key bytes32 key that constains the data
@param _start number of bytes to skip
@return data read from contract associated with `_key`
*/
function read(bytes32 _key, uint256 _start)
internal
view
returns (bytes memory)
{
return
Bytecode.codeAt(
Create3.addressOf(internalKey(_key)),
_start + 1,
type(uint256).max
);
}
/**
@notice Reads the contents for a given `_key`, it maps to a contract code as data, skips the first byte
@dev The function is intended for reading pointers first written by `write`
@param _key bytes32 key that constains the data
@param _start number of bytes to skip
@param _end index before which to end extraction
@return data read from contract associated with `_key`
*/
function read(
bytes32 _key,
uint256 _start,
uint256 _end
) internal view returns (bytes memory) {
return
Bytecode.codeAt(
Create3.addressOf(internalKey(_key)),
_start + 1,
_end + 1
);
}
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
/**
@title A library for deploying contracts EIP-3171 style.
@author Agustin Aguilar <aa@horizon.io>
*/
library Create3 {
error ErrorCreatingProxy();
error ErrorCreatingContract();
error TargetAlreadyExists();
/**
@notice The bytecode for a contract that proxies the creation of another contract
@dev If this code is deployed using CREATE2 it can be used to decouple `creationCode` from the child contract address
0x67363d3d37363d34f03d5260086018f3:
0x00 0x67 0x67XXXXXXXXXXXXXXXX PUSH8 bytecode 0x363d3d37363d34f0
0x01 0x3d 0x3d RETURNDATASIZE 0 0x363d3d37363d34f0
0x02 0x52 0x52 MSTORE
0x03 0x60 0x6008 PUSH1 08 8
0x04 0x60 0x6018 PUSH1 18 24 8
0x05 0xf3 0xf3 RETURN
0x363d3d37363d34f0:
0x00 0x36 0x36 CALLDATASIZE cds
0x01 0x3d 0x3d RETURNDATASIZE 0 cds
0x02 0x3d 0x3d RETURNDATASIZE 0 0 cds
0x03 0x37 0x37 CALLDATACOPY
0x04 0x36 0x36 CALLDATASIZE cds
0x05 0x3d 0x3d RETURNDATASIZE 0 cds
0x06 0x34 0x34 CALLVALUE val 0 cds
0x07 0xf0 0xf0 CREATE addr
*/
bytes internal constant PROXY_CHILD_BYTECODE =
hex'67_36_3d_3d_37_36_3d_34_f0_3d_52_60_08_60_18_f3';
// KECCAK256_PROXY_CHILD_BYTECODE = keccak256(PROXY_CHILD_BYTECODE);
bytes32 internal constant KECCAK256_PROXY_CHILD_BYTECODE =
0x21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f;
/**
@notice Returns the size of the code on a given address
@param _addr Address that may or may not contain code
@return size of the code on the given `_addr`
*/
function codeSize(address _addr) internal view returns (uint256 size) {
assembly {
size := extcodesize(_addr)
}
}
/**
@notice Creates a new contract with given `_creationCode` and `_salt`
@param _salt Salt of the contract creation, resulting address will be derivated from this value only
@param _creationCode Creation code (constructor) of the contract to be deployed, this value doesn't affect the resulting address
@return addr of the deployed contract, reverts on error
*/
function create3(bytes32 _salt, bytes memory _creationCode)
internal
returns (address addr)
{
return create3(_salt, _creationCode, 0);
}
/**
@notice Creates a new contract with given `_creationCode` and `_salt`
@param _salt Salt of the contract creation, resulting address will be derivated from this value only
@param _creationCode Creation code (constructor) of the contract to be deployed, this value doesn't affect the resulting address
@param _value In WEI of ETH to be forwarded to child contract
@return addr of the deployed contract, reverts on error
*/
function create3(
bytes32 _salt,
bytes memory _creationCode,
uint256 _value
) internal returns (address addr) {
// Creation code
bytes memory creationCode = PROXY_CHILD_BYTECODE;
// Get target final address
addr = addressOf(_salt);
if (codeSize(addr) != 0) revert TargetAlreadyExists();
// Create CREATE2 proxy
address proxy;
assembly {
proxy := create2(0, add(creationCode, 32), mload(creationCode), _salt)
}
if (proxy == address(0)) revert ErrorCreatingProxy();
// Call proxy with final init code
(bool success, ) = proxy.call{value: _value}(_creationCode);
if (!success || codeSize(addr) == 0) revert ErrorCreatingContract();
}
/**
@notice Computes the resulting address of a contract deployed using address(this) and the given `_salt`
@param _salt Salt of the contract creation, resulting address will be derivated from this value only
@return addr of the deployed contract, reverts on error
@dev The address creation formula is: keccak256(rlp([keccak256(0xff ++ address(this) ++ _salt ++ keccak256(childBytecode))[12:], 0x01]))
*/
function addressOf(bytes32 _salt) internal view returns (address) {
address proxy = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
hex'ff',
address(this),
_salt,
KECCAK256_PROXY_CHILD_BYTECODE
)
)
)
)
);
return
address(
uint160(
uint256(keccak256(abi.encodePacked(hex'd6_94', proxy, hex'01')))
)
);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
library Bytecode {
error InvalidCodeAtRange(uint256 _size, uint256 _start, uint256 _end);
/**
@notice Generate a creation code that results on a contract with `_code` as bytecode
@param _code The returning value of the resulting `creationCode`
@return creationCode (constructor) for new contract
*/
function creationCodeFor(bytes memory _code)
internal
pure
returns (bytes memory)
{
/*
0x00 0x63 0x63XXXXXX PUSH4 _code.length size
0x01 0x80 0x80 DUP1 size size
0x02 0x60 0x600e PUSH1 14 14 size size
0x03 0x60 0x6000 PUSH1 00 0 14 size size
0x04 0x39 0x39 CODECOPY size
0x05 0x60 0x6000 PUSH1 00 0 size
0x06 0xf3 0xf3 RETURN
<CODE>
*/
return
abi.encodePacked(
hex'63',
uint32(_code.length),
hex'80_60_0E_60_00_39_60_00_F3',
_code
);
}
/**
@notice Returns the size of the code on a given address
@param _addr Address that may or may not contain code
@return size of the code on the given `_addr`
*/
function codeSize(address _addr) internal view returns (uint256 size) {
assembly {
size := extcodesize(_addr)
}
}
/**
@notice Returns the code of a given address
@dev It will fail if `_end < _start`
@param _addr Address that may or may not contain code
@param _start number of bytes of code to skip on read
@param _end index before which to end extraction
@return oCode read from `_addr` deployed bytecode
Forked from: https://gist.github.com/KardanovIR/fe98661df9338c842b4a30306d507fbd
*/
function codeAt(
address _addr,
uint256 _start,
uint256 _end
) internal view returns (bytes memory oCode) {
uint256 csize = codeSize(_addr);
if (csize == 0) return bytes('');
if (_start > csize) return bytes('');
if (_end < _start) revert InvalidCodeAtRange(csize, _start, _end);
unchecked {
uint256 reqSize = _end - _start;
uint256 maxSize = csize - _start;
uint256 size = maxSize < reqSize ? maxSize : reqSize;
assembly {
// allocate output byte array - this could also be done without assembly
// by using o_code = new bytes(size)
oCode := mload(0x40)
// new "memory end" including padding
mstore(0x40, add(oCode, and(add(add(size, 0x20), 0x1f), not(0x1f))))
// store length in memory
mstore(oCode, size)
// actually retrieve the code, this needs assembly
extcodecopy(_addr, add(oCode, 0x20), _start, size)
}
}
}
}// 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
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
interface IRenderer is IERC165 {
function name() external view returns (string memory);
function owner() external view returns (address);
function propsSize() external view returns (uint256);
function additionalMetadataURI() external view returns (string memory);
function renderAttributeKey() external view returns (string memory);
function renderRaw(bytes calldata props) external view returns (bytes memory);
function render(bytes calldata props) external view returns (string memory);
function attributes(bytes calldata props) external view returns (string memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/Strings.sol";
library SvgUtils {
using Strings for uint256;
uint public constant DECIMALS = 4;
uint public constant ONE_UNIT = 10 ** DECIMALS;
function padZeros(string memory s, uint len) public pure returns (string memory) {
uint local_len = bytes(s).length;
string memory local_s = s;
while(local_len < len) {
local_s = string(abi.encodePacked('0', local_s));
local_len++;
}
return local_s;
}
function wholeNumber(uint n) public pure returns (uint) {
return n / ONE_UNIT;
}
function decimals(uint n) public pure returns (uint) {
return n % ONE_UNIT;
}
function toDecimalString(uint n) public pure returns (string memory s) {
if (n == 0) return '0';
s = string(abi.encodePacked(
(n / (ONE_UNIT)).toString(), '.' , padZeros((n % ONE_UNIT).toString(), DECIMALS)
));
}
function lerpWithDecimals(uint min, uint max, bytes1 scale) public pure returns (uint) {
if (scale == 0x0) return min * ONE_UNIT;
if (scale == 0xff) return max * ONE_UNIT;
uint delta = ((max - min) * ONE_UNIT * uint(uint8(scale))) / 255;
return (min * ONE_UNIT) + delta;
}
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toColorHexString(uint256 value) public pure returns (string memory) {
bytes memory buffer = new bytes(2 * 3 + 1);
buffer[0] = "#";
for (uint256 i = 2 * 3; i > 0; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toColorHexStringByBytes(bytes1 r, bytes1 g, bytes1 b) public pure returns (string memory) {
bytes memory buffer = new bytes(7);
buffer[0] = "#";
buffer[2] = _HEX_SYMBOLS[uint8(r) & 0xf];
r >>= 4;
buffer[1] = _HEX_SYMBOLS[uint8(r) & 0xf];
buffer[4] = _HEX_SYMBOLS[uint8(g) & 0xf];
g >>= 4;
buffer[3] = _HEX_SYMBOLS[uint8(g) & 0xf];
buffer[6] = _HEX_SYMBOLS[uint8(b) & 0xf];
b >>= 4;
buffer[5] = _HEX_SYMBOLS[uint8(b) & 0xf];
return string(buffer);
}
function toColorHexStringByBytes3(bytes3 rgb) public pure returns (string memory) {
return toColorHexStringByBytes(rgb[0], rgb[1], rgb[2]);
}
}// 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
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerQueryForNonexistentToken();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _burnCounter;
// Token name
string internal _name;
// Token symbol
string internal _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// 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;
constructor() {
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
*/
function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
// Counter underflow is impossible as _currentIndex does not decrement,
// and it is initialized to _startTokenId()
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @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 override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberMinted);
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberBurned);
}
/**
* Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return _addressData[owner].aux;
}
/**
* Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal {
_addressData[owner].aux = aux;
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function _ownershipOf(uint256 tokenId)
internal
view
returns (TokenOwnership memory)
{
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr && curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _ownershipOf(tokenId).addr;
}
/**
* @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)
{
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
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 overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_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 {
_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 {
_transfer(from, to, tokenId);
if (
to.isContract() &&
!_checkContractOnERC721Received(from, to, tokenId, _data)
) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @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`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex &&
!_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (safe && to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (
!_checkContractOnERC721Received(
address(0),
to,
updatedIndex++,
_data
)
) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) private {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = to;
currSlot.startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev This is equivalent to _burn(tokenId, false)
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
address from = prevOwnership.addr;
if (approvalCheck) {
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
AddressData storage addressData = _addressData[from];
addressData.balance -= 1;
addressData.numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = from;
currSlot.startTimestamp = uint64(block.timestamp);
currSlot.burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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 _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try
IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data)
returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
* And also called before burning one token.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
* And also called after one token has been burned.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/utils/math/Math.sol';
import '@openzeppelin/contracts/utils/math/SafeMath.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
contract SigmoidThreshold {
using SafeMath for uint256;
using SafeMath for uint64;
struct CurveParams {
uint256 _x;
uint256 minX;
uint256 maxX;
uint256 minY;
uint256 maxY;
}
uint256[23] private slots;
constructor() {
slots[0] = 1000000000000000000;
slots[1] = 994907149075715143;
slots[2] = 988513057369406817;
slots[3] = 982013790037908452;
slots[4] = 970687769248643639;
slots[5] = 952574126822433143;
slots[6] = 924141819978756551;
slots[7] = 880797077977882314;
slots[8] = 817574476193643651;
slots[9] = 731058578630004896;
slots[10] = 622459331201854593;
slots[11] = 500000000000000000;
slots[12] = 377540668798145407;
slots[13] = 268941421369995104;
slots[14] = 182425523806356349;
slots[15] = 119202922022117574;
slots[16] = 75858180021243560;
slots[17] = 47425873177566788;
slots[18] = 29312230751356326;
slots[19] = 17986209962091562;
slots[20] = 11486942630593183;
slots[21] = 5092850924284857;
slots[22] = 0;
}
function getY(CurveParams memory config) public view returns (uint256) {
if (config._x <= config.minX) {
return config.minY;
}
if (config._x >= config.maxX) {
return config.maxY;
}
uint256 slotWidth = config.maxX.sub(config.minX).div(slots.length);
uint256 xa = config._x.sub(config.minX).div(slotWidth);
uint256 xb = Math.min(xa.add(1), slots.length.sub(1));
uint256 slope = slots[xa].sub(slots[xb]).mul(1e18).div(slotWidth);
uint256 wy = slots[xa].add(slope.mul(slotWidth.mul(xa)).div(1e18));
uint256 percentage = 0;
if (wy > slope.mul(config._x).div(1e18)) {
percentage = wy.sub(slope.mul(config._x).div(1e18));
} else {
percentage = slope.mul(config._x).div(1e18).sub(wy);
}
uint256 result = config.minY.add(
config.maxY.sub(config.minY).mul(percentage).div(1e18)
);
return config.maxY.sub(result); // inverse curve to be LOW => HIGH
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './RendererPropsStorage.sol';
import './ChunkedDataStorage.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/Base64.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@abf-monorepo/protocol/contracts/renderers/LayerCompositeRenderer.sol';
import '@abf-monorepo/protocol/contracts/libraries/BytesUtils.sol';
contract RarityCompositingEngine is Ownable {
uint256 public constant MAX_UINT_16 = 0xFFFF;
uint256 public constant RARITY_DATA_TUPLE_NUM_BYTES = 4;
address public immutable COMPOSITING_RENDERER;
address public immutable ATTRIBUTE_RENDERER;
uint256 public immutable MAX_LAYERS;
bytes public GLOBAL_ATTRIBUTE_PREFIX;
// storage contracts
RendererPropsStorage public rendererPropsStorage;
ChunkedDataStorage public layerStorage;
ChunkedDataStorage public attributeStorage;
uint256 constant NUM_DECIMALS = 2; // units are in bps
uint256 constant ONE_UNIT = 10**NUM_DECIMALS; // represents 0.01x
uint256 constant ONE_HUNDRED_PERCENT = 100 * ONE_UNIT; // represents 1.00x
struct LayerData {
uint8 layerType;
bytes rarityData;
}
struct AttributeData {
bool shouldShowInAttributes;
bool shouldShowInRendererProps;
uint16 rendererDataIndex;
string key;
string value;
bytes prefix;
}
constructor(
uint256 _maxLayers,
address _compositingRenderer,
address _attributeRenderer,
bytes memory _globalAttributePrefix,
address _rendererPropsStorage,
address _layerStorage,
address _attributeStorage
) {
MAX_LAYERS = _maxLayers;
COMPOSITING_RENDERER = _compositingRenderer;
ATTRIBUTE_RENDERER = _attributeRenderer;
GLOBAL_ATTRIBUTE_PREFIX = _globalAttributePrefix;
rendererPropsStorage = RendererPropsStorage(_rendererPropsStorage);
layerStorage = ChunkedDataStorage(_layerStorage);
attributeStorage = ChunkedDataStorage(_attributeStorage);
}
function setRendererPropsStorage(address _rendererPropsStorage)
public
onlyOwner
{
rendererPropsStorage = RendererPropsStorage(_rendererPropsStorage);
}
function setLayerStorage(address _layerStorage) public onlyOwner {
layerStorage = ChunkedDataStorage(_layerStorage);
}
function setAttributeStorage(address _attributeStorage) public onlyOwner {
attributeStorage = ChunkedDataStorage(_attributeStorage);
}
function decodeLayerData(bytes memory data)
public
pure
returns (LayerData memory ld)
{
if (data.length != 0) {
ld.layerType = uint8(data[0]);
ld.rarityData = BytesUtils.slice(data, 1, data.length - 1);
}
}
function decodeAttributeData(bytes memory data)
public
pure
returns (AttributeData memory ad)
{
if (data.length != 0) {
ad.shouldShowInAttributes = uint8(data[0]) == 1;
ad.shouldShowInRendererProps = uint8(data[1]) == 1;
ad.rendererDataIndex = BytesUtils.toUint16(data, 2);
uint8 keyLength = uint8(data[4]);
ad.key = string(BytesUtils.slice(data, 5, keyLength));
uint8 valueLength = uint8(data[5 + keyLength]);
ad.value = string(BytesUtils.slice(data, 6 + keyLength, valueLength));
ad.prefix = BytesUtils.slice(
data,
6 + keyLength + valueLength,
data.length - (6 + keyLength + valueLength)
);
}
}
function resolveLayerIndex(
uint16[] memory attributeIndexes,
uint256 layerIndex
) public view returns (uint256) {
require(
layerIndex != 0,
'RarityCompositingEngine: layerIndex can not be zero'
);
LayerData memory layerData = decodeLayerData(
layerStorage.indexToData(layerIndex)
);
if (layerData.layerType == 1) {
uint16 rootAttributeIndex = attributeIndexes[
BytesUtils.toUint16(layerData.rarityData, 0)
];
require(
rootAttributeIndex != 0,
'RarityCompositingEngine: Root attribute has not been set yet'
);
uint256 dependentLayerIndex = 0;
for (uint256 j = 2; j < layerData.rarityData.length; j += 4) {
if (
BytesUtils.toUint16(layerData.rarityData, j) == rootAttributeIndex
) {
dependentLayerIndex = BytesUtils.toUint16(
layerData.rarityData,
j + 2
);
break;
}
}
require(
dependentLayerIndex != 0,
'RarityCompositingEngine: No dependent layerIndex was found'
);
return resolveLayerIndex(attributeIndexes, dependentLayerIndex);
} else if (layerData.layerType == 0) {
return layerIndex;
}
return 0;
}
function applyRarityMultiplier(
uint256 rarityMultiplier,
uint256[] memory rarityData
)
public
pure
returns (
uint256 appliedRaritySum,
uint256[] memory appliedRarityData,
uint256[] memory rarityMultipliers
)
{
rarityMultipliers = new uint256[](rarityData.length);
if (rarityData.length == 0) {
return (0, rarityData, rarityMultipliers);
}
if (rarityData.length == 2) {
return (rarityData[1], rarityData, rarityMultipliers);
}
// sum the current rarity values
uint256 highestRarityWeight = rarityData[1];
uint256 lowestRarityWeight = rarityData[rarityData.length - 1];
if (highestRarityWeight - lowestRarityWeight == 0) {
for (uint256 i = 1; i < rarityData.length; i += 2) {
appliedRaritySum += rarityData[i];
}
return (appliedRaritySum, rarityData, rarityMultipliers);
}
appliedRarityData = rarityData;
uint256 a = (rarityMultiplier * ONE_UNIT) /
((highestRarityWeight - lowestRarityWeight)**2);
for (uint256 i = 1; i < rarityData.length; i += 2) {
uint256 scaledRarityMultiplier = (a *
(highestRarityWeight - rarityData[i])**2) / ONE_UNIT;
uint256 appliedRarity = ((ONE_HUNDRED_PERCENT + scaledRarityMultiplier) *
rarityData[i]) / ONE_UNIT;
rarityMultipliers[i] = scaledRarityMultiplier;
appliedRarityData[i] = appliedRarity;
appliedRaritySum += appliedRarityData[i];
}
}
function getRarity(uint256 rarityMultiplier, bytes memory seed)
public
view
returns (uint256[] memory layerIndexes, uint16[] memory attributeIndexes)
{
// attributeIndexes are the keys to the actual visual output data for a specific layer index
attributeIndexes = new uint16[](MAX_LAYERS);
// layerIndexes are the keys to the actual layer and its corresponding rarity data
layerIndexes = new uint256[](MAX_LAYERS);
// set default layer indexes
for (uint16 i = 0; i < MAX_LAYERS; ++i) {
layerIndexes[i] = i + 1;
}
for (uint16 i = 0; i < MAX_LAYERS; ++i) {
layerIndexes[i] = resolveLayerIndex(attributeIndexes, layerIndexes[i]);
LayerData memory layerData = decodeLayerData(
layerStorage.indexToData(layerIndexes[i])
);
uint256 randomSource = uint256(keccak256(abi.encodePacked(seed, i)));
uint256[] memory rarityData = new uint256[](
(layerData.rarityData.length) / 2
);
for (uint256 j = 0; j < layerData.rarityData.length; j += 2) {
rarityData[j / 2] = BytesUtils.toUint16(layerData.rarityData, j);
}
(
uint256 appliedRaritySum,
uint256[] memory appliedRarityData,
) = applyRarityMultiplier(rarityMultiplier, rarityData);
// get attribute for this layer
uint16 attributeIndex = 0;
uint256 rarityValue = randomSource % appliedRaritySum;
uint256 acc = 0;
for (uint256 j = 1; j < appliedRarityData.length; j += 2) {
acc += appliedRarityData[j];
if (acc >= rarityValue) {
attributeIndex = uint16(appliedRarityData[j - 1]);
break;
}
}
require(
attributeIndex != 0,
'RarityCompositingEngine: No attribute was found for layer.'
);
attributeIndexes[i] = attributeIndex;
}
}
function getRendererProps(uint16[] memory attributeIndexes)
public
view
returns (address[] memory renderers, bytes[] memory rendererProps)
{
uint256 numNonrendereredAttributes = 0;
for (uint256 i = 0; i < attributeIndexes.length; ++i) {
AttributeData memory ad = decodeAttributeData(
attributeStorage.indexToData(attributeIndexes[i])
);
if (!ad.shouldShowInRendererProps) {
numNonrendereredAttributes++;
}
}
renderers = new address[](
attributeIndexes.length - numNonrendereredAttributes
);
rendererProps = new bytes[](
attributeIndexes.length - numNonrendereredAttributes
);
uint256 numRenderersStored = 0;
for (uint256 i = 0; i < attributeIndexes.length; ++i) {
AttributeData memory ad = decodeAttributeData(
attributeStorage.indexToData(attributeIndexes[i])
);
if (ad.shouldShowInRendererProps) {
uint256 rendererIndex = attributeIndexes.length -
numNonrendereredAttributes -
1 -
numRenderersStored;
renderers[rendererIndex] = ATTRIBUTE_RENDERER;
rendererProps[rendererIndex] = abi.encodePacked(
GLOBAL_ATTRIBUTE_PREFIX,
ad.prefix,
rendererPropsStorage.indexToRendererProps(ad.rendererDataIndex)
);
numRenderersStored++;
}
}
}
function getAttributesJSON(uint16[] memory attributeIndexes)
public
view
returns (string memory)
{
bytes memory attributes = '[';
for (uint256 i = 0; i < attributeIndexes.length; ++i) {
AttributeData memory ad = decodeAttributeData(
attributeStorage.indexToData(attributeIndexes[i])
);
if (ad.shouldShowInAttributes) {
attributes = abi.encodePacked(
attributes,
(attributes.length == 1) ? '' : ',',
'{"value":"',
ad.value,
'","trait_type":"',
ad.key,
'"}'
);
}
}
attributes = abi.encodePacked(attributes, ']');
return string(attributes);
}
function getRender(uint16[] memory attributeIndexes)
public
view
returns (string memory)
{
LayerCompositeRenderer renderer = LayerCompositeRenderer(
COMPOSITING_RENDERER
);
(
address[] memory renderers,
bytes[] memory rendererProps
) = getRendererProps(attributeIndexes);
return renderer.render(renderer.encodeProps(renderers, rendererProps));
}
function getRenderRaw(uint16[] memory attributeIndexes)
public
view
returns (bytes memory)
{
LayerCompositeRenderer renderer = LayerCompositeRenderer(
COMPOSITING_RENDERER
);
(
address[] memory renderers,
bytes[] memory rendererProps
) = getRendererProps(attributeIndexes);
return renderer.renderRaw(renderer.encodeProps(renderers, rendererProps));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// 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 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.7.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 functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev 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) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @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 (last updated v4.7.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. It 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)`.
// We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
// This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
// Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
// good first aproximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1;
uint256 x = a;
if (x >> 128 > 0) {
x >>= 128;
result <<= 64;
}
if (x >> 64 > 0) {
x >>= 64;
result <<= 32;
}
if (x >> 32 > 0) {
x >>= 32;
result <<= 16;
}
if (x >> 16 > 0) {
x >>= 16;
result <<= 8;
}
if (x >> 8 > 0) {
x >>= 8;
result <<= 4;
}
if (x >> 4 > 0) {
x >>= 4;
result <<= 2;
}
if (x >> 2 > 0) {
result <<= 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) {
uint256 result = sqrt(a);
if (rounding == Rounding.Up && result * result < a) {
result += 1;
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import './libraries/SSTORE2Map.sol';
import './interfaces/IDataStorage.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/Base64.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@abf-monorepo/protocol/contracts/libraries/BytesUtils.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
contract ChunkedDataStorage is IDataStorage, Ownable, ERC165 {
uint256 public constant MAX_UINT_16 = 0xFFFF;
mapping(uint256 => uint256) public numLayerDataInChunk;
uint256 public currentMaxChunksIndex = 0;
constructor() {}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IDataStorage).interfaceId ||
super.supportsInterface(interfaceId);
}
function batchAddChunkedData(bytes[] calldata data) public onlyOwner {
numLayerDataInChunk[currentMaxChunksIndex] = data.length;
bytes memory chunkedLayerData = '';
for (uint256 i = 0; i < data.length; ++i) {
require(
data[i].length <= MAX_UINT_16,
'ChunkedDataStorage: data exceeds size of 0xFFFF'
);
chunkedLayerData = abi.encodePacked(
chunkedLayerData,
uint16(data[i].length),
data[i]
);
}
SSTORE2Map.write(bytes32(currentMaxChunksIndex), chunkedLayerData);
currentMaxChunksIndex++;
}
function indexToData(uint256 index) public view returns (bytes memory) {
uint256 currentChunkIndex = 0;
uint256 currentIndex = 0;
do {
currentIndex += numLayerDataInChunk[currentChunkIndex];
currentChunkIndex++;
if (numLayerDataInChunk[currentChunkIndex] == 0) {
break;
}
} while (currentIndex <= index);
currentChunkIndex--;
currentIndex -= numLayerDataInChunk[currentChunkIndex];
uint256 localChunkIndex = index - currentIndex;
bytes memory chunkedData = SSTORE2Map.read(bytes32(currentChunkIndex));
uint256 localChunkIndexPointer = 0;
for (uint256 i = 0; i < chunkedData.length; i += 0) {
if (localChunkIndexPointer == localChunkIndex) {
return
BytesUtils.slice(
chunkedData,
i + 2,
BytesUtils.toUint16(chunkedData, i)
);
}
i += BytesUtils.toUint16(chunkedData, i) + 2;
localChunkIndexPointer++;
}
return '';
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}{
"optimizer": {
"enabled": false,
"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":[{"components":[{"internalType":"address","name":"merge","type":"address"},{"internalType":"address","name":"baseManaStorage","type":"address"},{"internalType":"uint256","name":"manaBoostRitualMultiplier","type":"uint256"},{"internalType":"uint256","name":"maxManaBoostRitualBalance","type":"uint256"},{"internalType":"uint256","name":"baseManaMultiplier","type":"uint256"},{"internalType":"uint256","name":"numDecimals","type":"uint256"}],"internalType":"struct MergeMana.DeployMergeManaConfig","name":"config","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"booster","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BoostedMana","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"shutdown","type":"bool"}],"name":"ChangedEmergencyShutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"from","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ChanneledStatue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ConsumedMana","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IncreasedMana","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"baseManaMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseManaStorage","outputs":[{"internalType":"contract IDataStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"boostedMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"from","type":"uint256[]"},{"internalType":"uint256","name":"to","type":"uint256"}],"name":"channelManaRitual","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"channeledMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"channelingRitualDestinationTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"consumeMana","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"consumedMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyShutdown","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"booster","type":"address"}],"name":"getBoostManaRitualAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getBoostedMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getChanneledMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getInherentMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getInherentManaWithNoPenalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getManaDecay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getTotalMana","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getTotalManaPenalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getTotalManaWithNoPenalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"increaseMana","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isChannelingRitualActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMergeByDifficulty","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"manaBoostRitual","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manaBoostRitualMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manaDecayPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manaDecayStartBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"manaModifier","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxManaBoostRitualBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merge","outputs":[{"internalType":"contract Merge","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"numChanneledToTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"from","type":"uint256[]"},{"internalType":"uint256","name":"to","type":"uint256"}],"name":"safeChannelManaRitual","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"safeManaBoostRitual","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_baseManaMultiplier","type":"uint256"}],"name":"setBaseManaMultiplier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseManaStorage","type":"address"}],"name":"setBaseManaStorage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"shutdown","type":"bool"}],"name":"setEmergencyShutdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isChannelingRitualActive","type":"bool"}],"name":"setIsChannelingRitualActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_manaBoostRitualMultiplier","type":"uint256"}],"name":"setManaBoostRitualMultiplier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_manaDecayPerBlock","type":"uint256"}],"name":"setManaDecayPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_manaDecayStartBlock","type":"uint256"}],"name":"setManaDecayStartBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_manaModifier","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setManaModifier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxManaBoostRitualBalance","type":"uint256"}],"name":"setMaxManaBoostRitualBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_merge","type":"address"}],"name":"setMerge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numDecimals","type":"uint256"}],"name":"setNumDecimals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040526000600160146101000a81548160ff0219169083151502179055506000600c60006101000a81548160ff0219169083151502179055503480156200004757600080fd5b506040516200335c3803806200335c83398181016040528101906200006d919062000410565b6200008d620000816200014a60201b60201c565b6200015260201b60201c565b8060000151600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060400151600a819055508060200151600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060600151600b8190555080608001516004819055508060a001516002819055505062000442565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b62000275826200022a565b810181811067ffffffffffffffff821117156200029757620002966200023b565b5b80604052505050565b6000620002ac62000216565b9050620002ba82826200026a565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620002ec82620002bf565b9050919050565b620002fe81620002df565b81146200030a57600080fd5b50565b6000815190506200031e81620002f3565b92915050565b6000819050919050565b620003398162000324565b81146200034557600080fd5b50565b60008151905062000359816200032e565b92915050565b600060c0828403121562000378576200037762000225565b5b6200038460c0620002a0565b9050600062000396848285016200030d565b6000830152506020620003ac848285016200030d565b6020830152506040620003c28482850162000348565b6040830152506060620003d88482850162000348565b6060830152506080620003ee8482850162000348565b60808301525060a0620004048482850162000348565b60a08301525092915050565b600060c0828403121562000429576200042862000220565b5b600062000439848285016200035f565b91505092915050565b612f0a80620004526000396000f3fe608060405234801561001057600080fd5b50600436106102895760003560e01c806379a244931161015c578063d4433a8f116100ce578063ef1da90111610087578063ef1da901146107e4578063ef9d2ca314610800578063f2fde38b14610830578063f9242c541461084c578063fa13007d1461086a578063fae2d28e1461089a57610289565b8063d4433a8f14610738578063d5db330a14610754578063de615a1e14610772578063e224d5e81461078e578063e6df5d13146107ac578063e7016da0146107c857610289565b8063b1a9a89711610120578063b1a9a89714610654578063b49757a614610670578063c14a10811461068c578063c7821b29146106bc578063cf0f8a3f146106ec578063d43758b71461070857610289565b806379a244931461059a5780638da5cb5b146105b857806392d704a3146105d6578063976af3ca146105f4578063aae7dfaf1461062457610289565b80635123b01a11610200578063624ba675116101b9578063624ba675146104c857806368d61e6c146104f85780636e9844ac14610528578063706348e214610558578063715018a6146105745780637439baab1461057e57610289565b80635123b01a146103de57806351d38fb71461040e57806358258c2b1461043e57806359619e5e1461045c5780635d7656401461047a5780635f17f7b41461049857610289565b80631b3f74a9116102525780631b3f74a9146103325780632e075cdc1461035057806333adf3841461036c5780633403c2fc14610388578063434b9039146103a657806345d5007e146103c257610289565b80625d8caa1461028e578063077060af146102aa5780630b65108b146102c857806314c64402146102e6578063184fa0ed14610302575b600080fd5b6102a860048036038101906102a39190612032565b6108b6565b005b6102b26108c8565b6040516102bf919061206e565b60405180910390f35b6102d06108ce565b6040516102dd9190612108565b60405180910390f35b61030060048036038101906102fb919061215b565b6108f4565b005b61031c60048036038101906103179190612032565b610950565b604051610329919061206e565b60405180910390f35b61033a610968565b604051610347919061206e565b60405180910390f35b61036a60048036038101906103659190612188565b61096e565b005b61038660048036038101906103819190612321565b610b10565b005b610390610c39565b60405161039d919061238c565b60405180910390f35b6103c060048036038101906103bb91906123e5565b610c4c565b005b6103dc60048036038101906103d79190612188565b610c98565b005b6103f860048036038101906103f39190612032565b610e26565b604051610405919061206e565b60405180910390f35b61042860048036038101906104239190612032565b610e5e565b604051610435919061206e565b60405180910390f35b610446610e76565b604051610453919061238c565b60405180910390f35b610464610e94565b604051610471919061238c565b60405180910390f35b610482610ea7565b60405161048f919061206e565b60405180910390f35b6104b260048036038101906104ad91906123e5565b610ead565b6040516104bf919061238c565b60405180910390f35b6104e260048036038101906104dd9190612032565b610ecd565b6040516104ef919061206e565b60405180910390f35b610512600480360381019061050d9190612032565b61103b565b60405161051f919061206e565b60405180910390f35b610542600480360381019061053d9190612032565b611053565b60405161054f919061206e565b60405180910390f35b610572600480360381019061056d9190612032565b61106b565b005b61057c61107d565b005b61059860048036038101906105939190612412565b611091565b005b6105a2611337565b6040516105af919061247c565b60405180910390f35b6105c061135d565b6040516105cd91906124a6565b60405180910390f35b6105de611386565b6040516105eb919061206e565b60405180910390f35b61060e60048036038101906106099190612032565b61138c565b60405161061b919061206e565b60405180910390f35b61063e60048036038101906106399190612032565b6113da565b60405161064b919061206e565b60405180910390f35b61066e60048036038101906106699190612032565b61147b565b005b61068a600480360381019061068591906123e5565b61148d565b005b6106a660048036038101906106a19190612032565b6114d9565b6040516106b3919061206e565b60405180910390f35b6106d660048036038101906106d19190612032565b611590565b6040516106e3919061206e565b60405180910390f35b61070660048036038101906107019190612032565b6115ca565b005b610722600480360381019061071d9190612032565b6115dc565b60405161072f919061206e565b60405180910390f35b610752600480360381019061074d9190612412565b611637565b005b61075c61186d565b604051610769919061206e565b60405180910390f35b61078c60048036038101906107879190612032565b611873565b005b610796611885565b6040516107a3919061206e565b60405180910390f35b6107c660048036038101906107c1919061215b565b61188b565b005b6107e260048036038101906107dd9190612032565b6118f6565b005b6107fe60048036038101906107f99190612321565b611908565b005b61081a60048036038101906108159190612032565b611aa1565b604051610827919061206e565b60405180910390f35b61084a600480360381019061084591906123e5565b611ab9565b005b610854611b3d565b604051610861919061206e565b60405180910390f35b610884600480360381019061087f91906123e5565b611b73565b604051610891919061206e565b60405180910390f35b6108b460048036038101906108af91906124c1565b611d00565b005b6108be611d63565b8060048190555050565b600b5481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6108fc611d63565b80600160146101000a81548160ff0219169083151502179055507fb28c3d380b31a9985118fb02f15e73682e9338a972a19723b46ac25b4feb9dc081604051610945919061238c565b60405180910390a150565b60076020528060005260406000206000915090505481565b60095481565b600160149054906101000a900460ff16156109be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b590612584565b60405180910390fd5b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610a4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a41906125f0565b60405180910390fd5b6000600d6000848152602001908152602001600020541415610a955780600660008481526020019081526020016000206000828254610a89919061263f565b92505081905550610ad3565b80600e6000600d60008681526020019081526020016000205481526020019081526020016000206000828254610acb919061263f565b925050819055505b7f9b6f636467cbdcf59f1aad8fc897e1913283780653328048b33b01bce84e351a8282604051610b04929190612695565b60405180910390a15050565b600c60009054906101000a900460ff16610b5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5690612730565b60405180910390fd5b600160149054906101000a900460ff1615610baf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba690612584565b60405180910390fd5b60005b8251811015610c345760008214158015610bf957506000600d6000858481518110610be057610bdf612750565b5b6020026020010151815260200190815260200160002054145b15610c2357610c22838281518110610c1457610c13612750565b5b602002602001015183611de1565b5b80610c2d9061277f565b9050610bb2565b505050565b600160149054906101000a900460ff1681565b610c54611d63565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160149054906101000a900460ff1615610ce8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cdf90612584565b60405180910390fd5b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6b906125f0565b60405180910390fd5b610d7d82610e26565b811115610dbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db69061283a565b60405180910390fd5b80600760008481526020019081526020016000206000828254610de2919061263f565b925050819055507f835fc2c65e775b8f339b96d0cfbcc4e6a02ef00bd9bb2f7f26995d6efb064c608282604051610e1a929190612695565b60405180910390a15050565b6000610e31826115dc565b610e3a836114d9565b610e43846113da565b610e4d919061263f565b610e57919061263f565b9050919050565b600f6020528060005260406000206000915090505481565b600068010000000000000000441180610e8f5750600044145b905090565b600c60009054906101000a900460ff1681565b60025481565b60056020528060005260406000206000915054906101000a900460ff1681565b600080600d60008481526020019081526020016000205414610ef25760009050611036565b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610f525760009050611036565b600454600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318ed981a846040518263ffffffff1660e01b8152600401610fb0919061206e565b60006040518083038186803b158015610fc857600080fd5b505afa158015610fdc573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110059190612933565b60008151811061101857611017612750565b5b602001015160f81c60f81b60f81c60ff16611033919061297c565b90505b919050565b600d6020528060005260406000206000915090505481565b600e6020528060005260406000206000915090505481565b611073611d63565b8060088190555050565b611085611d63565b61108f6000611ec5565b565b611099610e76565b1580156110b35750600c60009054906101000a900460ff16155b6110f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e990612a48565b60405180910390fd5b600160149054906101000a900460ff1615611142576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113990612584565b60405180910390fd5b600061114d33611b73565b905060005b8251811015611332573373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e8584815181106111c3576111c2612750565b5b60200260200101516040518263ffffffff1660e01b81526004016111e7919061206e565b60206040518083038186803b1580156111ff57600080fd5b505afa158015611213573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112379190612a7d565b73ffffffffffffffffffffffffffffffffffffffff161461128d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128490612b1c565b60405180910390fd5b6000600660008584815181106112a6576112a5612750565b5b6020026020010151815260200190815260200160002054146112fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f490612bae565b60405180910390fd5b61132183828151811061131357611312612750565b5b602002602001015183611f89565b8061132b9061277f565b9050611152565b505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60085481565b6000600e60008381526020019081526020016000205460066000848152602001908152602001600020546113bf84610ecd565b6113c9919061263f565b6113d3919061263f565b9050919050565b600080600e600084815260200190815260200160002054600660008581526020019081526020016000205461140f919061263f565b9050600061141c84611590565b9050600061142985610ecd565b90508282111561146f57600083836114419190612bce565b905081811115611458576000945050505050611476565b80826114649190612bce565b945050505050611476565b8093505050505b919050565b611483611d63565b80600a8190555050565b611495611d63565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806114e583611590565b9050600e600084815260200190815260200160002054811115611573576000600e600085815260200190815260200160002054826115239190612bce565b9050600660008581526020019081526020016000205481111561154b5760009250505061158b565b80600660008681526020019081526020016000205461156a9190612bce565b9250505061158b565b60066000848152602001908152602001600020549150505b919050565b60008061159b611b3d565b905060006007600085815260200190815260200160002054905080826115c1919061263f565b92505050919050565b6115d2611d63565b80600b8190555050565b6000806115e883611590565b9050600e60008481526020019081526020016000205481111561160f576000915050611632565b80600e60008581526020019081526020016000205461162e9190612bce565b9150505b919050565b61163f610e76565b1580156116595750600c60009054906101000a900460ff16155b611698576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168f90612a48565b60405180910390fd5b600160149054906101000a900460ff16156116e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116df90612584565b60405180910390fd5b60006116f333611b73565b905060005b8251811015611868573373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e85848151811061176957611768612750565b5b60200260200101516040518263ffffffff1660e01b815260040161178d919061206e565b60206040518083038186803b1580156117a557600080fd5b505afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd9190612a7d565b73ffffffffffffffffffffffffffffffffffffffff1614801561182d575060006006600085848151811061181457611813612750565b5b6020026020010151815260200190815260200160002054145b156118575761185683828151811061184857611847612750565b5b602002602001015183611f89565b5b806118619061277f565b90506116f8565b505050565b60045481565b61187b611d63565b8060028190555050565b600a5481565b611893611d63565b80600c60006101000a81548160ff0219169083151502179055507fb28c3d380b31a9985118fb02f15e73682e9338a972a19723b46ac25b4feb9dc0600c60009054906101000a900460ff166040516118eb919061238c565b60405180910390a150565b6118fe611d63565b8060098190555050565b600c60009054906101000a900460ff16611957576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194e90612730565b60405180910390fd5b600160149054906101000a900460ff16156119a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199e90612584565b60405180910390fd5b60005b8251811015611a9c5760008214156119f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ee90612c74565b60405180910390fd5b6000600d6000858481518110611a1057611a0f612750565b5b602002602001015181526020019081526020016000205414611a67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5e90612d06565b60405180910390fd5b611a8b838281518110611a7d57611a7c612750565b5b602002602001015183611de1565b80611a959061277f565b90506119aa565b505050565b60066020528060005260406000206000915090505481565b611ac1611d63565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2890612d98565b60405180910390fd5b611b3a81611ec5565b50565b6000806009541415611b525760009050611b70565b60085460095443611b639190612bce565b611b6d919061297c565b90505b90565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231846040518263ffffffff1660e01b8152600401611bd191906124a6565b60206040518083038186803b158015611be957600080fd5b505afa158015611bfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c219190612dcd565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a162b9c846040518263ffffffff1660e01b8152600401611c7e91906124a6565b60206040518083038186803b158015611c9657600080fd5b505afa158015611caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cce9190612dcd565b600b548211611cdd5781611ce1565b600b545b600a54611cee919061297c565b611cf8919061297c565b915050919050565b611d08611d63565b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b611d6b611fe0565b73ffffffffffffffffffffffffffffffffffffffff16611d8961135d565b73ffffffffffffffffffffffffffffffffffffffff1614611ddf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dd690612e46565b60405180910390fd5b565b6000611dec836114d9565b611df5846113da565b611dff919061263f565b905080600e60008481526020019081526020016000206000828254611e24919061263f565b92505081905550600f60008381526020019081526020016000206000815480929190611e4f9061277f565b919050555081600d600085815260200190815260200160002081905550600060066000858152602001908152602001600020819055507fe79f3148c0423b65874ebb948d20564b5fe3dcdb8eda7400ccfc776e76b1e2f5838383604051611eb893929190612e66565b60405180910390a1505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8060066000848152602001908152602001600020819055507f226e949884706db1e15d9b679b05e7f223fc30b0db0035125eaf3ec56f822472338383604051611fd493929190612e9d565b60405180910390a15050565b600033905090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61200f81611ffc565b811461201a57600080fd5b50565b60008135905061202c81612006565b92915050565b60006020828403121561204857612047611ff2565b5b60006120568482850161201d565b91505092915050565b61206881611ffc565b82525050565b6000602082019050612083600083018461205f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006120ce6120c96120c484612089565b6120a9565b612089565b9050919050565b60006120e0826120b3565b9050919050565b60006120f2826120d5565b9050919050565b612102816120e7565b82525050565b600060208201905061211d60008301846120f9565b92915050565b60008115159050919050565b61213881612123565b811461214357600080fd5b50565b6000813590506121558161212f565b92915050565b60006020828403121561217157612170611ff2565b5b600061217f84828501612146565b91505092915050565b6000806040838503121561219f5761219e611ff2565b5b60006121ad8582860161201d565b92505060206121be8582860161201d565b9150509250929050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612216826121cd565b810181811067ffffffffffffffff82111715612235576122346121de565b5b80604052505050565b6000612248611fe8565b9050612254828261220d565b919050565b600067ffffffffffffffff821115612274576122736121de565b5b602082029050602081019050919050565b600080fd5b600061229d61229884612259565b61223e565b905080838252602082019050602084028301858111156122c0576122bf612285565b5b835b818110156122e957806122d5888261201d565b8452602084019350506020810190506122c2565b5050509392505050565b600082601f830112612308576123076121c8565b5b813561231884826020860161228a565b91505092915050565b6000806040838503121561233857612337611ff2565b5b600083013567ffffffffffffffff81111561235657612355611ff7565b5b612362858286016122f3565b92505060206123738582860161201d565b9150509250929050565b61238681612123565b82525050565b60006020820190506123a1600083018461237d565b92915050565b60006123b282612089565b9050919050565b6123c2816123a7565b81146123cd57600080fd5b50565b6000813590506123df816123b9565b92915050565b6000602082840312156123fb576123fa611ff2565b5b6000612409848285016123d0565b91505092915050565b60006020828403121561242857612427611ff2565b5b600082013567ffffffffffffffff81111561244657612445611ff7565b5b612452848285016122f3565b91505092915050565b6000612466826120d5565b9050919050565b6124768161245b565b82525050565b6000602082019050612491600083018461246d565b92915050565b6124a0816123a7565b82525050565b60006020820190506124bb6000830184612497565b92915050565b600080604083850312156124d8576124d7611ff2565b5b60006124e6858286016123d0565b92505060206124f785828601612146565b9150509250929050565b600082825260208201905092915050565b7f4d657267654d616e613a20456d657267656e63792073687574646f776e20697360008201527f20696e20706c6163650000000000000000000000000000000000000000000000602082015250565b600061256e602983612501565b915061257982612512565b604082019050919050565b6000602082019050818103600083015261259d81612561565b9050919050565b7f4d657267654d616e613a204e6f742061206d616e61206d6f6469666965720000600082015250565b60006125da601e83612501565b91506125e5826125a4565b602082019050919050565b60006020820190508181036000830152612609816125cd565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061264a82611ffc565b915061265583611ffc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561268a57612689612610565b5b828201905092915050565b60006040820190506126aa600083018561205f565b6126b7602083018461205f565b9392505050565b7f4d657267654d616e613a20416374696f6e206f6e6c792063616e206f6363757260008201527f206166746572206d657267650000000000000000000000000000000000000000602082015250565b600061271a602c83612501565b9150612725826126be565b604082019050919050565b600060208201905081810360008301526127498161270d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600061278a82611ffc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156127bd576127bc612610565b5b600182019050919050565b7f4d657267654d616e613a2043616e206e6f7420636f6e73756d65206d6f72652060008201527f6d616e61207468616e20776861742065786973747320696e2073746174756500602082015250565b6000612824603f83612501565b915061282f826127c8565b604082019050919050565b6000602082019050818103600083015261285381612817565b9050919050565b600080fd5b600067ffffffffffffffff82111561287a576128796121de565b5b612883826121cd565b9050602081019050919050565b60005b838110156128ae578082015181840152602081019050612893565b838111156128bd576000848401525b50505050565b60006128d66128d18461285f565b61223e565b9050828152602081018484840111156128f2576128f161285a565b5b6128fd848285612890565b509392505050565b600082601f83011261291a576129196121c8565b5b815161292a8482602086016128c3565b91505092915050565b60006020828403121561294957612948611ff2565b5b600082015167ffffffffffffffff81111561296757612966611ff7565b5b61297384828501612905565b91505092915050565b600061298782611ffc565b915061299283611ffc565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156129cb576129ca612610565b5b828202905092915050565b7f4d657267654d616e613a20416374696f6e206f6e6c792063616e206f6363757260008201527f206265666f7265206d6572676500000000000000000000000000000000000000602082015250565b6000612a32602d83612501565b9150612a3d826129d6565b604082019050919050565b60006020820190508181036000830152612a6181612a25565b9050919050565b600081519050612a77816123b9565b92915050565b600060208284031215612a9357612a92611ff2565b5b6000612aa184828501612a68565b91505092915050565b7f4d657267654d616e613a2043616e206e6f7420626f6f737420746f6b656e207960008201527f6f7520646f206e6f74206f776e00000000000000000000000000000000000000602082015250565b6000612b06602d83612501565b9150612b1182612aaa565b604082019050919050565b60006020820190508181036000830152612b3581612af9565b9050919050565b7f4d657267654d616e613a2043616e206e6f7420626f6f737420746f6b656e732060008201527f746861742061726520616c726561647920626f6f737465640000000000000000602082015250565b6000612b98603883612501565b9150612ba382612b3c565b604082019050919050565b60006020820190508181036000830152612bc781612b8b565b9050919050565b6000612bd982611ffc565b9150612be483611ffc565b925082821015612bf757612bf6612610565b5b828203905092915050565b7f4d657267654d616e613a2043616e206e6f74206368616e6e656c20746f20746f60008201527f6b656e4964207a65726f00000000000000000000000000000000000000000000602082015250565b6000612c5e602a83612501565b9150612c6982612c02565b604082019050919050565b60006020820190508181036000830152612c8d81612c51565b9050919050565b7f4d657267654d616e613a204d616e612068617320616c7265616479206265656e60008201527f206368616e6e656c656400000000000000000000000000000000000000000000602082015250565b6000612cf0602a83612501565b9150612cfb82612c94565b604082019050919050565b60006020820190508181036000830152612d1f81612ce3565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612d82602683612501565b9150612d8d82612d26565b604082019050919050565b60006020820190508181036000830152612db181612d75565b9050919050565b600081519050612dc781612006565b92915050565b600060208284031215612de357612de2611ff2565b5b6000612df184828501612db8565b91505092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612e30602083612501565b9150612e3b82612dfa565b602082019050919050565b60006020820190508181036000830152612e5f81612e23565b9050919050565b6000606082019050612e7b600083018661205f565b612e88602083018561205f565b612e95604083018461205f565b949350505050565b6000606082019050612eb26000830186612497565b612ebf602083018561205f565b612ecc604083018461205f565b94935050505056fea26469706673582212201eef640021462daafb2ad1efa6f15f9bfcbd3df0f4c49c524d648851646664df64736f6c6343000809003300000000000000000000000095cdb0fbf3ccadabba38acc921a9b2381329f7270000000000000000000000008a2f3cf61dbfe039ba26986360a18776d0bf19aa000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000005b8d800000000000000000000000000000000000000000000000000000000000000006
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102895760003560e01c806379a244931161015c578063d4433a8f116100ce578063ef1da90111610087578063ef1da901146107e4578063ef9d2ca314610800578063f2fde38b14610830578063f9242c541461084c578063fa13007d1461086a578063fae2d28e1461089a57610289565b8063d4433a8f14610738578063d5db330a14610754578063de615a1e14610772578063e224d5e81461078e578063e6df5d13146107ac578063e7016da0146107c857610289565b8063b1a9a89711610120578063b1a9a89714610654578063b49757a614610670578063c14a10811461068c578063c7821b29146106bc578063cf0f8a3f146106ec578063d43758b71461070857610289565b806379a244931461059a5780638da5cb5b146105b857806392d704a3146105d6578063976af3ca146105f4578063aae7dfaf1461062457610289565b80635123b01a11610200578063624ba675116101b9578063624ba675146104c857806368d61e6c146104f85780636e9844ac14610528578063706348e214610558578063715018a6146105745780637439baab1461057e57610289565b80635123b01a146103de57806351d38fb71461040e57806358258c2b1461043e57806359619e5e1461045c5780635d7656401461047a5780635f17f7b41461049857610289565b80631b3f74a9116102525780631b3f74a9146103325780632e075cdc1461035057806333adf3841461036c5780633403c2fc14610388578063434b9039146103a657806345d5007e146103c257610289565b80625d8caa1461028e578063077060af146102aa5780630b65108b146102c857806314c64402146102e6578063184fa0ed14610302575b600080fd5b6102a860048036038101906102a39190612032565b6108b6565b005b6102b26108c8565b6040516102bf919061206e565b60405180910390f35b6102d06108ce565b6040516102dd9190612108565b60405180910390f35b61030060048036038101906102fb919061215b565b6108f4565b005b61031c60048036038101906103179190612032565b610950565b604051610329919061206e565b60405180910390f35b61033a610968565b604051610347919061206e565b60405180910390f35b61036a60048036038101906103659190612188565b61096e565b005b61038660048036038101906103819190612321565b610b10565b005b610390610c39565b60405161039d919061238c565b60405180910390f35b6103c060048036038101906103bb91906123e5565b610c4c565b005b6103dc60048036038101906103d79190612188565b610c98565b005b6103f860048036038101906103f39190612032565b610e26565b604051610405919061206e565b60405180910390f35b61042860048036038101906104239190612032565b610e5e565b604051610435919061206e565b60405180910390f35b610446610e76565b604051610453919061238c565b60405180910390f35b610464610e94565b604051610471919061238c565b60405180910390f35b610482610ea7565b60405161048f919061206e565b60405180910390f35b6104b260048036038101906104ad91906123e5565b610ead565b6040516104bf919061238c565b60405180910390f35b6104e260048036038101906104dd9190612032565b610ecd565b6040516104ef919061206e565b60405180910390f35b610512600480360381019061050d9190612032565b61103b565b60405161051f919061206e565b60405180910390f35b610542600480360381019061053d9190612032565b611053565b60405161054f919061206e565b60405180910390f35b610572600480360381019061056d9190612032565b61106b565b005b61057c61107d565b005b61059860048036038101906105939190612412565b611091565b005b6105a2611337565b6040516105af919061247c565b60405180910390f35b6105c061135d565b6040516105cd91906124a6565b60405180910390f35b6105de611386565b6040516105eb919061206e565b60405180910390f35b61060e60048036038101906106099190612032565b61138c565b60405161061b919061206e565b60405180910390f35b61063e60048036038101906106399190612032565b6113da565b60405161064b919061206e565b60405180910390f35b61066e60048036038101906106699190612032565b61147b565b005b61068a600480360381019061068591906123e5565b61148d565b005b6106a660048036038101906106a19190612032565b6114d9565b6040516106b3919061206e565b60405180910390f35b6106d660048036038101906106d19190612032565b611590565b6040516106e3919061206e565b60405180910390f35b61070660048036038101906107019190612032565b6115ca565b005b610722600480360381019061071d9190612032565b6115dc565b60405161072f919061206e565b60405180910390f35b610752600480360381019061074d9190612412565b611637565b005b61075c61186d565b604051610769919061206e565b60405180910390f35b61078c60048036038101906107879190612032565b611873565b005b610796611885565b6040516107a3919061206e565b60405180910390f35b6107c660048036038101906107c1919061215b565b61188b565b005b6107e260048036038101906107dd9190612032565b6118f6565b005b6107fe60048036038101906107f99190612321565b611908565b005b61081a60048036038101906108159190612032565b611aa1565b604051610827919061206e565b60405180910390f35b61084a600480360381019061084591906123e5565b611ab9565b005b610854611b3d565b604051610861919061206e565b60405180910390f35b610884600480360381019061087f91906123e5565b611b73565b604051610891919061206e565b60405180910390f35b6108b460048036038101906108af91906124c1565b611d00565b005b6108be611d63565b8060048190555050565b600b5481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6108fc611d63565b80600160146101000a81548160ff0219169083151502179055507fb28c3d380b31a9985118fb02f15e73682e9338a972a19723b46ac25b4feb9dc081604051610945919061238c565b60405180910390a150565b60076020528060005260406000206000915090505481565b60095481565b600160149054906101000a900460ff16156109be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b590612584565b60405180910390fd5b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610a4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a41906125f0565b60405180910390fd5b6000600d6000848152602001908152602001600020541415610a955780600660008481526020019081526020016000206000828254610a89919061263f565b92505081905550610ad3565b80600e6000600d60008681526020019081526020016000205481526020019081526020016000206000828254610acb919061263f565b925050819055505b7f9b6f636467cbdcf59f1aad8fc897e1913283780653328048b33b01bce84e351a8282604051610b04929190612695565b60405180910390a15050565b600c60009054906101000a900460ff16610b5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5690612730565b60405180910390fd5b600160149054906101000a900460ff1615610baf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba690612584565b60405180910390fd5b60005b8251811015610c345760008214158015610bf957506000600d6000858481518110610be057610bdf612750565b5b6020026020010151815260200190815260200160002054145b15610c2357610c22838281518110610c1457610c13612750565b5b602002602001015183611de1565b5b80610c2d9061277f565b9050610bb2565b505050565b600160149054906101000a900460ff1681565b610c54611d63565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160149054906101000a900460ff1615610ce8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cdf90612584565b60405180910390fd5b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6b906125f0565b60405180910390fd5b610d7d82610e26565b811115610dbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db69061283a565b60405180910390fd5b80600760008481526020019081526020016000206000828254610de2919061263f565b925050819055507f835fc2c65e775b8f339b96d0cfbcc4e6a02ef00bd9bb2f7f26995d6efb064c608282604051610e1a929190612695565b60405180910390a15050565b6000610e31826115dc565b610e3a836114d9565b610e43846113da565b610e4d919061263f565b610e57919061263f565b9050919050565b600f6020528060005260406000206000915090505481565b600068010000000000000000441180610e8f5750600044145b905090565b600c60009054906101000a900460ff1681565b60025481565b60056020528060005260406000206000915054906101000a900460ff1681565b600080600d60008481526020019081526020016000205414610ef25760009050611036565b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610f525760009050611036565b600454600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318ed981a846040518263ffffffff1660e01b8152600401610fb0919061206e565b60006040518083038186803b158015610fc857600080fd5b505afa158015610fdc573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110059190612933565b60008151811061101857611017612750565b5b602001015160f81c60f81b60f81c60ff16611033919061297c565b90505b919050565b600d6020528060005260406000206000915090505481565b600e6020528060005260406000206000915090505481565b611073611d63565b8060088190555050565b611085611d63565b61108f6000611ec5565b565b611099610e76565b1580156110b35750600c60009054906101000a900460ff16155b6110f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e990612a48565b60405180910390fd5b600160149054906101000a900460ff1615611142576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113990612584565b60405180910390fd5b600061114d33611b73565b905060005b8251811015611332573373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e8584815181106111c3576111c2612750565b5b60200260200101516040518263ffffffff1660e01b81526004016111e7919061206e565b60206040518083038186803b1580156111ff57600080fd5b505afa158015611213573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112379190612a7d565b73ffffffffffffffffffffffffffffffffffffffff161461128d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128490612b1c565b60405180910390fd5b6000600660008584815181106112a6576112a5612750565b5b6020026020010151815260200190815260200160002054146112fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f490612bae565b60405180910390fd5b61132183828151811061131357611312612750565b5b602002602001015183611f89565b8061132b9061277f565b9050611152565b505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60085481565b6000600e60008381526020019081526020016000205460066000848152602001908152602001600020546113bf84610ecd565b6113c9919061263f565b6113d3919061263f565b9050919050565b600080600e600084815260200190815260200160002054600660008581526020019081526020016000205461140f919061263f565b9050600061141c84611590565b9050600061142985610ecd565b90508282111561146f57600083836114419190612bce565b905081811115611458576000945050505050611476565b80826114649190612bce565b945050505050611476565b8093505050505b919050565b611483611d63565b80600a8190555050565b611495611d63565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806114e583611590565b9050600e600084815260200190815260200160002054811115611573576000600e600085815260200190815260200160002054826115239190612bce565b9050600660008581526020019081526020016000205481111561154b5760009250505061158b565b80600660008681526020019081526020016000205461156a9190612bce565b9250505061158b565b60066000848152602001908152602001600020549150505b919050565b60008061159b611b3d565b905060006007600085815260200190815260200160002054905080826115c1919061263f565b92505050919050565b6115d2611d63565b80600b8190555050565b6000806115e883611590565b9050600e60008481526020019081526020016000205481111561160f576000915050611632565b80600e60008581526020019081526020016000205461162e9190612bce565b9150505b919050565b61163f610e76565b1580156116595750600c60009054906101000a900460ff16155b611698576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168f90612a48565b60405180910390fd5b600160149054906101000a900460ff16156116e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116df90612584565b60405180910390fd5b60006116f333611b73565b905060005b8251811015611868573373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e85848151811061176957611768612750565b5b60200260200101516040518263ffffffff1660e01b815260040161178d919061206e565b60206040518083038186803b1580156117a557600080fd5b505afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd9190612a7d565b73ffffffffffffffffffffffffffffffffffffffff1614801561182d575060006006600085848151811061181457611813612750565b5b6020026020010151815260200190815260200160002054145b156118575761185683828151811061184857611847612750565b5b602002602001015183611f89565b5b806118619061277f565b90506116f8565b505050565b60045481565b61187b611d63565b8060028190555050565b600a5481565b611893611d63565b80600c60006101000a81548160ff0219169083151502179055507fb28c3d380b31a9985118fb02f15e73682e9338a972a19723b46ac25b4feb9dc0600c60009054906101000a900460ff166040516118eb919061238c565b60405180910390a150565b6118fe611d63565b8060098190555050565b600c60009054906101000a900460ff16611957576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194e90612730565b60405180910390fd5b600160149054906101000a900460ff16156119a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199e90612584565b60405180910390fd5b60005b8251811015611a9c5760008214156119f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ee90612c74565b60405180910390fd5b6000600d6000858481518110611a1057611a0f612750565b5b602002602001015181526020019081526020016000205414611a67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5e90612d06565b60405180910390fd5b611a8b838281518110611a7d57611a7c612750565b5b602002602001015183611de1565b80611a959061277f565b90506119aa565b505050565b60066020528060005260406000206000915090505481565b611ac1611d63565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2890612d98565b60405180910390fd5b611b3a81611ec5565b50565b6000806009541415611b525760009050611b70565b60085460095443611b639190612bce565b611b6d919061297c565b90505b90565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231846040518263ffffffff1660e01b8152600401611bd191906124a6565b60206040518083038186803b158015611be957600080fd5b505afa158015611bfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c219190612dcd565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a162b9c846040518263ffffffff1660e01b8152600401611c7e91906124a6565b60206040518083038186803b158015611c9657600080fd5b505afa158015611caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cce9190612dcd565b600b548211611cdd5781611ce1565b600b545b600a54611cee919061297c565b611cf8919061297c565b915050919050565b611d08611d63565b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b611d6b611fe0565b73ffffffffffffffffffffffffffffffffffffffff16611d8961135d565b73ffffffffffffffffffffffffffffffffffffffff1614611ddf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dd690612e46565b60405180910390fd5b565b6000611dec836114d9565b611df5846113da565b611dff919061263f565b905080600e60008481526020019081526020016000206000828254611e24919061263f565b92505081905550600f60008381526020019081526020016000206000815480929190611e4f9061277f565b919050555081600d600085815260200190815260200160002081905550600060066000858152602001908152602001600020819055507fe79f3148c0423b65874ebb948d20564b5fe3dcdb8eda7400ccfc776e76b1e2f5838383604051611eb893929190612e66565b60405180910390a1505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8060066000848152602001908152602001600020819055507f226e949884706db1e15d9b679b05e7f223fc30b0db0035125eaf3ec56f822472338383604051611fd493929190612e9d565b60405180910390a15050565b600033905090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61200f81611ffc565b811461201a57600080fd5b50565b60008135905061202c81612006565b92915050565b60006020828403121561204857612047611ff2565b5b60006120568482850161201d565b91505092915050565b61206881611ffc565b82525050565b6000602082019050612083600083018461205f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006120ce6120c96120c484612089565b6120a9565b612089565b9050919050565b60006120e0826120b3565b9050919050565b60006120f2826120d5565b9050919050565b612102816120e7565b82525050565b600060208201905061211d60008301846120f9565b92915050565b60008115159050919050565b61213881612123565b811461214357600080fd5b50565b6000813590506121558161212f565b92915050565b60006020828403121561217157612170611ff2565b5b600061217f84828501612146565b91505092915050565b6000806040838503121561219f5761219e611ff2565b5b60006121ad8582860161201d565b92505060206121be8582860161201d565b9150509250929050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612216826121cd565b810181811067ffffffffffffffff82111715612235576122346121de565b5b80604052505050565b6000612248611fe8565b9050612254828261220d565b919050565b600067ffffffffffffffff821115612274576122736121de565b5b602082029050602081019050919050565b600080fd5b600061229d61229884612259565b61223e565b905080838252602082019050602084028301858111156122c0576122bf612285565b5b835b818110156122e957806122d5888261201d565b8452602084019350506020810190506122c2565b5050509392505050565b600082601f830112612308576123076121c8565b5b813561231884826020860161228a565b91505092915050565b6000806040838503121561233857612337611ff2565b5b600083013567ffffffffffffffff81111561235657612355611ff7565b5b612362858286016122f3565b92505060206123738582860161201d565b9150509250929050565b61238681612123565b82525050565b60006020820190506123a1600083018461237d565b92915050565b60006123b282612089565b9050919050565b6123c2816123a7565b81146123cd57600080fd5b50565b6000813590506123df816123b9565b92915050565b6000602082840312156123fb576123fa611ff2565b5b6000612409848285016123d0565b91505092915050565b60006020828403121561242857612427611ff2565b5b600082013567ffffffffffffffff81111561244657612445611ff7565b5b612452848285016122f3565b91505092915050565b6000612466826120d5565b9050919050565b6124768161245b565b82525050565b6000602082019050612491600083018461246d565b92915050565b6124a0816123a7565b82525050565b60006020820190506124bb6000830184612497565b92915050565b600080604083850312156124d8576124d7611ff2565b5b60006124e6858286016123d0565b92505060206124f785828601612146565b9150509250929050565b600082825260208201905092915050565b7f4d657267654d616e613a20456d657267656e63792073687574646f776e20697360008201527f20696e20706c6163650000000000000000000000000000000000000000000000602082015250565b600061256e602983612501565b915061257982612512565b604082019050919050565b6000602082019050818103600083015261259d81612561565b9050919050565b7f4d657267654d616e613a204e6f742061206d616e61206d6f6469666965720000600082015250565b60006125da601e83612501565b91506125e5826125a4565b602082019050919050565b60006020820190508181036000830152612609816125cd565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061264a82611ffc565b915061265583611ffc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561268a57612689612610565b5b828201905092915050565b60006040820190506126aa600083018561205f565b6126b7602083018461205f565b9392505050565b7f4d657267654d616e613a20416374696f6e206f6e6c792063616e206f6363757260008201527f206166746572206d657267650000000000000000000000000000000000000000602082015250565b600061271a602c83612501565b9150612725826126be565b604082019050919050565b600060208201905081810360008301526127498161270d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600061278a82611ffc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156127bd576127bc612610565b5b600182019050919050565b7f4d657267654d616e613a2043616e206e6f7420636f6e73756d65206d6f72652060008201527f6d616e61207468616e20776861742065786973747320696e2073746174756500602082015250565b6000612824603f83612501565b915061282f826127c8565b604082019050919050565b6000602082019050818103600083015261285381612817565b9050919050565b600080fd5b600067ffffffffffffffff82111561287a576128796121de565b5b612883826121cd565b9050602081019050919050565b60005b838110156128ae578082015181840152602081019050612893565b838111156128bd576000848401525b50505050565b60006128d66128d18461285f565b61223e565b9050828152602081018484840111156128f2576128f161285a565b5b6128fd848285612890565b509392505050565b600082601f83011261291a576129196121c8565b5b815161292a8482602086016128c3565b91505092915050565b60006020828403121561294957612948611ff2565b5b600082015167ffffffffffffffff81111561296757612966611ff7565b5b61297384828501612905565b91505092915050565b600061298782611ffc565b915061299283611ffc565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156129cb576129ca612610565b5b828202905092915050565b7f4d657267654d616e613a20416374696f6e206f6e6c792063616e206f6363757260008201527f206265666f7265206d6572676500000000000000000000000000000000000000602082015250565b6000612a32602d83612501565b9150612a3d826129d6565b604082019050919050565b60006020820190508181036000830152612a6181612a25565b9050919050565b600081519050612a77816123b9565b92915050565b600060208284031215612a9357612a92611ff2565b5b6000612aa184828501612a68565b91505092915050565b7f4d657267654d616e613a2043616e206e6f7420626f6f737420746f6b656e207960008201527f6f7520646f206e6f74206f776e00000000000000000000000000000000000000602082015250565b6000612b06602d83612501565b9150612b1182612aaa565b604082019050919050565b60006020820190508181036000830152612b3581612af9565b9050919050565b7f4d657267654d616e613a2043616e206e6f7420626f6f737420746f6b656e732060008201527f746861742061726520616c726561647920626f6f737465640000000000000000602082015250565b6000612b98603883612501565b9150612ba382612b3c565b604082019050919050565b60006020820190508181036000830152612bc781612b8b565b9050919050565b6000612bd982611ffc565b9150612be483611ffc565b925082821015612bf757612bf6612610565b5b828203905092915050565b7f4d657267654d616e613a2043616e206e6f74206368616e6e656c20746f20746f60008201527f6b656e4964207a65726f00000000000000000000000000000000000000000000602082015250565b6000612c5e602a83612501565b9150612c6982612c02565b604082019050919050565b60006020820190508181036000830152612c8d81612c51565b9050919050565b7f4d657267654d616e613a204d616e612068617320616c7265616479206265656e60008201527f206368616e6e656c656400000000000000000000000000000000000000000000602082015250565b6000612cf0602a83612501565b9150612cfb82612c94565b604082019050919050565b60006020820190508181036000830152612d1f81612ce3565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612d82602683612501565b9150612d8d82612d26565b604082019050919050565b60006020820190508181036000830152612db181612d75565b9050919050565b600081519050612dc781612006565b92915050565b600060208284031215612de357612de2611ff2565b5b6000612df184828501612db8565b91505092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612e30602083612501565b9150612e3b82612dfa565b602082019050919050565b60006020820190508181036000830152612e5f81612e23565b9050919050565b6000606082019050612e7b600083018661205f565b612e88602083018561205f565b612e95604083018461205f565b949350505050565b6000606082019050612eb26000830186612497565b612ebf602083018561205f565b612ecc604083018461205f565b94935050505056fea26469706673582212201eef640021462daafb2ad1efa6f15f9bfcbd3df0f4c49c524d648851646664df64736f6c63430008090033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000095cdb0fbf3ccadabba38acc921a9b2381329f7270000000000000000000000008a2f3cf61dbfe039ba26986360a18776d0bf19aa000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000005b8d800000000000000000000000000000000000000000000000000000000000000006
-----Decoded View---------------
Arg [0] : config (tuple):
Arg [1] : merge (address): 0x95Cdb0FBf3CcaDABBa38aCC921A9b2381329f727
Arg [2] : baseManaStorage (address): 0x8a2F3Cf61DBFe039Ba26986360A18776D0bf19AA
Arg [3] : manaBoostRitualMultiplier (uint256): 20
Arg [4] : maxManaBoostRitualBalance (uint256): 200
Arg [5] : baseManaMultiplier (uint256): 6000000
Arg [6] : numDecimals (uint256): 6
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 00000000000000000000000095cdb0fbf3ccadabba38acc921a9b2381329f727
Arg [1] : 0000000000000000000000008a2f3cf61dbfe039ba26986360a18776d0bf19aa
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000c8
Arg [4] : 00000000000000000000000000000000000000000000000000000000005b8d80
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000006
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 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.