Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| 0xda99bc4ec79a4967d25a885f57c7f4cfad70c7eb2b1c4514298e8ee2ff454c8a | Mint | (pending) | 3 days ago | IN | 0 ETH | (Pending) | |||
| Set Approval For... | 24508012 | 12 hrs ago | IN | 0 ETH | 0.00000123 | ||||
| Safe Transfer Fr... | 24501834 | 33 hrs ago | IN | 0 ETH | 0.00000162 | ||||
| Set Approval For... | 24498866 | 43 hrs ago | IN | 0 ETH | 0.00003262 | ||||
| Set Approval For... | 24496982 | 2 days ago | IN | 0 ETH | 0.00000344 | ||||
| Set Approval For... | 24496951 | 2 days ago | IN | 0 ETH | 0.00000113 | ||||
| Set Approval For... | 24493126 | 2 days ago | IN | 0 ETH | 0.00000305 | ||||
| Mint | 24491588 | 2 days ago | IN | 0 ETH | 0.00007532 | ||||
| Set Approval For... | 24477291 | 4 days ago | IN | 0 ETH | 0.00000659 | ||||
| Set Approval For... | 24468590 | 6 days ago | IN | 0 ETH | 0.00000147 | ||||
| Set Approval For... | 24444577 | 9 days ago | IN | 0 ETH | 0.00000156 | ||||
| Set Approval For... | 24440864 | 9 days ago | IN | 0 ETH | 0.00013876 | ||||
| Set Approval For... | 24435252 | 10 days ago | IN | 0 ETH | 0.00000507 | ||||
| Set Approval For... | 24434843 | 10 days ago | IN | 0 ETH | 0.00001109 | ||||
| Set Approval For... | 24432401 | 11 days ago | IN | 0 ETH | 0.00000224 | ||||
| Set Approval For... | 24427915 | 11 days ago | IN | 0 ETH | 0.00000614 | ||||
| Set Approval For... | 24422212 | 12 days ago | IN | 0 ETH | 0.00000421 | ||||
| Set Approval For... | 24421907 | 12 days ago | IN | 0 ETH | 0.00000878 | ||||
| Set Approval For... | 24418727 | 12 days ago | IN | 0 ETH | 0.00000986 | ||||
| Set Approval For... | 24417858 | 13 days ago | IN | 0 ETH | 0.00000349 | ||||
| Mint | 24414000 | 13 days ago | IN | 0 ETH | 0.00000178 | ||||
| Set Approval For... | 24413060 | 13 days ago | IN | 0 ETH | 0.00000193 | ||||
| Set Approval For... | 24411936 | 13 days ago | IN | 0 ETH | 0.00000715 | ||||
| Set Approval For... | 24388906 | 17 days ago | IN | 0 ETH | 0.00000526 | ||||
| Set Approval For... | 24372862 | 19 days ago | IN | 0 ETH | 0.00000606 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
SovereignBits
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./PixelRenderer.sol";
contract SovereignBits is ERC721A, Ownable, ReentrancyGuard {
using Strings for uint256;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public mintPrice = 0 ether;
uint256 public maxPerWallet = 1;
mapping(uint256 => uint8) public rarityOf;
mapping(uint256 => bool) public rarityAssigned;
// hasMinted removed in favor of _numberMinted checks
// Rarity Counts
uint256 public courtCount;
uint256 public queenCount;
uint256 public kingCount;
uint256 public jokerCount;
// Events
event BaseMint(address indexed minter, uint256 tokenId, uint8 rarity);
event BonusMint(address indexed minter, uint256 tokenId, uint8 rarity);
event BonusCreditEarned(address indexed user, uint256 amount);
event BonusCreditUsed(address indexed user, uint256 amount);
// Errors
error MaxSupplyExceeded();
error InsufficientFunds();
error MaxPerWalletExceeded();
error MintPaused();
error RefundFailed();
error TokenDoesNotExist();
error InvalidPayment();
bool public paused;
constructor() ERC721A("SovereignBits", "SOV") Ownable(msg.sender) {}
function _baseURI() internal pure override returns (string memory) {
return "";
}
function _startTokenId() internal pure override returns (uint256) {
return 0;
}
function _rarityToString(uint8 rarity) internal pure returns (string memory) {
if (rarity == 3) return "Joker";
if (rarity == 2) return "King";
if (rarity == 1) return "Queen";
return "Court";
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
if (!_exists(tokenId)) revert TokenDoesNotExist();
// Generate on-chain metadata & SVG
PixelRenderer.Traits memory traits = PixelRenderer.generateTraits(tokenId);
string memory svg = PixelRenderer.renderSVG(traits);
// Construct attributes JSON
string memory attributes = string(abi.encodePacked(
'[',
'{"trait_type": "Rarity", "value": "', _rarityToString(traits.rarity), '"},',
'{"trait_type": "Template", "value": "Type ', Strings.toString(traits.templateId), '"},',
'{"trait_type": "Palette", "value": "Palette ', Strings.toString(traits.paletteId), '"}'
']'
));
return string(abi.encodePacked(
'data:application/json;base64,',
Base64.encode(bytes(string(abi.encodePacked(
'{"name": "SovereignBit #', Strings.toString(tokenId), '",',
'"description": "A fully on-chain deterministic pixel art character.",',
'"image": "data:image/svg+xml;base64,', Base64.encode(bytes(svg)), '",',
'"attributes": ', attributes,
'}'
))))
));
}
function setMintPrice(uint256 _mintPrice) external onlyOwner {
mintPrice = _mintPrice;
}
function setMaxPerWallet(uint256 _maxPerWallet) external onlyOwner {
maxPerWallet = _maxPerWallet;
}
function setPaused(bool _paused) external onlyOwner {
paused = _paused;
}
function airdrop(address to, uint256 quantity) external onlyOwner {
if (totalSupply() + quantity > MAX_SUPPLY) revert MaxSupplyExceeded();
_mint(to, quantity);
}
function mint(uint256 quantity) external payable nonReentrant {
if (paused) revert MintPaused();
if (quantity == 0) revert InvalidPayment();
if (_numberMinted(msg.sender) + quantity > maxPerWallet) revert MaxPerWalletExceeded();
if (totalSupply() + quantity > MAX_SUPPLY) revert MaxSupplyExceeded();
if (msg.value < mintPrice * quantity) revert InsufficientFunds();
_mint(msg.sender, quantity);
// Refund excess payment
if (msg.value > mintPrice * quantity) {
(bool success, ) = msg.sender.call{value: msg.value - (mintPrice * quantity)}("");
if (!success) revert RefundFailed();
}
}
// Centralized rarity logic hook
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override {
super._afterTokenTransfers(from, to, startTokenId, quantity);
// Only trigger on minting (from == 0x0)
if (from == address(0)) {
for (uint256 i = 0; i < quantity; i++) {
uint256 tokenId = startTokenId + i;
// Double check to avoid re-assignment if logic changes, though fresh mint shouldn't have it
if (!rarityAssigned[tokenId]) {
PixelRenderer.Traits memory t = PixelRenderer.generateTraits(tokenId);
uint8 rarity = t.rarity;
if (rarity == 3) {
jokerCount++;
} else if (rarity == 2) {
kingCount++;
} else if (rarity == 1) {
queenCount++;
} else {
courtCount++;
}
rarityOf[tokenId] = rarity;
rarityAssigned[tokenId] = true;
emit BaseMint(to, tokenId, rarity);
}
}
}
}
function getRarity(uint256 tokenId) external view returns (uint8) {
if (!_exists(tokenId)) revert TokenDoesNotExist();
return rarityOf[tokenId];
}
function tokenRarityOrDefault(uint256 tokenId) external view returns (uint8 rarity, bool isAssigned) {
if (!_exists(tokenId)) revert TokenDoesNotExist();
if (rarityAssigned[tokenId]) {
return (rarityOf[tokenId], true);
}
return (0, false);
}
function remainingSupply() external view returns (uint256) {
return MAX_SUPPLY - totalSupply();
}
function canMint(address user) external view returns (bool) {
if (paused) return false;
return _numberMinted(user) < maxPerWallet;
}
function tokensOfOwner(address owner, uint256 start, uint256 stop) external view returns (uint256[] memory) {
uint256 nextId = _nextTokenId();
if (stop > nextId) {
stop = nextId;
}
uint256 tokenCount = 0;
for (uint256 i = start; i < stop; i++) {
if (_exists(i) && ownerOf(i) == owner) {
tokenCount++;
}
}
uint256[] memory tokens = new uint256[](tokenCount);
uint256 index = 0;
for (uint256 i = start; i < stop; i++) {
if (_exists(i) && ownerOf(i) == owner) {
tokens[index] = i;
index++;
}
}
return tokens;
}
function rarityCounts() external view returns (uint256 court, uint256 queen, uint256 king, uint256 joker) {
return (courtCount, queenCount, kingCount, jokerCount);
}
function withdraw() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed");
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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 {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Base64.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*/
library Base64 {
/**
* @dev Base64 Encoding/Decoding Table
* See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
/**
* @dev Converts a `bytes` to its Bytes64 `string` representation.
*/
function encode(bytes memory data) internal pure returns (string memory) {
return _encode(data, _TABLE, true);
}
/**
* @dev Converts a `bytes` to its Bytes64Url `string` representation.
* Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].
*/
function encodeURL(bytes memory data) internal pure returns (string memory) {
return _encode(data, _TABLE_URL, false);
}
/**
* @dev Internal table-agnostic conversion
*/
function _encode(bytes memory data, string memory table, bool withPadding) private 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 "";
// If padding is enabled, the final length should be `bytes` data length divided by 3 rounded up and then
// multiplied by 4 so that it leaves room for padding the last chunk
// - `data.length + 2` -> Prepare for division rounding up
// - `/ 3` -> Number of 3-bytes chunks (rounded up)
// - `4 *` -> 4 characters for each chunk
// This is equivalent to: 4 * Math.ceil(data.length / 3)
//
// If padding is disabled, the final length should be `bytes` data length multiplied by 4/3 rounded up as
// opposed to when padding is required to fill the last chunk.
// - `4 * data.length` -> 4 characters for each chunk
// - ` + 2` -> Prepare for division rounding up
// - `/ 3` -> Number of 3-bytes chunks (rounded up)
// This is equivalent to: Math.ceil((4 * data.length) / 3)
uint256 resultLength = withPadding ? 4 * ((data.length + 2) / 3) : (4 * data.length + 2) / 3;
string memory result = new string(resultLength);
assembly ("memory-safe") {
// Prepare the lookup table (skip the first "length" byte)
let tablePtr := add(table, 1)
// Prepare result pointer, jump over length
let resultPtr := add(result, 0x20)
let dataPtr := data
let endPtr := add(data, mload(data))
// In some cases, the last iteration will read bytes after the end of the data. We cache the value, and
// set it to zero to make sure no dirty bytes are read in that section.
let afterPtr := add(endPtr, 0x20)
let afterCache := mload(afterPtr)
mstore(afterPtr, 0x00)
// Run over the input, 3 bytes at a time
for {} lt(dataPtr, endPtr) {} {
// Advance 3 bytes
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
// To write each character, shift the 3 byte (24 bits) chunk
// 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
// and apply logical AND with 0x3F to bitmask the least significant 6 bits.
// Use this as an index into the lookup table, mload an entire word
// so the desired character is in the least significant byte, and
// mstore8 this least significant byte into the result and continue.
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
}
// Reset the value that was cached
mstore(afterPtr, afterCache)
if withPadding {
// 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 v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(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 towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* 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 {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, 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.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
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⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// 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²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev 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) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
}
}
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
using SafeCast for *;
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
uint256 private constant SPECIAL_CHARS_LOOKUP =
(1 << 0x08) | // backspace
(1 << 0x09) | // tab
(1 << 0x0a) | // newline
(1 << 0x0c) | // form feed
(1 << 0x0d) | // carriage return
(1 << 0x22) | // double quote
(1 << 0x5c); // backslash
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev The string being parsed contains characters that are not in scope of the given base.
*/
error StringsInvalidChar();
/**
* @dev The string being parsed is not a properly formatted address.
*/
error StringsInvalidAddressFormat();
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(add(buffer, 0x20), length)
}
while (true) {
ptr--;
assembly ("memory-safe") {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
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_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
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);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
* representation, according to EIP-55.
*/
function toChecksumHexString(address addr) internal pure returns (string memory) {
bytes memory buffer = bytes(toHexString(addr));
// hash the hex part of buffer (skip length + 2 bytes, length 40)
uint256 hashValue;
assembly ("memory-safe") {
hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
}
for (uint256 i = 41; i > 1; --i) {
// possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
// case shift by xoring with 0x20
buffer[i] ^= 0x20;
}
hashValue >>= 4;
}
return string(buffer);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
/**
* @dev Parse a decimal string and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input) internal pure returns (uint256) {
return parseUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
uint256 result = 0;
for (uint256 i = begin; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 9) return (false, 0);
result *= 10;
result += chr;
}
return (true, result);
}
/**
* @dev Parse a decimal string and returns the value as a `int256`.
*
* Requirements:
* - The string must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input) internal pure returns (int256) {
return parseInt(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
(bool success, int256 value) = tryParseInt(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
* the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
}
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
/**
* @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character or if the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, int256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseIntUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, int256 value) {
bytes memory buffer = bytes(input);
// Check presence of a negative sign.
bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
bool positiveSign = sign == bytes1("+");
bool negativeSign = sign == bytes1("-");
uint256 offset = (positiveSign || negativeSign).toUint();
(bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
if (absSuccess && absValue < ABS_MIN_INT256) {
return (true, negativeSign ? -int256(absValue) : int256(absValue));
} else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
return (true, type(int256).min);
} else return (false, 0);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input) internal pure returns (uint256) {
return parseHexUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseHexUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
* invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseHexUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
// skip 0x prefix if present
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 offset = hasPrefix.toUint() * 2;
uint256 result = 0;
for (uint256 i = begin + offset; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 15) return (false, 0);
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
return (true, result);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input) internal pure returns (address) {
return parseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
(bool success, address value) = tryParseAddress(input, begin, end);
if (!success) revert StringsInvalidAddressFormat();
return value;
}
/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress-string} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress-string-uint256-uint256} requirements.
*/
function tryParseAddress(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, address value) {
if (end > bytes(input).length || begin > end) return (false, address(0));
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
// check that input is the correct length
if (end - begin == expectedLength) {
// length guarantees that this does not overflow, and value is at most type(uint160).max
(bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
return (s, address(uint160(v)));
} else {
return (false, address(0));
}
}
function _tryParseChr(bytes1 chr) private pure returns (uint8) {
uint8 value = uint8(chr);
// Try to parse `chr`:
// - Case 1: [0-9]
// - Case 2: [a-f]
// - Case 3: [A-F]
// - otherwise not supported
unchecked {
if (value > 47 && value < 58) value -= 48;
else if (value > 96 && value < 103) value -= 87;
else if (value > 64 && value < 71) value -= 55;
else return type(uint8).max;
}
return value;
}
/**
* @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
*
* WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
*
* NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
* RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
* characters that are not in this range, but other tooling may provide different results.
*/
function escapeJSON(string memory input) internal pure returns (string memory) {
bytes memory buffer = bytes(input);
bytes memory output = new bytes(2 * buffer.length); // worst case scenario
uint256 outputLength = 0;
for (uint256 i; i < buffer.length; ++i) {
bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
output[outputLength++] = "\\";
if (char == 0x08) output[outputLength++] = "b";
else if (char == 0x09) output[outputLength++] = "t";
else if (char == 0x0a) output[outputLength++] = "n";
else if (char == 0x0c) output[outputLength++] = "f";
else if (char == 0x0d) output[outputLength++] = "r";
else if (char == 0x5c) output[outputLength++] = "\\";
else if (char == 0x22) {
// solhint-disable-next-line quotes
output[outputLength++] = '"';
}
} else {
output[outputLength++] = char;
}
}
// write the actual length and deallocate unused memory
assembly ("memory-safe") {
mstore(output, outputLength)
mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
}
return string(output);
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(add(buffer, 0x20), offset))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
library PixelRenderer {
using Strings for uint256;
// Constants
string constant COLLECTION_SALT = "SOVEREIGN_BITS_V1";
// Rarity Thresholds (Total 10000)
uint256 constant THRESHOLD_COURT = 7500;
uint256 constant THRESHOLD_QUEEN = 9300;
uint256 constant THRESHOLD_KING = 9950;
struct Traits {
uint256 seed;
uint8 rarity; // 0=Court, 1=Queen, 2=King, 3=Joker
uint8 templateId; // Renamed from templateIndex to match CodedVibes.sol usage
uint8 paletteId; // Renamed from paletteIndex to match CodedVibes.sol usage
uint8 accIndex; // Accessory/Weapon
uint8 bgIndex;
}
function generateTraits(uint256 tokenId) internal pure returns (Traits memory) {
uint256 seed = uint256(keccak256(abi.encodePacked(tokenId, COLLECTION_SALT)));
Traits memory t;
t.seed = seed;
// Rarity Logic
uint256 r = seed % 10000;
if (r < THRESHOLD_COURT) {
t.rarity = 0; // Court
t.templateId = uint8((seed >> 8) % 8); // 8 Templates
} else if (r < THRESHOLD_QUEEN) {
t.rarity = 1; // Queen
t.templateId = uint8((seed >> 8) % 3); // 3 Templates
} else if (r < THRESHOLD_KING) {
t.rarity = 2; // King
t.templateId = uint8((seed >> 8) % 2); // 2 Templates
} else {
t.rarity = 3; // Joker
t.templateId = uint8((seed >> 8) % 2); // 2 Templates
}
t.paletteId = uint8((seed >> 16) % 40); // INCREASED TO 40 Palettes
t.accIndex = uint8((seed >> 24) % 10); // INCREASED TO 10 Accessories
t.bgIndex = uint8((seed >> 40) % 20); // INCREASED TO 20 Backgrounds
return t;
}
// 30 Palettes: [Main, Secondary, Highlight/Skin]
function getPalette(uint8 index) internal pure returns (string[3] memory) {
string[3][30] memory palettes = [
["#5DADE2", "#2E86C1", "#AED6F1"], // Steel Blue
["#27AE60", "#1E8449", "#ABEBC6"], // Forest Green
["#C0392B", "#922B21", "#E6B0AA"], // Crimson Red
["#D35400", "#A04000", "#EDBB99"], // Bronze/Rust
["#8E44AD", "#6C3483", "#D2B4DE"], // Royal Purple
["#F1C40F", "#B7950B", "#F9E79F"], // Gold
["#2C3E50", "#17202A", "#808B96"], // Shadow Black
["#E59866", "#BA4A00", "#F6DDCC"], // Sand Beige
["#1ABC9C", "#117A65", "#A3E4D7"], // Teal
["#2E4053", "#1B2631", "#5D6D7E"], // Navy
["#95A5A6", "#7F8C8D", "#CACFD2"], // Silver
["#A04000", "#6E2C00", "#E59866"], // Wood/Leather
["#D4AC0D", "#9A7D0A", "#F7DC6F"], // Brass
["#58D68D", "#28B463", "#82E0AA"], // Emerald
["#AF7AC5", "#884EA0", "#D7BDE2"], // Lavender
["#F39C12", "#D68910", "#FAD7A0"], // Amber
["#EC7063", "#CB4335", "#F2D7D5"], // Soft Red
["#5499C7", "#2471A3", "#D4E6F1"], // Soft Blue
["#48C9B0", "#17A589", "#A3E4D7"], // Turquoise
["#A569BD", "#884EA0", "#D2B4DE"], // Amethyst
// New Palettes
["#FF00FF", "#990099", "#FF66FF"], // Neon Magenta
["#00FFFF", "#008B8B", "#E0FFFF"], // Cyan
["#32CD32", "#006400", "#98FB98"], // Lime
["#FF4500", "#8B0000", "#FFA07A"], // Magma
["#F0F8FF", "#B0C4DE", "#FFFFFF"], // Ice
["#8B4513", "#5D4037", "#D2691E"], // Earth
["#212121", "#000000", "#424242"], // Void
["#FFD700", "#DAA520", "#FFFACD"], // Solar
["#000080", "#0000CD", "#4169E1"], // Ocean
["#800080", "#4B0082", "#9370DB"] // Berry
];
if (index >= 30) return palettes[0];
return palettes[index];
}
function getBackground(uint8 index) internal pure returns (string memory) {
string[10] memory bgs = [
"#F2F3F4", // White Smoke
"#EAFAF1", // Mint
"#FEF9E7", // Cornsilk
"#F5EEF8", // Lavender
"#EBF5FB", // Azure
"#FDEDEC", // Blush
"#E8DAEF", // Purple Mist
"#D5F5E3", // Green Mist
"#FCF3CF", // Lemon
"#D6EAF8" // Blue Mist
];
if (index >= 10) return bgs[0];
return bgs[index];
}
function getAccessory(uint8 index) internal pure returns (uint256[8] memory) {
// Index 0 = None
if (index == 0) {
return [uint256(0), 0, 0, 0, 0, 0, 0, 0];
}
// 1: Halo (Head) - Gold pixels
if (index == 1) {
return [
uint256(0x0000000000000000000000000000000000000000003f00000000000003f00000),
0, 0, 0, 0, 0, 0, 0
];
}
// 2: Sword (Right side)
if (index == 2) {
return [
0, 0,
uint256(0x0000000000000000000000000000000300000000000000000000000000000003), // Tip
uint256(0x0000000000000003000000000000000300000000000000030000000000000003), // Blade
uint256(0x00000000000000030000000000000003000000000000000c000000000000000c), // Hilt
0, 0, 0
];
}
// 3: Energy Orb (Left Hand)
if (index == 3) {
return [
0, 0,
0,
uint256(0x000c000000000000003f000000000000003f000000000000000c000000000000),
0, 0, 0, 0
];
}
// 4: Crown (Head)
if (index == 4) {
return [
uint256(0x0000000000000000000000000000000000000000001500000000000003f00000),
0, 0, 0, 0, 0, 0, 0
];
}
// 5: Glasses
if (index == 5) {
return [
0,
uint256(0x0000000000000000000000000000000000000000003f00000000000000000000),
0, 0, 0, 0, 0, 0
];
}
// 6: Cigarette (Mouth)
if (index == 6) {
return [
0,
uint256(0x0000000000000000000000000000000000000002000000000000000000000000),
0, 0, 0, 0, 0, 0
];
}
// 7: Aura (Pixels around)
if (index == 7) {
return [
uint256(0x1000000000000000000000000000000100000000000000000000000000000001),
uint256(0x1000000000000000000000000000000000000000000000000000000000000001),
uint256(0x1000000000000000000000000000000000000000000000000000000000000001),
uint256(0x1000000000000000000000000000000000000000000000000000000000000001),
uint256(0x1000000000000000000000000000000000000000000000000000000000000001),
uint256(0x1000000000000000000000000000000000000000000000000000000000000001),
uint256(0x1000000000000000000000000000000100000000000000000000000000000001),
0
];
}
// 8: Pipe (Mouth)
if (index == 8) {
return [
0,
uint256(0x0000000000000000000000000000000000000003c00000000000000000000000),
0, 0, 0, 0, 0, 0
];
}
// 9: Earring (Ear)
if (index == 9) {
return [
uint256(0x0000000000000000000000000000000000000000000000000000000030000000),
0, 0, 0, 0, 0, 0, 0
];
}
return [uint256(0), 0, 0, 0, 0, 0, 0, 0];
}
// Template Data: 8 uint256s (Total 32 rows * 32 cols * 2 bits)
// 00=Trans, 01=Black, 10=Main, 11=Sec/Skin
function getTemplate(uint8 rarity, uint8 /*index*/) internal pure returns (uint256[8] memory) {
if (rarity == 2) { // King V2 (Wide Robe, Crown, Scepter)
return [
uint256(0x1104000000000000333c000000),
uint256(0x7ffd0000000000007ffd0000000000003ffc15000000000037dc080000),
uint256(0x2aa81500000000002aa80c00000000002aa80c0000000006affa9c0000),
uint256(0x26affa9c0000000026affa9c0000000026affa9c0000000026affa9c0000),
uint256(0x26affa9c0000000026affa9c0000000006affa9c0000000006affa9c0000),
uint256(0x6affa9c0000000006affa9c0000000006affa900000000006affa900000),
uint256(0x6affa900000000005555550000000000000000000000000000000000000),
uint256(0x0)
];
}
if (rarity == 1) { // Queen V2 (Big Hair, Wide Dress)
return [
uint256(0x3ffc000000),
uint256(0x1ff4000000000002aaaa800000000002bffe800000000002b7de800000),
uint256(0x2bffe800000000002bffe800000000002aaaa80000000000febebf00000),
uint256(0xfebebf0000000000febebf0000000003c2be83c000000003eabeabc0000),
uint256(0x3eabeabc000000003eabeabc0000000002abea800000000002abea800000),
uint256(0x2aabeaa8000000002aabeaa8000000002aabeaa8000000002aabeaa80000),
uint256(0x2aabeaa8000000002aabeaa8000000000000000000000000000000000000),
uint256(0x0)
];
}
if (rarity == 3) { // Joker V2 (Double Hat, Dynamic Pose)
return [
uint256(0x0),
uint256(0x800080000000000320023000000000000aa80000000000000aa8000000),
uint256(0xffc0000000000000ddc0000000000000ffc0000000000030ffc300000),
uint256(0xbaab8000000000002aaa0000000000003aab0000000000003aab000000),
uint256(0x3aab0000000000003aab0000000000000f280000000000000f28000000),
uint256(0xf280000000000004f2840000000000015150000000000000000000000),
uint256(0x0),
uint256(0x0)
];
}
// Base Template (Guard/Court style)
return [
uint256(0x0000000000000000000000000000000000000000000000000000000000000000),
uint256(0x000000000000000000000000000000000000005555000000000002affa800000),
uint256(0x000002aefa800000000002fffa800000000002efaa8000000000015555000000),
uint256(0x000002d7d7800000000002affa800000000015555554000000001f2c3ce40000),
uint256(0x000015bfee540000000019afaa64000000001d2aa86400000000154751540000),
uint256(0x000015a69a540000000006f6af900000000001a55a4000000000015415400000),
uint256(0x0000165555940000000015555554000000000000000000000000000000000000),
uint256(0x0000000000000000000000000000000000000000000000000000000000000000)
];
}
function renderSVG(Traits memory t) internal pure returns (string memory) {
string[3] memory pal = getPalette(t.paletteId);
string memory bg = getBackground(t.bgIndex); // New logic
uint256[8] memory sprite = getTemplate(t.rarity, t.templateId);
uint256[8] memory accessory = getAccessory(t.accIndex); // New logic
string memory rects = "";
// Iterate 8 blocks (each 4 rows)
for (uint256 i = 0; i < 8; i++) {
uint256 blockData = sprite[i];
uint256 accData = accessory[i]; // Get accessory data
if (blockData == 0 && accData == 0) continue;
// Each block has 4 rows
for (uint256 r = 0; r < 4; r++) {
uint256 y = i * 4 + r;
// Shift to get row data (from high bits to low)
// Row 0 of block is at shift 192, Row 1 at 128, etc.
uint256 rowShift = 192 - (r * 64);
uint256 rowData = (blockData >> rowShift) & 0xFFFFFFFFFFFFFFFF;
uint256 accRow = (accData >> rowShift) & 0xFFFFFFFFFFFFFFFF;
if (rowData == 0 && accRow == 0) continue;
string memory rowRects = "";
for (uint256 x = 0; x < 32; x++) {
// Get 2 bits at position x (from left)
// x=0 -> bits 62-63
uint256 shift = 62 - (x * 2);
// Accessory takes priority if not 0
uint256 val = (accRow >> shift) & 3;
if (val == 0) {
val = (rowData >> shift) & 3;
}
if (val != 0) {
string memory color;
if (val == 1) color = "#000000";
else if (val == 2) color = pal[0];
else if (val == 3) color = pal[1];
rowRects = string.concat(rowRects,
"<rect x='", x.toString(),
"' y='", y.toString(),
"' width='1' height='1' fill='", color, "' />"
);
}
}
rects = string.concat(rects, rowRects);
}
}
return string.concat(
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' shape-rendering='crispEdges' style='background-color:", bg, "'>",
rects,
"</svg>"
);
}
// Old tokenURI function removed as logic moved to CodedVibes.sol
}// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.sol';
/**
* @dev Interface of ERC721 token receiver.
*/
interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC721A
*
* @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
* Non-Fungible Token Standard, including the Metadata extension.
* Optimized for lower gas during batch mints.
*
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* The `_sequentialUpTo()` function can be overriden to enable spot mints
* (i.e. non-consecutive mints) for `tokenId`s greater than `_sequentialUpTo()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
* - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is IERC721A {
// Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
struct TokenApprovalRef {
address value;
}
// =============================================================
// CONSTANTS
// =============================================================
// Mask of an entry in packed address data.
uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
// The bit position of `numberBurned` in packed address data.
uint256 private constant _BITPOS_NUMBER_BURNED = 128;
// The bit position of `aux` in packed address data.
uint256 private constant _BITPOS_AUX = 192;
// Mask of all 256 bits in packed address data except the 64 bits for `aux`.
uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
// The bit position of `startTimestamp` in packed ownership.
uint256 private constant _BITPOS_START_TIMESTAMP = 160;
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
// The bit position of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;
// The bit mask of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;
// The bit position of `extraData` in packed ownership.
uint256 private constant _BITPOS_EXTRA_DATA = 232;
// Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
// The mask of the lower 160 bits for addresses.
uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;
// The maximum `quantity` that can be minted with {_mintERC2309}.
// This limit is to prevent overflows on the address data entries.
// For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
// is required to cause an overflow, which is unrealistic.
uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
// The `Transfer` event signature is given by:
// `keccak256(bytes("Transfer(address,address,uint256)"))`.
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
// =============================================================
// STORAGE
// =============================================================
// The next token ID to be minted.
uint256 private _currentIndex;
// The number of tokens burned.
uint256 private _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned.
// See {_packedOwnershipOf} implementation for details.
//
// Bits Layout:
// - [0..159] `addr`
// - [160..223] `startTimestamp`
// - [224] `burned`
// - [225] `nextInitialized`
// - [232..255] `extraData`
mapping(uint256 => uint256) private _packedOwnerships;
// Mapping owner address to address data.
//
// Bits Layout:
// - [0..63] `balance`
// - [64..127] `numberMinted`
// - [128..191] `numberBurned`
// - [192..255] `aux`
mapping(address => uint256) private _packedAddressData;
// Mapping from token ID to approved address.
mapping(uint256 => TokenApprovalRef) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// The amount of tokens minted above `_sequentialUpTo()`.
// We call these spot mints (i.e. non-sequential mints).
uint256 private _spotMinted;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
if (_sequentialUpTo() < _startTokenId()) _revert(SequentialUpToTooSmall.selector);
}
// =============================================================
// TOKEN COUNTING OPERATIONS
// =============================================================
/**
* @dev Returns the starting token ID for sequential mints.
*
* Override this function to change the starting token ID for sequential mints.
*
* Note: The value returned must never change after any tokens have been minted.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Returns the maximum token ID (inclusive) for sequential mints.
*
* Override this function to return a value less than 2**256 - 1,
* but greater than `_startTokenId()`, to enable spot (non-sequential) mints.
*
* Note: The value returned must never change after any tokens have been minted.
*/
function _sequentialUpTo() internal view virtual returns (uint256) {
return type(uint256).max;
}
/**
* @dev Returns the next token ID to be minted.
*/
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual override returns (uint256 result) {
// Counter underflow is impossible as `_burnCounter` cannot be incremented
// more than `_currentIndex + _spotMinted - _startTokenId()` times.
unchecked {
// With spot minting, the intermediate `result` can be temporarily negative,
// and the computation must be unchecked.
result = _currentIndex - _burnCounter - _startTokenId();
if (_sequentialUpTo() != type(uint256).max) result += _spotMinted;
}
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view virtual returns (uint256 result) {
// Counter underflow is impossible as `_currentIndex` does not decrement,
// and it is initialized to `_startTokenId()`.
unchecked {
result = _currentIndex - _startTokenId();
if (_sequentialUpTo() != type(uint256).max) result += _spotMinted;
}
}
/**
* @dev Returns the total number of tokens burned.
*/
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
/**
* @dev Returns the total number of tokens that are spot-minted.
*/
function _totalSpotMinted() internal view virtual returns (uint256) {
return _spotMinted;
}
// =============================================================
// ADDRESS DATA OPERATIONS
// =============================================================
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) _revert(BalanceQueryForZeroAddress.selector);
return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
}
/**
* Sets the auxiliary 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 virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
// Cast `aux` with assembly to avoid redundant masking.
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
// The interface IDs are constants representing the first 4 bytes
// of the XOR of all function selectors in the interface.
// See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
// (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
return
interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
}
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) _revert(URIQueryForNonexistentToken.selector);
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
}
/**
* @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, it can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
// =============================================================
// OWNERSHIPS OPERATIONS
// =============================================================
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
/**
* @dev Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around over time.
*/
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
/**
* @dev Returns the unpacked `TokenOwnership` struct at `index`.
*/
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
/**
* @dev Returns whether the ownership slot at `index` is initialized.
* An uninitialized slot does not necessarily mean that the slot has no owner.
*/
function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) {
return _packedOwnerships[index] != 0;
}
/**
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
*/
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
/**
* @dev Returns the packed ownership data of `tokenId`.
*/
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) {
if (_startTokenId() <= tokenId) {
packed = _packedOwnerships[tokenId];
if (tokenId > _sequentialUpTo()) {
if (_packedOwnershipExists(packed)) return packed;
_revert(OwnerQueryForNonexistentToken.selector);
}
// If the data at the starting slot does not exist, start the scan.
if (packed == 0) {
if (tokenId >= _currentIndex) _revert(OwnerQueryForNonexistentToken.selector);
// Invariant:
// There will always be an initialized ownership slot
// (i.e. `ownership.addr != address(0) && ownership.burned == false`)
// before an unintialized ownership slot
// (i.e. `ownership.addr == address(0) && ownership.burned == false`)
// Hence, `tokenId` will not underflow.
//
// We can directly compare the packed value.
// If the address is zero, packed will be zero.
for (;;) {
unchecked {
packed = _packedOwnerships[--tokenId];
}
if (packed == 0) continue;
if (packed & _BITMASK_BURNED == 0) return packed;
// Otherwise, the token is burned, and we must revert.
// This handles the case of batch burned tokens, where only the burned bit
// of the starting slot is set, and remaining slots are left uninitialized.
_revert(OwnerQueryForNonexistentToken.selector);
}
}
// Otherwise, the data exists and we can skip the scan.
// This is possible because we have already achieved the target condition.
// This saves 2143 gas on transfers of initialized tokens.
// If the token is not burned, return `packed`. Otherwise, revert.
if (packed & _BITMASK_BURNED == 0) return packed;
}
_revert(OwnerQueryForNonexistentToken.selector);
}
/**
* @dev Returns the unpacked `TokenOwnership` struct from `packed`.
*/
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
ownership.addr = address(uint160(packed));
ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
ownership.burned = packed & _BITMASK_BURNED != 0;
ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
}
/**
* @dev Packs ownership data into a single uint256.
*/
function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
/**
* @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
*/
function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
// For branchless setting of the `nextInitialized` flag.
assembly {
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
_approve(to, tokenId, true);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) _revert(ApprovalQueryForNonexistentToken.selector);
return _tokenApprovals[tokenId].value;
}
/**
* @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) public virtual override {
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @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. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool result) {
if (_startTokenId() <= tokenId) {
if (tokenId > _sequentialUpTo()) return _packedOwnershipExists(_packedOwnerships[tokenId]);
if (tokenId < _currentIndex) {
uint256 packed;
while ((packed = _packedOwnerships[tokenId]) == 0) --tokenId;
result = packed & _BITMASK_BURNED == 0;
}
}
}
/**
* @dev Returns whether `packed` represents a token that exists.
*/
function _packedOwnershipExists(uint256 packed) private pure returns (bool result) {
assembly {
// The following is equivalent to `owner != address(0) && burned == false`.
// Symbolically tested.
result := gt(and(packed, _BITMASK_ADDRESS), and(packed, _BITMASK_BURNED))
}
}
/**
* @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
*/
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
msgSender := and(msgSender, _BITMASK_ADDRESS)
// `msgSender == owner || msgSender == approvedAddress`.
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
/**
* @dev Returns the storage slot and value for the approved address of `tokenId`.
*/
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
// The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
// =============================================================
// TRANSFER OPERATIONS
// =============================================================
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) public payable virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
// Mask `from` to the lower 160 bits, in case the upper bits somehow aren't clean.
from = address(uint160(uint256(uint160(from)) & _BITMASK_ADDRESS));
if (address(uint160(prevOwnershipPacked)) != from) _revert(TransferFromIncorrectOwner.selector);
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector);
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// 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 {
// We can directly increment and decrement the balances.
--_packedAddressData[from]; // Updates: `balance -= 1`.
++_packedAddressData[to]; // Updates: `balance += 1`.
// Updates:
// - `address` to the next owner.
// - `startTimestamp` to the timestamp of transfering.
// - `burned` to `false`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;
assembly {
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
from, // `from`.
toMasked, // `to`.
tokenId // `tokenId`.
)
}
if (toMasked == 0) _revert(TransferToZeroAddress.selector);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @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 memory _data
) public payable virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
_revert(TransferToNonERC721ReceiverImplementer.selector);
}
}
/**
* @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 {}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* `from` - Previous owner of the given token ID.
* `to` - Target address that will receive the token.
* `tokenId` - Token ID to be transferred.
* `_data` - Optional data to send along with the call.
*
* Returns whether the call correctly returned the expected magic value.
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
_revert(TransferToNonERC721ReceiverImplementer.selector);
}
assembly {
revert(add(32, reason), mload(reason))
}
}
}
// =============================================================
// MINT OPERATIONS
// =============================================================
/**
* @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 for each mint.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) _revert(MintZeroQuantity.selector);
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// `balance` and `numberMinted` have a maximum limit of 2**64.
// `tokenId` has a maximum limit of 2**256.
unchecked {
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;
if (toMasked == 0) _revert(MintToZeroAddress.selector);
uint256 end = startTokenId + quantity;
uint256 tokenId = startTokenId;
if (end - 1 > _sequentialUpTo()) _revert(SequentialMintExceedsLimit.selector);
do {
assembly {
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
tokenId // `tokenId`.
)
}
// The `!=` check ensures that large values of `quantity`
// that overflows uint256 will make the loop run out of gas.
} while (++tokenId != end);
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* This function is intended for efficient minting only during contract creation.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*
* Calling this function outside of contract creation WILL make your contract
* non-compliant with the ERC721 standard.
* For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
* {ConsecutiveTransfer} event is only permissible during contract creation.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {ConsecutiveTransfer} event.
*/
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) _revert(MintToZeroAddress.selector);
if (quantity == 0) _revert(MintZeroQuantity.selector);
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) _revert(MintERC2309QuantityExceedsLimit.selector);
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are unrealistic due to the above check for `quantity` to be below the limit.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
if (startTokenId + quantity - 1 > _sequentialUpTo()) _revert(SequentialMintExceedsLimit.selector);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_afterTokenTransfers(address(0), to, startTokenId, 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.
*
* See {_mint}.
*
* Emits a {Transfer} event for each mint.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
_revert(TransferToNonERC721ReceiverImplementer.selector);
}
} while (index < end);
// This prevents reentrancy to `_safeMint`.
// It does not prevent reentrancy to `_safeMintSpot`.
if (_currentIndex != end) revert();
}
}
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
/**
* @dev Mints a single token at `tokenId`.
*
* Note: A spot-minted `tokenId` that has been burned can be re-minted again.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` must be greater than `_sequentialUpTo()`.
* - `tokenId` must not exist.
*
* Emits a {Transfer} event for each mint.
*/
function _mintSpot(address to, uint256 tokenId) internal virtual {
if (tokenId <= _sequentialUpTo()) _revert(SpotMintTokenIdTooSmall.selector);
uint256 prevOwnershipPacked = _packedOwnerships[tokenId];
if (_packedOwnershipExists(prevOwnershipPacked)) _revert(TokenAlreadyExists.selector);
_beforeTokenTransfers(address(0), to, tokenId, 1);
// Overflows are incredibly unrealistic.
// The `numberMinted` for `to` is incremented by 1, and has a max limit of 2**64 - 1.
// `_spotMinted` is incremented by 1, and has a max limit of 2**256 - 1.
unchecked {
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `true` (as `quantity == 1`).
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_nextInitializedFlag(1) | _nextExtraData(address(0), to, prevOwnershipPacked)
);
// Updates:
// - `balance += 1`.
// - `numberMinted += 1`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += (1 << _BITPOS_NUMBER_MINTED) | 1;
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;
if (toMasked == 0) _revert(MintToZeroAddress.selector);
assembly {
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
tokenId // `tokenId`.
)
}
++_spotMinted;
}
_afterTokenTransfers(address(0), to, tokenId, 1);
}
/**
* @dev Safely mints a single token at `tokenId`.
*
* Note: A spot-minted `tokenId` that has been burned can be re-minted again.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}.
* - `tokenId` must be greater than `_sequentialUpTo()`.
* - `tokenId` must not exist.
*
* See {_mintSpot}.
*
* Emits a {Transfer} event.
*/
function _safeMintSpot(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mintSpot(to, tokenId);
unchecked {
if (to.code.length != 0) {
uint256 currentSpotMinted = _spotMinted;
if (!_checkContractOnERC721Received(address(0), to, tokenId, _data)) {
_revert(TransferToNonERC721ReceiverImplementer.selector);
}
// This prevents reentrancy to `_safeMintSpot`.
// It does not prevent reentrancy to `_safeMint`.
if (_spotMinted != currentSpotMinted) revert();
}
}
}
/**
* @dev Equivalent to `_safeMintSpot(to, tokenId, '')`.
*/
function _safeMintSpot(address to, uint256 tokenId) internal virtual {
_safeMintSpot(to, tokenId, '');
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @dev Equivalent to `_approve(to, tokenId, false)`.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_approve(to, tokenId, false);
}
/**
* @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:
*
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
bool approvalCheck
) internal virtual {
address owner = ownerOf(tokenId);
if (approvalCheck && _msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
_revert(ApprovalCallerNotOwnerNorApproved.selector);
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
// =============================================================
// BURN OPERATIONS
// =============================================================
/**
* @dev 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 {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector);
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// 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 {
// Updates:
// - `balance -= 1`.
// - `numberBurned += 1`.
//
// We can directly decrement the balance, and increment the number burned.
// This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
_packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;
// Updates:
// - `address` to the last owner.
// - `startTimestamp` to the timestamp of burning.
// - `burned` to `true`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as `_burnCounter` cannot be exceed `_currentIndex + _spotMinted` times.
unchecked {
_burnCounter++;
}
}
// =============================================================
// EXTRA DATA OPERATIONS
// =============================================================
/**
* @dev Directly sets the extra data for the ownership data `index`.
*/
function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) _revert(OwnershipNotInitializedForExtraData.selector);
uint256 extraDataCasted;
// Cast `extraData` with assembly to avoid redundant masking.
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
/**
* @dev Called during each token transfer to set the 24bit `extraData` field.
* Intended to be overridden by the cosumer contract.
*
* `previousExtraData` - the value of `extraData` before transfer.
*
* 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 _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
/**
* @dev Returns the next extra data for the packed ownership data.
* The returned result is shifted into position.
*/
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
}
// =============================================================
// OTHER OPERATIONS
// =============================================================
/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
/**
* @dev Converts a uint256 to its ASCII string decimal representation.
*/
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but
// we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
// We will need 1 word for the trailing zeros padding, 1 word for the length,
// and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
let m := add(mload(0x40), 0xa0)
// Update the free memory pointer to allocate.
mstore(0x40, m)
// Assign the `str` to the end.
str := sub(m, 0x20)
// Zeroize the slot after the string.
mstore(str, 0)
// Cache the end of the memory to calculate the length later.
let end := str
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
// prettier-ignore
for { let temp := value } 1 {} {
str := sub(str, 1)
// Write the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(str, add(48, mod(temp, 10)))
// Keep dividing `temp` until zero.
temp := div(temp, 10)
// prettier-ignore
if iszero(temp) { break }
}
let length := sub(end, str)
// Move the pointer 32 bytes leftwards to make room for the length.
str := sub(str, 0x20)
// Store the length.
mstore(str, length)
}
}
/**
* @dev For more efficient reverts.
*/
function _revert(bytes4 errorSelector) internal pure {
assembly {
mstore(0x00, errorSelector)
revert(0x00, 0x04)
}
}
}// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
/**
* `_sequentialUpTo()` must be greater than `_startTokenId()`.
*/
error SequentialUpToTooSmall();
/**
* The `tokenId` of a sequential mint exceeds `_sequentialUpTo()`.
*/
error SequentialMintExceedsLimit();
/**
* Spot minting requires a `tokenId` greater than `_sequentialUpTo()`.
*/
error SpotMintTokenIdTooSmall();
/**
* Cannot mint over a token that already exists.
*/
error TokenAlreadyExists();
/**
* The feature is not compatible with spot mints.
*/
error NotCompatibleWithSpotMints();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables
* (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`,
* checking first that contract recipients are aware of the ERC721 protocol
* to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move
* this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external payable;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Transfers `tokenId` 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 payable;
/**
* @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 payable;
/**
* @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);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @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);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}{
"viaIR": true,
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InsufficientFunds","type":"error"},{"inputs":[],"name":"InvalidPayment","type":"error"},{"inputs":[],"name":"MaxPerWalletExceeded","type":"error"},{"inputs":[],"name":"MaxSupplyExceeded","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintPaused","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"NotCompatibleWithSpotMints","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RefundFailed","type":"error"},{"inputs":[],"name":"SequentialMintExceedsLimit","type":"error"},{"inputs":[],"name":"SequentialUpToTooSmall","type":"error"},{"inputs":[],"name":"SpotMintTokenIdTooSmall","type":"error"},{"inputs":[],"name":"TokenAlreadyExists","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"rarity","type":"uint8"}],"name":"BaseMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BonusCreditEarned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BonusCreditUsed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"rarity","type":"uint8"}],"name":"BonusMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"airdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"canMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"courtCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getRarity","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"jokerCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"kingCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPerWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"queenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rarityAssigned","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rarityCounts","outputs":[{"internalType":"uint256","name":"court","type":"uint256"},{"internalType":"uint256","name":"queen","type":"uint256"},{"internalType":"uint256","name":"king","type":"uint256"},{"internalType":"uint256","name":"joker","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rarityOf","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"remainingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPerWallet","type":"uint256"}],"name":"setMaxPerWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintPrice","type":"uint256"}],"name":"setMintPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenRarityOrDefault","outputs":[{"internalType":"uint8","name":"rarity","type":"uint8"},{"internalType":"bool","name":"isAssigned","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234620001a75762000014620001c2565b60206c536f7665726569676e4269747360981b8183015262000035620001e6565b6229a7ab60e91b82820152825190916001600160401b038211620001a1576200006b82620000656002546200020a565b62000247565b80601f83116001146200011057508190620000a49460009262000104575b50508160011b916000199060031b1c191617600255620002f9565b600080553315620000eb57620000ba33620003ec565b620000c56001600a55565b620000d06000600b55565b620000db6001600c55565b6040516142729081620004368239f35b604051631e4fbdf760e01b815260006004820152602490fd5b01519050388062000089565b60026000529193601f1985167f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace936000905b82821062000188575050916001939186620000a49794106200016e575b505050811b01600255620002f9565b015160001960f88460031b161c191690553880806200015f565b8060018697829497870151815501960194019062000142565b620001ac565b600080fd5b634e487b7160e01b600052604160045260246000fd5b60408051919082016001600160401b03811183821017620001a157604052600d8252565b60408051919082016001600160401b03811183821017620001a15760405260038252565b90600182811c921680156200023c575b60208310146200022657565b634e487b7160e01b600052602260045260246000fd5b91607f16916200021a565b601f811162000254575050565b6000906002825260208220906020601f850160051c8301941062000295575b601f0160051c01915b8281106200028957505050565b8181556001016200027c565b909250829062000273565b601f8111620002ad575050565b6000906003825260208220906020601f850160051c83019410620002ee575b601f0160051c01915b828110620002e257505050565b818155600101620002d5565b9092508290620002cc565b80519091906001600160401b038111620001a15762000325816200031f6003546200020a565b620002a0565b602080601f831160011462000364575081929360009262000358575b50508160011b916000199060031b1c191617600355565b01519050388062000341565b6003600052601f198316949091907fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b926000905b878210620003d3575050836001959610620003b9575b505050811b01600355565b015160001960f88460031b161c19169055388080620003ae565b8060018596829496860151815501950193019062000398565b600980546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a356fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a71461028757806306fdde0314610282578063081812fc1461027d578063095ea7b31461027857806316c38b3c1461027357806318160ddd1461026e57806323b872dd1461026957806332cb6b0c14610264578063370fb4b01461025f5780633ccfd60b1461025a57806342842e0e14610255578063453c231014610250578063487586971461024b5780635c975abb146102465780636352211e146102415780636817c76c1461023c57806370a0823114610237578063715018a61461023257806384a9bfe81461022d5780638ba4cc3c146102285780638d0eaa4d146102235780638da5cb5b1461021e57806395d89b41146102195780639e2e9ce814610214578063a0712d681461020f578063a22cb4651461020a578063b7651b4914610205578063b88d4fde14610200578063c2ba4744146101fb578063c839fe94146101f6578063c87b56dd146101f1578063d7a87a23146101ec578063da0239a6146101e7578063dd3b5f9a146101e2578063e268e4d3146101dd578063e6c0a851146101d8578063e985e9c5146101d3578063f2fde38b146101ce5763f4a0a528146101c957600080fd5b611486565b6113f8565b61139b565b61137d565b61135c565b61132d565b6112fc565b6112cd565b610faa565b610e7b565b610e13565b610d90565b610c48565b610bba565b610a7a565b610a5c565b610999565b610970565b610952565b6108f4565b6108d6565b610878565b61081e565b610800565b6107d1565b6107ae565b61075f565b610741565b61071e565b6106a7565b610670565b610653565b61063f565b6105e7565b6105ae565b6104f8565b610479565b61036d565b6102a3565b6001600160e01b031981160361029e57565b600080fd5b3461029e57602036600319011261029e5760206004356102c28161028c565b63ffffffff60e01b166301ffc9a760e01b8114908115610300575b81156102ef575b506040519015158152f35b635b5e139f60e01b149050386102e4565b6380ac58cd60e01b811491506102dd565b60005b8381106103245750506000910152565b8181015183820152602001610314565b9060209161034d81518092818552858086019101610311565b601f01601f1916010190565b90602061036a928181520190610334565b90565b3461029e576000806003193601126104765760405190806002549060019180831c9280821692831561046c575b602092838610851461045857858852602088019490811561043757506001146103de575b6103da876103ce81890382610ce5565b60405191829182610359565b0390f35b600260005294509192917f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b83861061042657505050910190506103ce826103da38806103be565b80548587015294820194810161040a565b60ff191685525050505090151560051b0190506103ce826103da38806103be565b634e487b7160e01b82526022600452602482fd5b93607f169361039a565b80fd5b3461029e57602036600319011261029e5760043561049681613b6c565b156104bb576000526006602052602060018060a01b0360406000205416604051908152f35b6333d1c03960e21b60005260046000fd5b600435906001600160a01b038216820361029e57565b602435906001600160a01b038216820361029e57565b604036600319011261029e5761050c6104cc565b6001600160a01b0390602435908261052383613ae1565b1680330361057c575b600093838552600660205260408520921691826bffffffffffffffffffffffff60a01b8254161790557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b600081815260076020908152604080832033845290915290205460ff1661052c576367d9dca160e11b60005260046000fd5b3461029e57602036600319011261029e5760043580151580910361029e576105d46114a7565b60ff801960135416911617601355600080f35b3461029e57600036600319011261029e5760206000546001549003604051908152f35b606090600319011261029e576001600160a01b0390600435828116810361029e5791602435908116810361029e579060443590565b61065161064b3661060a565b91613baf565b005b3461029e57600036600319011261029e5760206040516127108152f35b3461029e57600036600319011261029e576080600f5460105460115460125491604051938452602084015260408301526060820152f35b3461029e57600080600319360112610476576106c16114a7565b6106c96139f0565b8080808047335af16106d96139c0565b50156106e7576001600a5580f35b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b61065161072a3661060a565b906040519261073884610c8f565b60008452613ff5565b3461029e57600036600319011261029e576020600c54604051908152f35b3461029e57602036600319011261029e5760043561077c81613b6c565b1561079c57600052600d602052602060ff60406000205416604051908152f35b60405163677510db60e11b8152600490fd5b3461029e57600036600319011261029e57602060ff601354166040519015158152f35b3461029e57602036600319011261029e5760206001600160a01b036107f7600435613ae1565b16604051908152f35b3461029e57600036600319011261029e576020600b54604051908152f35b3461029e57602036600319011261029e576001600160a01b0361083f6104cc565b16801561086757600052600560205260206001600160401b0360406000205416604051908152f35b6323d3ad8160e21b60005260046000fd5b3461029e57600080600319360112610476576108926114a7565b600980546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b3461029e57600036600319011261029e576020600f54604051908152f35b3461029e57604036600319011261029e5761090d6104cc565b6024356109186114a7565b600054600154900381810180911161094d576127101061093b576106519161410b565b604051638a164f6360e01b8152600490fd5b61155c565b3461029e57600036600319011261029e576020601054604051908152f35b3461029e57600036600319011261029e576009546040516001600160a01b039091168152602090f35b3461029e576000806003193601126104765760405190806003549060019180831c92808216928315610a52575b602092838610851461045857858852602088019490811561043757506001146109f9576103da876103ce81890382610ce5565b600360005294509192917fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b838610610a4157505050910190506103ce826103da38806103be565b805485870152948201948101610a25565b93607f16936109c6565b3461029e57600036600319011261029e576020601254604051908152f35b602036600319011261029e5760048035610a926139f0565b60135460ff16610baa578015610b9a57336000908152600560205260409081902054610acf918391901c6001600160401b03166115ed565b6115ed565b600c5410610b8a57612710610aec82610aca600054600154900390565b11610b7a57610afd81600b546115cc565b3410610b6a57610b0d813361410b565b600b54610b1a82826115cc565b3411610b2b575b6106516001600a55565b600080610b43610b3d829583956115cc565b34611a3d565b335af1610b4e6139c0565b5015610b5b578080610b21565b604051633c31275160e21b8152fd5b5060405163356680b760e01b8152fd5b50604051638a164f6360e01b8152fd5b50604051637ab0312d60e11b8152fd5b5060405163078d696560e31b8152fd5b50604051636be9245d60e11b8152fd5b3461029e57604036600319011261029e57610bd36104cc565b6024359081151580920361029e573360009081526007602090815260408083206001600160a01b0385168452909152902060ff1981541660ff841617905560405191825260018060a01b0316907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b3461029e57602036600319011261029e57600435600052600e602052602060ff604060002054166040519015158152f35b634e487b7160e01b600052604160045260246000fd5b602081019081106001600160401b03821117610caa57604052565b610c79565b606081019081106001600160401b03821117610caa57604052565b604081019081106001600160401b03821117610caa57604052565b90601f801991011681019081106001600160401b03821117610caa57604052565b604051906103c082018281106001600160401b03821117610caa57604052565b60405190610d3382610caf565b565b6040519061014082018281106001600160401b03821117610caa57604052565b6040519061010082018281106001600160401b03821117610caa57604052565b6001600160401b038111610caa57601f01601f191660200190565b608036600319011261029e57610da46104cc565b610dac6104e2565b606435916001600160401b03831161029e573660238401121561029e57826004013591610dd883610d75565b92610de66040519485610ce5565b808452366024828701011161029e5760208160009260246106519801838801378501015260443591613ff5565b3461029e57602036600319011261029e576020610e36610e316104cc565b613a52565b6040519015158152f35b6020908160408183019282815285518094520193019160005b828110610e67575050505090565b835185529381019392810192600101610e59565b3461029e57606036600319011261029e57610e946104cc565b60243560443590600054808311610fa2575b506000815b838110610f485750610ebc90613aa5565b926000915b838110610ed657604051806103da8782610e40565b610edf81613b6c565b80610f19575b610ef8575b610ef3906119e6565b610ec1565b91610f118184610f0b610ef39489613acd565b526119e6565b929050610eea565b50610f35610f29610f2983613ae1565b6001600160a01b031690565b6001600160a01b03838116911614610ee5565b610f5181613b6c565b80610f7f575b610f6a575b610f65906119e6565b610eab565b90610f77610f65916119e6565b919050610f5c565b50610f8f610f29610f2983613ae1565b6001600160a01b03868116911614610f57565b915038610ea6565b3461029e57602036600319011261029e57600435610fce610fca82613b6c565b1590565b61079c57610fdb816118dc565b610fe481611c5f565b602082015160ff16610ff59061393a565b60408301516110069060ff1661170d565b606093909301516110199060ff1661170d565b604051605b60f81b6020820152938492602184017f7b2274726169745f74797065223a2022526172697479222c202276616c7565228152621d101160e91b6020820152602301611068916114d3565b62089f4b60ea1b81526003017f7b2274726169745f74797065223a202254656d706c617465222c202276616c75815269032911d10112a3cb832960b51b6020820152602a016110b6916114d3565b62089f4b60ea1b81526003017f7b2274726169745f74797065223a202250616c65747465222c202276616c756581526b0111d10112830b632ba3a32960a51b6020820152602c01611106916114d3565b62227d5d60e81b81526003010392601f199384810184526111279084610ce5565b6111309061170d565b906111396114fd565b6111429161162c565b6040517f7b226e616d65223a2022536f7665726569676e4269742023000000000000000060208201529283929091906038840161117e916114d3565b61088b60f21b81526002017f226465736372697074696f6e223a2022412066756c6c79206f6e2d636861696e81527f2064657465726d696e697374696320706978656c206172742063686172616374602082015264195c8b888b60da1b60408201526045017f22696d616765223a2022646174613a696d6167652f7376672b786d6c3b626173815263194d8d0b60e21b602082015260240161121f916114d3565b61088b60f21b81526002016d01130ba3a3934b13aba32b9911d160951b8152600e0161124a916114d3565b607d60f81b81526001010382810182526112649082610ce5565b61126c6114fd565b6112759161162c565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000602082015291908290603d82016112af916114d3565b0390810182526112bf9082610ce5565b6040516103da819282610359565b3461029e57602036600319011261029e5760406112eb600435613a13565b60ff83519216825215156020820152f35b3461029e57600036600319011261029e57600054600154900361271090810390811161094d57602090604051908152f35b3461029e57602036600319011261029e57600435600052600d602052602060ff60406000205416604051908152f35b3461029e57602036600319011261029e576113756114a7565b600435600c55005b3461029e57600036600319011261029e576020601154604051908152f35b3461029e57604036600319011261029e57602060ff6113ec6113bb6104cc565b6113c36104e2565b6001600160a01b0391821660009081526007865260408082209290931681526020919091522090565b54166040519015158152f35b3461029e57602036600319011261029e576114116104cc565b6114196114a7565b6001600160a01b0390811690811561146d57600954826bffffffffffffffffffffffff60a01b821617600955167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b3461029e57602036600319011261029e5761149f6114a7565b600435600b55005b6009546001600160a01b031633036114bb57565b60405163118cdaa760e01b8152336004820152602490fd5b906114e660209282815194859201610311565b0190565b604051906114f782610c8f565b60008252565b6040519061150a82610caf565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b634e487b7160e01b600052601160045260246000fd5b600281901b91906001600160fe1b0381160361094d57565b908160021b918083046004149015171561094d57565b908160061b918083046040149015171561094d57565b908160011b918083046002149015171561094d57565b8181029291811591840414171561094d57565b906002820180921161094d57565b9190820180921161094d57565b9061160482610d75565b6116116040519182610ce5565b8281528092611622601f1991610d75565b0190602036910137565b908151156117035761165861165361164e61164785516115df565b6003900490565b611572565b6115fa565b91602083019181825183016020810191825193600084525b8282106116b1575050505251600390066001811461169e57600214611693575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091956004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301959190611670565b505061036a6114ea565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000080821015611842575b506d04ee2d6d415b85acef810000000080831015611833575b50662386f26fc1000080831015611824575b506305f5e10080831015611815575b5061271080831015611806575b5060648210156117f6575b600a809210156117ec575b6001908160216117a48287016115fa565b95860101905b6117b6575b5050505090565b600019019083906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a8353049182156117e7579190826117aa565b6117af565b9160010191611793565b9190606460029104910191611788565b6004919392049101913861177d565b60089193920491019138611770565b60109193920491019138611761565b6020919392049101913861174f565b604093508104915038611736565b6040519060c082018281106001600160401b03821117610caa576040528160a06000918281528260208201528260408201528260608201528260808201520152565b6040519061189f82610cca565b6011825270534f5645524549474e5f424954535f563160781b6020830152565b6020929181526118d782518093858085019101610311565b010190565b6118e4611850565b506119046119126118f3611892565b6040519283916020830195866118bf565b03601f198101835282610ce5565b51902061036a60ff6014611924611850565b848152936127108106611d4c811015611982575060006020860152600881901c60071660408601525b60ff6028601083901c06841616606086015260ff600a601883901c06841616608086015260281c061660a083019060ff169052565b6124548110156119ab57506001602086015260ff6003600883901c06841616604086015261194d565b6126de11156119cd5760026020860152600881901c600116604086015261194d565b60036020860152600881901c600116604086015261194d565b600019811461094d5760010190565b634e487b7160e01b600052603260045260246000fd5b906008811015611a1c5760051b0190565b6119f5565b60c0039060c0821161094d57565b603e0390603e821161094d57565b9190820391821161094d57565b60405190611a5782610cca565b60078252660233030303030360cc1b6020830152565b90610d33929493604f92611b146040519788948351611a948160209687808b019101610311565b8601683c7265637420783d2760b81b85820152611aba8251809387602985019101610311565b01642720793d2760d81b6029820152611adc8251809386602e85019101610311565b01917f272077696474683d273127206865696768743d2731272066696c6c3d27000000602e8401528351938491604b85019101610311565b01631390179f60e11b604b82015203602f810185520183610ce5565b6020610d33919392936040519481611b518793518092868087019101610311565b8201611b6582518093868085019101610311565b01038085520183610ce5565b6099610d33919392936040519485917f3c73766720786d6c6e733d27687474703a2f2f7777772e77332e6f72672f323060208401527f30302f737667272076696577426f783d2730203020333220333227207368617060408401527f652d72656e646572696e673d276372697370456467657327207374796c653d276060840152703130b1b5b3b937bab73216b1b7b637b91d60791b6080840152611c20815180926020609187019101610311565b820161139f60f11b6091820152611c41825180936020609385019101610311565b01651e17b9bb339f60d11b6093820152036079810185520183610ce5565b906060611c77611c728285015160ff1690565b612a44565b92611c8e611c8960a083015160ff1690565b61317f565b90602094611cbd611cb86080611caf611caa8a87015160ff1690565b613599565b94015160ff1690565b613242565b611cc56114ea565b9460005b60088110611ce157505050505061036a929350611b71565b611ceb8186611a0b565b51611cf68285611a0b565b51811580611e80575b611e7557906000915b8b60048410611d235750505050611d1e906119e6565b611cc9565b90919299611d348b610aca8761158a565b611d45611d408d6115a0565b611a21565b906001600160401b03858188851c16931c1691801580611e6d575b611e5f57611d6c6114ea565b9460005b818110611d96575050505050611d8f91611d8991611b30565b996119e6565b9190611d08565b8c611da8611da3836115b6565b611a2f565b6003858189841c16928315611e53575b50508d82611dd3575b50505050611dce906119e6565b611d70565b9185611e139492611dce969c949260018114600014611e1f575050505050611df9611a4a565b905b611e048a61170d565b611e0d8861170d565b91611a6d565b9690508c38808d611dc1565b60028103611e3257505050505190611dfb565b949391929414611e44575b5050611dfb565b909192500151908f8590611e3d565b1c811691508538611db8565b50505099611d8f91506119e6565b508215611d60565b5050611d1e906119e6565b508015611cff565b60405190611e9582610caf565b819060005b606080821015611eb05784820152602001611e9a565b5050909150565b60405190611ec482610cca565b6007825266119aa220a2229960c91b6020830152565b60405190611ee782610cca565b60078252662332453836433160c81b6020830152565b60405190611f0a82610cca565b60078252662341454436463160c81b6020830152565b60405190611f2d82610cca565b60078252660233237414536360cc1b6020830152565b60405190611f5082610cca565b60078252662331453834343960c81b6020830152565b60405190611f7382610cca565b600782526611a0a122a1219b60c91b6020830152565b60405190611f9682610cca565b600782526611a198199c992160c91b6020830152565b60405190611fb982610cca565b60078252662339323242323160c81b6020830152565b60405190611fdc82610cca565b60078252662345364230414160c81b6020830152565b60405190611fff82610cca565b60078252660234433353430360cc1b6020830152565b6040519061202282610cca565b60078252660234130343030360cc1b6020830152565b6040519061204582610cca565b60078252662345444242393960c81b6020830152565b6040519061206882610cca565b600782526608ce114d0d105160ca1b6020830152565b6040519061208b82610cca565b60078252662336433334383360c81b6020830152565b604051906120ae82610cca565b60078252662344324234444560c81b6020830152565b604051906120d182610cca565b600782526611a318a19a182360c91b6020830152565b604051906120f482610cca565b600782526611a11b9c9a982160c91b6020830152565b6040519061211782610cca565b600782526611a31ca29b9ca360c91b6020830152565b6040519061213a82610cca565b60078252660233243334535360cc1b6020830152565b6040519061215d82610cca565b60078252662331373230324160c81b6020830152565b6040519061218082610cca565b6007825266119c181c211c9b60c91b6020830152565b604051906121a382610cca565b600782526611a29a9c9c1b1b60c91b6020830152565b604051906121c682610cca565b60078252660234241344130360cc1b6020830152565b604051906121e982610cca565b60078252662346364444434360c81b6020830152565b6040519061220c82610cca565b60078252662331414243394360c81b6020830152565b6040519061222f82610cca565b60078252662331313741363560c81b6020830152565b6040519061225282610cca565b60078252662341334534443760c81b6020830152565b6040519061227582610cca565b60078252662332453430353360c81b6020830152565b6040519061229882610cca565b60078252662331423236333160c81b6020830152565b604051906122bb82610cca565b60078252662335443644374560c81b6020830152565b604051906122de82610cca565b6007825266119c9aa09aa09b60c91b6020830152565b6040519061230182610cca565b600782526608cdd18e10ce1160ca1b6020830152565b6040519061232482610cca565b600782526611a1a0a1a3221960c91b6020830152565b6040519061234782610cca565b60078252660233645324330360cc1b6020830152565b6040519061236a82610cca565b600782526608d10d1050cc1160ca1b6020830152565b6040519061238d82610cca565b60078252662339413744304160c81b6020830152565b604051906123b082610cca565b600782526611a31ba2219b2360c91b6020830152565b604051906123d382610cca565b600782526608cd4e110d8e1160ca1b6020830152565b604051906123f682610cca565b60078252662332384234363360c81b6020830152565b6040519061241982610cca565b60078252662338324530414160c81b6020830152565b6040519061243c82610cca565b60078252662341463741433560c81b6020830152565b6040519061245f82610cca565b60078252660233838344541360cc1b6020830152565b6040519061248282610cca565b600782526611a21ba122229960c91b6020830152565b604051906124a582610cca565b600782526611a3199ca1989960c91b6020830152565b604051906124c882610cca565b60078252660234436383931360cc1b6020830152565b604051906124eb82610cca565b60078252660234641443741360cc1b6020830152565b6040519061250e82610cca565b60078252662345433730363360c81b6020830152565b6040519061253182610cca565b60078252662343423433333560c81b6020830152565b6040519061255482610cca565b60078252662346324437443560c81b6020830152565b6040519061257782610cca565b60078252662335343939433760c81b6020830152565b6040519061259a82610cca565b60078252662332343731413360c81b6020830152565b604051906125bd82610cca565b60078252662344344536463160c81b6020830152565b604051906125e082610cca565b60078252660233438433942360cc1b6020830152565b6040519061260382610cca565b60078252662331374135383960c81b6020830152565b6040519061262682610cca565b600782526608d04d4d8e509160ca1b6020830152565b6040519061264982610cca565b600782526611a3231818232360c91b6020830152565b6040519061266c82610cca565b60078252662339393030393960c81b6020830152565b6040519061268f82610cca565b600782526611a3231b1b232360c91b6020830152565b604051906126b282610cca565b60078252661198182323232360c91b6020830152565b604051906126d582610cca565b60078252661198181c211c2160c91b6020830152565b604051906126f882610cca565b600782526611a2982323232360c91b6020830152565b6040519061271b82610cca565b600782526611999921a2199960c91b6020830152565b6040519061273e82610cca565b60078252660233030363430360cc1b6020830152565b6040519061276182610cca565b600782526604672708c8472760cb1b6020830152565b6040519061278482610cca565b60078252660234646343530360cc1b6020830152565b604051906127a782610cca565b60078252660233842303030360cc1b6020830152565b604051906127ca82610cca565b60078252662346464130374160c81b6020830152565b604051906127ed82610cca565b600782526611a318231c232360c91b6020830152565b6040519061281082610cca565b60078252662342304334444560c81b6020830152565b6040519061283382610cca565b600782526611a3232323232360c91b6020830152565b6040519061285682610cca565b60078252662338423435313360c81b6020830152565b6040519061287982610cca565b60078252662335443430333760c81b6020830152565b6040519061289c82610cca565b60078252662344323639314560c81b6020830152565b604051906128bf82610cca565b60078252662332313231323160c81b6020830152565b604051906128e282610cca565b6007825266119a191a191a1960c91b6020830152565b6040519061290582610cca565b60078252660234646443730360cc1b6020830152565b6040519061292882610cca565b60078252660234441413532360cc1b6020830152565b6040519061294b82610cca565b600782526608d191919050d160ca1b6020830152565b6040519061296e82610cca565b60078252660233030303038360cc1b6020830152565b6040519061299182610cca565b600782526608cc0c0c0c10d160ca1b6020830152565b604051906129b482610cca565b60078252662334313639453160c81b6020830152565b604051906129d782610cca565b60078252660233830303038360cc1b6020830152565b604051906129fa82610cca565b6007825266119a2118181c1960c91b6020830152565b60405190612a1d82610cca565b6007825266119c999b98222160c91b6020830152565b90601e811015611a1c5760051b0190565b612a4c611e88565b5060ff612a57610d06565b91612a60610d26565b612a68611eb7565b8152612a72611eda565b9060209182820152612a82611efd565b90604091828201528552612a94610d26565b612a9c611f20565b8152612aa6611f43565b83820152612ab2611f66565b8282015282860152612ac2610d26565b612aca611f89565b8152612ad4611fac565b83820152612ae0611fcf565b8282015281860152612af0610d26565b612af8611ff2565b8152612b02612015565b83820152612b0e612038565b828201526060860152612b1f610d26565b612b2761205b565b8152612b3161207e565b83820152612b3d6120a1565b828201526080860152612b4e610d26565b612b566120c4565b8152612b606120e7565b83820152612b6c61210a565b8282015260a0860152612b7d610d26565b612b8561212d565b8152612b8f612150565b83820152612b9b612173565b8282015260c0860152612bac610d26565b612bb4612196565b8152612bbe6121b9565b83820152612bca6121dc565b8282015260e0860152612bdb610d26565b612be36121ff565b8152612bed612222565b83820152612bf9612245565b82820152610100860152612c0b610d26565b612c13612268565b8152612c1d61228b565b83820152612c296122ae565b82820152610120860152612c3b610d26565b612c436122d1565b8152612c4d6122f4565b83820152612c59612317565b82820152610140860152612c6b610d26565b612c73612015565b8152612c7d61233a565b83820152612c89612196565b82820152610160860152612c9b610d26565b612ca361235d565b8152612cad612380565b83820152612cb96123a3565b82820152610180860152612ccb610d26565b612cd36123c6565b8152612cdd6123e9565b83820152612ce961240c565b828201526101a0860152612cfb610d26565b612d0361242f565b8152612d0d612452565b83820152612d19612475565b828201526101c0860152612d2b610d26565b612d33612498565b8152612d3d6124bb565b83820152612d496124de565b828201526101e0860152612d5b610d26565b612d63612501565b8152612d6d612524565b83820152612d79612547565b82820152610200860152612d8b610d26565b612d9361256a565b8152612d9d61258d565b83820152612da96125b0565b82820152610220860152612dbb610d26565b612dc36125d3565b8152612dcd6125f6565b83820152612dd9612245565b82820152610240860152612deb610d26565b612df3612619565b8152612dfd612452565b83820152612e096120a1565b82820152610260860152612e1b610d26565b612e2361263c565b8152612e2d61265f565b83820152612e39612682565b82820152610280860152612e4b610d26565b612e536126a5565b8152612e5d6126c8565b83820152612e696126eb565b828201526102a0860152612e7b610d26565b612e8361270e565b8152612e8d612731565b83820152612e99612754565b828201526102c0860152612eab610d26565b612eb3612777565b8152612ebd61279a565b83820152612ec96127bd565b828201526102e0860152612edb610d26565b612ee36127e0565b8152612eed612803565b83820152612ef9612826565b82820152610300860152612f0b610d26565b612f13612849565b8152612f1d61286c565b83820152612f2961288f565b82820152610320860152612f3b610d26565b612f436128b2565b8152612f4d611a4a565b83820152612f596128d5565b82820152610340860152612f6b610d26565b612f736128f8565b8152612f7d61291b565b83820152612f8961293e565b82820152610360860152612f9b610d26565b612fa3612961565b8152612fad612984565b83820152612fb96129a7565b82820152610380860152612fcb610d26565b91612fd46129ca565b8352612fde6129ed565b90830152612fea612a10565b908201526103a084015216601e81101561300b5761300791612a33565b5190565b505190565b6040519061301d82610cca565b600782526608d18c918cd18d60ca1b6020830152565b6040519061304082610cca565b60078252662345414641463160c81b6020830152565b6040519061306382610cca565b60078252662346454639453760c81b6020830152565b6040519061308682610cca565b60078252660468c6a8a8a8c760cb1b6020830152565b604051906130a982610cca565b600782526611a2a1231aa32160c91b6020830152565b604051906130cc82610cca565b60078252662346444544454360c81b6020830152565b604051906130ef82610cca565b600782526611a29c2220a2a360c91b6020830152565b6040519061311282610cca565b60078252662344354635453360c81b6020830152565b6040519061313582610cca565b600782526611a321a319a1a360c91b6020830152565b6040519061315882610cca565b6007825266046886c8a828c760cb1b6020830152565b90600a811015611a1c5760051b0190565b60ff613189610d35565b91613192613010565b835261319c613033565b60208401526131a9613056565b60408401526131b6613079565b60608401526131c361309c565b60808401526131d06130bf565b60a08401526131dd6130e2565b60c08401526131ea613105565b60e08401526131f7613128565b61010084015261320561314b565b61012084015216600a81101561300b576130079161316e565b604051906101008083018381106001600160401b03821117610caa57604052368337565b60ff9061324d61321e565b50168015613590576001811461354b57600281146134ca5760038114613471576004811461342c57600581146133ee57600681146133b057600781146133505760088114613312576009146132d5576132a4610d55565b60008082528060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b6132dd610d55565b6330000000815260008060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b5061331b610d55565b6000808252600f605e1b60208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b50613359610d55565b7f100000000000000000000000000000010000000000000000000000000000000180825260018060fc1b0180602084015280604084015280606084015280608084015260a083015260c0820152600060e082015290565b506133b9610d55565b6000808252600160611b60208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b506133f7610d55565b6000808252603f60501b60208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b50613435610d55565b6a1500000000000003f00000815260008060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b5061347a610d55565b60008082528060208301528060408301527e0c000000000000003f000000000000003f000000000000000c00000000000060608301528060808301528060a08301528060c083015260e082015290565b506134d3610d55565b600081526000602082015270030000000000000000000000000000000360408201527803000000000000000300000000000000030000000000000003606082015278030000000000000003000000000000000c000000000000000c6080820152600060a0820152600060c0820152600060e082015290565b50613554610d55565b6a3f00000000000003f00000815260008060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b506132a4610d55565b60ff906135a461321e565b501660028114613830576001811461374d5760031461368a576135c5610d55565b60008082526c5555000000000002affa80000060208301527d02aefa800000000002fffa800000000002efaa800000000001555500000060408301527d02d7d7800000000002affa800000000015555554000000001f2c3ce4000060608301527d15bfee540000000019afaa64000000001d2aa8640000000015475154000060808301527d15a69a540000000006f6af900000000001a55a400000000001541540000060a08301526b05955565000000000555555560921b60c083015260e082015290565b613692610d55565b60008082527c800080000000000320023000000000000aa80000000000000aa800000060208301527c0ffc0000000000000ddc0000000000000ffc0000000000030ffc30000060408301527cbaab8000000000002aaa0000000000003aab0000000000003aab00000060608301527c3aab0000000000003aab0000000000000f280000000000000f280000006080830152710f280000000000004f28400000000000151560581b60a083015260c0820181905260e082015290565b50613756610d55565b643ffc00000081527c1ff4000000000002aaaa800000000002bffe800000000002b7de80000060208201527d02bffe800000000002bffe800000000002aaaa80000000000febebf0000060408201527d0febebf0000000000febebf0000000003c2be83c000000003eabeabc000060608201527d3eabeabc000000003eabeabc0000000002abea800000000002abea80000060808201527d2aabeaa8000000002aabeaa8000000002aabeaa8000000002aabeaa8000060a08201526b05557d550000000005557d5560931b60c0820152600060e082015290565b50613839610d55565b6c1104000000000000333c00000081527c7ffd0000000000007ffd0000000000003ffc15000000000037dc08000060208201527c2aa81500000000002aa80c00000000002aa80c0000000006affa9c000060408201527d26affa9c0000000026affa9c0000000026affa9c0000000026affa9c000060608201527d26affa9c0000000026affa9c0000000006affa9c0000000006affa9c000060808201527d06affa9c0000000006affa9c0000000006affa900000000006affa90000060a08201526a6affa9000000000055555560941b60c0820152600060e082015290565b6040519061392682610cca565b600582526410dbdd5c9d60da1b6020830152565b60ff166003811461399e576002811461397d5760011461395c5761036a613919565b60405161396881610cca565b600581526428bab2b2b760d91b602082015290565b5060405161398a81610cca565b60048152634b696e6760e01b602082015290565b506040516139ab81610cca565b60058152642537b5b2b960d91b602082015290565b3d156139eb573d906139d182610d75565b916139df6040519384610ce5565b82523d6000602084013e565b606090565b6002600a5414613a01576002600a55565b604051633ee5aeb560e01b8152600490fd5b613a1c81613b6c565b1561079c57600052600e60205260ff60406000205416613a3e57600090600090565b600d60205260ff6040600020541690600190565b60ff60135416613a88576001600160a01b03166000908152600560205260409081902054901c6001600160401b0316600c541190565b50600090565b6001600160401b038111610caa5760051b60200190565b90613aaf82613a8e565b613abc6040519182610ce5565b8281528092611622601f1991613a8e565b8051821015611a1c5760209160051b010190565b613af5816000526004602052604060002090565b54908115613b0c5750600160e01b81166141e95790565b90506000908154811015613b5d575b60001901600081815260046020526040902054908115613b565750600160e01b811615613b5157636f96cda160e11b8252600482fd5b905090565b9050613b1b565b636f96cda160e11b8252600482fd5b90600091600080548210613b7e575050565b92505b8083526004602052604083205480613ba35750801561094d5760001901613b81565b600160e01b1615925050565b9190613bba82613ae1565b6001600160a01b0393841693818116859003613d3a5760008481526006602052604090208054613bf96001600160a01b03881633908114908314171590565b613cec575b613ce2575b506001600160a01b038581166000908152600560209081526040808320805460001901905592861682528282208054600101905586825260049052209083169190600160e11b904260a01b841782179055811615613c98575b508281857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a415613c9357610d3392613d3f565b61421b565b60018401613cb0816000526004602052604060002090565b5415613cbd575b50613c5c565b6000548114613cb757613cda906000526004602052604060002090565b553880613cb7565b6000905538613c03565b613d30610fca613d2933613d128b60018060a01b03166000526007602052604060002090565b9060018060a01b0316600052602052604060002090565b5460ff1690565b15613bfe5761420a565b6141fa565b6001600160a01b039190821615613d5557505050565b90919260005b600180821015613ebc5790613d9b91613d7482886115ed565b90613d8f610fca613d2984600052600e602052604060002090565b613da0575b50506119e6565b613d5b565b613e657fabe2dd785dc96ee74bd71829da26ef21eb2a306561a15a8bb8570a3f9f8883b591613ddb6020613dd3866118dc565b015160ff1690565b9060ff821660038103613e6f575050613dfd613df86012546119e6565b601255565b613e2481613e1586600052600d602052604060002090565b9060ff1660ff19825416179055565b613e48613e3b85600052600e602052604060002090565b805460ff19166001179055565b6040805194855260ff909116602085015287891693918291820190565b0390a23880613d94565b60028103613e91575050613e8c613e876011546119e6565b601155565b613dfd565b03613ea957613e8c613ea46010546119e6565b601055565b613e8c613eb7600f546119e6565b600f55565b505092505050565b9060005b838110613ed55750505050565b80613ee3613f0892846115ed565b613efd610fca613d2983600052600e602052604060002090565b613f0d575b506119e6565b613ec8565b7fabe2dd785dc96ee74bd71829da26ef21eb2a306561a15a8bb8570a3f9f8883b5613fad613f3f6020613dd3856118dc565b60ff811660038103613fb65750613f5a613df86012546119e6565b613f7281613e1586600052600d602052604060002090565b613f89613e3b85600052600e602052604060002090565b6040805194855260ff90911660208501526001600160a01b03881693918291820190565b0390a238613f02565b60028103613fd25750613fcd613e876011546119e6565b613f5a565b600103613fe757613fcd613ea46010546119e6565b613fcd613eb7600f546119e6565b929190614003828286613baf565b803b614010575b50505050565b6140199361404d565b15614027573880808061400a565b6368d2bf6b60e11b60005260046000fd5b9081602091031261029e575161036a8161028c565b604051630a85bd0160e11b8082523360048301526001600160a01b0392831660248301526044820194909452608060648201529293602092849290918391600091839061409e906084830190610334565b0393165af1600091816140db575b506140cd576140b96139c0565b8051156140c857805190602001fd5b614027565b6001600160e01b0319161490565b6140fd91925060203d8111614104575b6140f58183610ce5565b810190614038565b90386140ac565b503d6140eb565b919060009283549082156141da5760008281526004602052604090206001956001600160a01b038316914260a01b86891460e11b17831790556001600160a01b0383166000908152600560205260409020680100000000000000018602815401905581156141d55784840191849780805b614190575b505050610d3395965055613ec4565b156141c4575b82818a84867fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a461417c565b809801978389036141965780614181565b61422c565b63b562e8dd60e01b8552600485fd5b636f96cda160e11b60005260046000fd5b62a1148160e81b60005260046000fd5b632ce44b5f60e11b60005260046000fd5b633a954ecd60e21b60005260046000fd5b622e076360e81b60005260046000fdfea2646970667358221220c912be208f0f0a5a8d69cebea6aad356daf3d1f4fbe218da9289734b2b442b0064736f6c63430008140033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301ffc9a71461028757806306fdde0314610282578063081812fc1461027d578063095ea7b31461027857806316c38b3c1461027357806318160ddd1461026e57806323b872dd1461026957806332cb6b0c14610264578063370fb4b01461025f5780633ccfd60b1461025a57806342842e0e14610255578063453c231014610250578063487586971461024b5780635c975abb146102465780636352211e146102415780636817c76c1461023c57806370a0823114610237578063715018a61461023257806384a9bfe81461022d5780638ba4cc3c146102285780638d0eaa4d146102235780638da5cb5b1461021e57806395d89b41146102195780639e2e9ce814610214578063a0712d681461020f578063a22cb4651461020a578063b7651b4914610205578063b88d4fde14610200578063c2ba4744146101fb578063c839fe94146101f6578063c87b56dd146101f1578063d7a87a23146101ec578063da0239a6146101e7578063dd3b5f9a146101e2578063e268e4d3146101dd578063e6c0a851146101d8578063e985e9c5146101d3578063f2fde38b146101ce5763f4a0a528146101c957600080fd5b611486565b6113f8565b61139b565b61137d565b61135c565b61132d565b6112fc565b6112cd565b610faa565b610e7b565b610e13565b610d90565b610c48565b610bba565b610a7a565b610a5c565b610999565b610970565b610952565b6108f4565b6108d6565b610878565b61081e565b610800565b6107d1565b6107ae565b61075f565b610741565b61071e565b6106a7565b610670565b610653565b61063f565b6105e7565b6105ae565b6104f8565b610479565b61036d565b6102a3565b6001600160e01b031981160361029e57565b600080fd5b3461029e57602036600319011261029e5760206004356102c28161028c565b63ffffffff60e01b166301ffc9a760e01b8114908115610300575b81156102ef575b506040519015158152f35b635b5e139f60e01b149050386102e4565b6380ac58cd60e01b811491506102dd565b60005b8381106103245750506000910152565b8181015183820152602001610314565b9060209161034d81518092818552858086019101610311565b601f01601f1916010190565b90602061036a928181520190610334565b90565b3461029e576000806003193601126104765760405190806002549060019180831c9280821692831561046c575b602092838610851461045857858852602088019490811561043757506001146103de575b6103da876103ce81890382610ce5565b60405191829182610359565b0390f35b600260005294509192917f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b83861061042657505050910190506103ce826103da38806103be565b80548587015294820194810161040a565b60ff191685525050505090151560051b0190506103ce826103da38806103be565b634e487b7160e01b82526022600452602482fd5b93607f169361039a565b80fd5b3461029e57602036600319011261029e5760043561049681613b6c565b156104bb576000526006602052602060018060a01b0360406000205416604051908152f35b6333d1c03960e21b60005260046000fd5b600435906001600160a01b038216820361029e57565b602435906001600160a01b038216820361029e57565b604036600319011261029e5761050c6104cc565b6001600160a01b0390602435908261052383613ae1565b1680330361057c575b600093838552600660205260408520921691826bffffffffffffffffffffffff60a01b8254161790557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b600081815260076020908152604080832033845290915290205460ff1661052c576367d9dca160e11b60005260046000fd5b3461029e57602036600319011261029e5760043580151580910361029e576105d46114a7565b60ff801960135416911617601355600080f35b3461029e57600036600319011261029e5760206000546001549003604051908152f35b606090600319011261029e576001600160a01b0390600435828116810361029e5791602435908116810361029e579060443590565b61065161064b3661060a565b91613baf565b005b3461029e57600036600319011261029e5760206040516127108152f35b3461029e57600036600319011261029e576080600f5460105460115460125491604051938452602084015260408301526060820152f35b3461029e57600080600319360112610476576106c16114a7565b6106c96139f0565b8080808047335af16106d96139c0565b50156106e7576001600a5580f35b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b61065161072a3661060a565b906040519261073884610c8f565b60008452613ff5565b3461029e57600036600319011261029e576020600c54604051908152f35b3461029e57602036600319011261029e5760043561077c81613b6c565b1561079c57600052600d602052602060ff60406000205416604051908152f35b60405163677510db60e11b8152600490fd5b3461029e57600036600319011261029e57602060ff601354166040519015158152f35b3461029e57602036600319011261029e5760206001600160a01b036107f7600435613ae1565b16604051908152f35b3461029e57600036600319011261029e576020600b54604051908152f35b3461029e57602036600319011261029e576001600160a01b0361083f6104cc565b16801561086757600052600560205260206001600160401b0360406000205416604051908152f35b6323d3ad8160e21b60005260046000fd5b3461029e57600080600319360112610476576108926114a7565b600980546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b3461029e57600036600319011261029e576020600f54604051908152f35b3461029e57604036600319011261029e5761090d6104cc565b6024356109186114a7565b600054600154900381810180911161094d576127101061093b576106519161410b565b604051638a164f6360e01b8152600490fd5b61155c565b3461029e57600036600319011261029e576020601054604051908152f35b3461029e57600036600319011261029e576009546040516001600160a01b039091168152602090f35b3461029e576000806003193601126104765760405190806003549060019180831c92808216928315610a52575b602092838610851461045857858852602088019490811561043757506001146109f9576103da876103ce81890382610ce5565b600360005294509192917fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b838610610a4157505050910190506103ce826103da38806103be565b805485870152948201948101610a25565b93607f16936109c6565b3461029e57600036600319011261029e576020601254604051908152f35b602036600319011261029e5760048035610a926139f0565b60135460ff16610baa578015610b9a57336000908152600560205260409081902054610acf918391901c6001600160401b03166115ed565b6115ed565b600c5410610b8a57612710610aec82610aca600054600154900390565b11610b7a57610afd81600b546115cc565b3410610b6a57610b0d813361410b565b600b54610b1a82826115cc565b3411610b2b575b6106516001600a55565b600080610b43610b3d829583956115cc565b34611a3d565b335af1610b4e6139c0565b5015610b5b578080610b21565b604051633c31275160e21b8152fd5b5060405163356680b760e01b8152fd5b50604051638a164f6360e01b8152fd5b50604051637ab0312d60e11b8152fd5b5060405163078d696560e31b8152fd5b50604051636be9245d60e11b8152fd5b3461029e57604036600319011261029e57610bd36104cc565b6024359081151580920361029e573360009081526007602090815260408083206001600160a01b0385168452909152902060ff1981541660ff841617905560405191825260018060a01b0316907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b3461029e57602036600319011261029e57600435600052600e602052602060ff604060002054166040519015158152f35b634e487b7160e01b600052604160045260246000fd5b602081019081106001600160401b03821117610caa57604052565b610c79565b606081019081106001600160401b03821117610caa57604052565b604081019081106001600160401b03821117610caa57604052565b90601f801991011681019081106001600160401b03821117610caa57604052565b604051906103c082018281106001600160401b03821117610caa57604052565b60405190610d3382610caf565b565b6040519061014082018281106001600160401b03821117610caa57604052565b6040519061010082018281106001600160401b03821117610caa57604052565b6001600160401b038111610caa57601f01601f191660200190565b608036600319011261029e57610da46104cc565b610dac6104e2565b606435916001600160401b03831161029e573660238401121561029e57826004013591610dd883610d75565b92610de66040519485610ce5565b808452366024828701011161029e5760208160009260246106519801838801378501015260443591613ff5565b3461029e57602036600319011261029e576020610e36610e316104cc565b613a52565b6040519015158152f35b6020908160408183019282815285518094520193019160005b828110610e67575050505090565b835185529381019392810192600101610e59565b3461029e57606036600319011261029e57610e946104cc565b60243560443590600054808311610fa2575b506000815b838110610f485750610ebc90613aa5565b926000915b838110610ed657604051806103da8782610e40565b610edf81613b6c565b80610f19575b610ef8575b610ef3906119e6565b610ec1565b91610f118184610f0b610ef39489613acd565b526119e6565b929050610eea565b50610f35610f29610f2983613ae1565b6001600160a01b031690565b6001600160a01b03838116911614610ee5565b610f5181613b6c565b80610f7f575b610f6a575b610f65906119e6565b610eab565b90610f77610f65916119e6565b919050610f5c565b50610f8f610f29610f2983613ae1565b6001600160a01b03868116911614610f57565b915038610ea6565b3461029e57602036600319011261029e57600435610fce610fca82613b6c565b1590565b61079c57610fdb816118dc565b610fe481611c5f565b602082015160ff16610ff59061393a565b60408301516110069060ff1661170d565b606093909301516110199060ff1661170d565b604051605b60f81b6020820152938492602184017f7b2274726169745f74797065223a2022526172697479222c202276616c7565228152621d101160e91b6020820152602301611068916114d3565b62089f4b60ea1b81526003017f7b2274726169745f74797065223a202254656d706c617465222c202276616c75815269032911d10112a3cb832960b51b6020820152602a016110b6916114d3565b62089f4b60ea1b81526003017f7b2274726169745f74797065223a202250616c65747465222c202276616c756581526b0111d10112830b632ba3a32960a51b6020820152602c01611106916114d3565b62227d5d60e81b81526003010392601f199384810184526111279084610ce5565b6111309061170d565b906111396114fd565b6111429161162c565b6040517f7b226e616d65223a2022536f7665726569676e4269742023000000000000000060208201529283929091906038840161117e916114d3565b61088b60f21b81526002017f226465736372697074696f6e223a2022412066756c6c79206f6e2d636861696e81527f2064657465726d696e697374696320706978656c206172742063686172616374602082015264195c8b888b60da1b60408201526045017f22696d616765223a2022646174613a696d6167652f7376672b786d6c3b626173815263194d8d0b60e21b602082015260240161121f916114d3565b61088b60f21b81526002016d01130ba3a3934b13aba32b9911d160951b8152600e0161124a916114d3565b607d60f81b81526001010382810182526112649082610ce5565b61126c6114fd565b6112759161162c565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000602082015291908290603d82016112af916114d3565b0390810182526112bf9082610ce5565b6040516103da819282610359565b3461029e57602036600319011261029e5760406112eb600435613a13565b60ff83519216825215156020820152f35b3461029e57600036600319011261029e57600054600154900361271090810390811161094d57602090604051908152f35b3461029e57602036600319011261029e57600435600052600d602052602060ff60406000205416604051908152f35b3461029e57602036600319011261029e576113756114a7565b600435600c55005b3461029e57600036600319011261029e576020601154604051908152f35b3461029e57604036600319011261029e57602060ff6113ec6113bb6104cc565b6113c36104e2565b6001600160a01b0391821660009081526007865260408082209290931681526020919091522090565b54166040519015158152f35b3461029e57602036600319011261029e576114116104cc565b6114196114a7565b6001600160a01b0390811690811561146d57600954826bffffffffffffffffffffffff60a01b821617600955167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b3461029e57602036600319011261029e5761149f6114a7565b600435600b55005b6009546001600160a01b031633036114bb57565b60405163118cdaa760e01b8152336004820152602490fd5b906114e660209282815194859201610311565b0190565b604051906114f782610c8f565b60008252565b6040519061150a82610caf565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b634e487b7160e01b600052601160045260246000fd5b600281901b91906001600160fe1b0381160361094d57565b908160021b918083046004149015171561094d57565b908160061b918083046040149015171561094d57565b908160011b918083046002149015171561094d57565b8181029291811591840414171561094d57565b906002820180921161094d57565b9190820180921161094d57565b9061160482610d75565b6116116040519182610ce5565b8281528092611622601f1991610d75565b0190602036910137565b908151156117035761165861165361164e61164785516115df565b6003900490565b611572565b6115fa565b91602083019181825183016020810191825193600084525b8282106116b1575050505251600390066001811461169e57600214611693575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091956004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301959190611670565b505061036a6114ea565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000080821015611842575b506d04ee2d6d415b85acef810000000080831015611833575b50662386f26fc1000080831015611824575b506305f5e10080831015611815575b5061271080831015611806575b5060648210156117f6575b600a809210156117ec575b6001908160216117a48287016115fa565b95860101905b6117b6575b5050505090565b600019019083906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a8353049182156117e7579190826117aa565b6117af565b9160010191611793565b9190606460029104910191611788565b6004919392049101913861177d565b60089193920491019138611770565b60109193920491019138611761565b6020919392049101913861174f565b604093508104915038611736565b6040519060c082018281106001600160401b03821117610caa576040528160a06000918281528260208201528260408201528260608201528260808201520152565b6040519061189f82610cca565b6011825270534f5645524549474e5f424954535f563160781b6020830152565b6020929181526118d782518093858085019101610311565b010190565b6118e4611850565b506119046119126118f3611892565b6040519283916020830195866118bf565b03601f198101835282610ce5565b51902061036a60ff6014611924611850565b848152936127108106611d4c811015611982575060006020860152600881901c60071660408601525b60ff6028601083901c06841616606086015260ff600a601883901c06841616608086015260281c061660a083019060ff169052565b6124548110156119ab57506001602086015260ff6003600883901c06841616604086015261194d565b6126de11156119cd5760026020860152600881901c600116604086015261194d565b60036020860152600881901c600116604086015261194d565b600019811461094d5760010190565b634e487b7160e01b600052603260045260246000fd5b906008811015611a1c5760051b0190565b6119f5565b60c0039060c0821161094d57565b603e0390603e821161094d57565b9190820391821161094d57565b60405190611a5782610cca565b60078252660233030303030360cc1b6020830152565b90610d33929493604f92611b146040519788948351611a948160209687808b019101610311565b8601683c7265637420783d2760b81b85820152611aba8251809387602985019101610311565b01642720793d2760d81b6029820152611adc8251809386602e85019101610311565b01917f272077696474683d273127206865696768743d2731272066696c6c3d27000000602e8401528351938491604b85019101610311565b01631390179f60e11b604b82015203602f810185520183610ce5565b6020610d33919392936040519481611b518793518092868087019101610311565b8201611b6582518093868085019101610311565b01038085520183610ce5565b6099610d33919392936040519485917f3c73766720786d6c6e733d27687474703a2f2f7777772e77332e6f72672f323060208401527f30302f737667272076696577426f783d2730203020333220333227207368617060408401527f652d72656e646572696e673d276372697370456467657327207374796c653d276060840152703130b1b5b3b937bab73216b1b7b637b91d60791b6080840152611c20815180926020609187019101610311565b820161139f60f11b6091820152611c41825180936020609385019101610311565b01651e17b9bb339f60d11b6093820152036079810185520183610ce5565b906060611c77611c728285015160ff1690565b612a44565b92611c8e611c8960a083015160ff1690565b61317f565b90602094611cbd611cb86080611caf611caa8a87015160ff1690565b613599565b94015160ff1690565b613242565b611cc56114ea565b9460005b60088110611ce157505050505061036a929350611b71565b611ceb8186611a0b565b51611cf68285611a0b565b51811580611e80575b611e7557906000915b8b60048410611d235750505050611d1e906119e6565b611cc9565b90919299611d348b610aca8761158a565b611d45611d408d6115a0565b611a21565b906001600160401b03858188851c16931c1691801580611e6d575b611e5f57611d6c6114ea565b9460005b818110611d96575050505050611d8f91611d8991611b30565b996119e6565b9190611d08565b8c611da8611da3836115b6565b611a2f565b6003858189841c16928315611e53575b50508d82611dd3575b50505050611dce906119e6565b611d70565b9185611e139492611dce969c949260018114600014611e1f575050505050611df9611a4a565b905b611e048a61170d565b611e0d8861170d565b91611a6d565b9690508c38808d611dc1565b60028103611e3257505050505190611dfb565b949391929414611e44575b5050611dfb565b909192500151908f8590611e3d565b1c811691508538611db8565b50505099611d8f91506119e6565b508215611d60565b5050611d1e906119e6565b508015611cff565b60405190611e9582610caf565b819060005b606080821015611eb05784820152602001611e9a565b5050909150565b60405190611ec482610cca565b6007825266119aa220a2229960c91b6020830152565b60405190611ee782610cca565b60078252662332453836433160c81b6020830152565b60405190611f0a82610cca565b60078252662341454436463160c81b6020830152565b60405190611f2d82610cca565b60078252660233237414536360cc1b6020830152565b60405190611f5082610cca565b60078252662331453834343960c81b6020830152565b60405190611f7382610cca565b600782526611a0a122a1219b60c91b6020830152565b60405190611f9682610cca565b600782526611a198199c992160c91b6020830152565b60405190611fb982610cca565b60078252662339323242323160c81b6020830152565b60405190611fdc82610cca565b60078252662345364230414160c81b6020830152565b60405190611fff82610cca565b60078252660234433353430360cc1b6020830152565b6040519061202282610cca565b60078252660234130343030360cc1b6020830152565b6040519061204582610cca565b60078252662345444242393960c81b6020830152565b6040519061206882610cca565b600782526608ce114d0d105160ca1b6020830152565b6040519061208b82610cca565b60078252662336433334383360c81b6020830152565b604051906120ae82610cca565b60078252662344324234444560c81b6020830152565b604051906120d182610cca565b600782526611a318a19a182360c91b6020830152565b604051906120f482610cca565b600782526611a11b9c9a982160c91b6020830152565b6040519061211782610cca565b600782526611a31ca29b9ca360c91b6020830152565b6040519061213a82610cca565b60078252660233243334535360cc1b6020830152565b6040519061215d82610cca565b60078252662331373230324160c81b6020830152565b6040519061218082610cca565b6007825266119c181c211c9b60c91b6020830152565b604051906121a382610cca565b600782526611a29a9c9c1b1b60c91b6020830152565b604051906121c682610cca565b60078252660234241344130360cc1b6020830152565b604051906121e982610cca565b60078252662346364444434360c81b6020830152565b6040519061220c82610cca565b60078252662331414243394360c81b6020830152565b6040519061222f82610cca565b60078252662331313741363560c81b6020830152565b6040519061225282610cca565b60078252662341334534443760c81b6020830152565b6040519061227582610cca565b60078252662332453430353360c81b6020830152565b6040519061229882610cca565b60078252662331423236333160c81b6020830152565b604051906122bb82610cca565b60078252662335443644374560c81b6020830152565b604051906122de82610cca565b6007825266119c9aa09aa09b60c91b6020830152565b6040519061230182610cca565b600782526608cdd18e10ce1160ca1b6020830152565b6040519061232482610cca565b600782526611a1a0a1a3221960c91b6020830152565b6040519061234782610cca565b60078252660233645324330360cc1b6020830152565b6040519061236a82610cca565b600782526608d10d1050cc1160ca1b6020830152565b6040519061238d82610cca565b60078252662339413744304160c81b6020830152565b604051906123b082610cca565b600782526611a31ba2219b2360c91b6020830152565b604051906123d382610cca565b600782526608cd4e110d8e1160ca1b6020830152565b604051906123f682610cca565b60078252662332384234363360c81b6020830152565b6040519061241982610cca565b60078252662338324530414160c81b6020830152565b6040519061243c82610cca565b60078252662341463741433560c81b6020830152565b6040519061245f82610cca565b60078252660233838344541360cc1b6020830152565b6040519061248282610cca565b600782526611a21ba122229960c91b6020830152565b604051906124a582610cca565b600782526611a3199ca1989960c91b6020830152565b604051906124c882610cca565b60078252660234436383931360cc1b6020830152565b604051906124eb82610cca565b60078252660234641443741360cc1b6020830152565b6040519061250e82610cca565b60078252662345433730363360c81b6020830152565b6040519061253182610cca565b60078252662343423433333560c81b6020830152565b6040519061255482610cca565b60078252662346324437443560c81b6020830152565b6040519061257782610cca565b60078252662335343939433760c81b6020830152565b6040519061259a82610cca565b60078252662332343731413360c81b6020830152565b604051906125bd82610cca565b60078252662344344536463160c81b6020830152565b604051906125e082610cca565b60078252660233438433942360cc1b6020830152565b6040519061260382610cca565b60078252662331374135383960c81b6020830152565b6040519061262682610cca565b600782526608d04d4d8e509160ca1b6020830152565b6040519061264982610cca565b600782526611a3231818232360c91b6020830152565b6040519061266c82610cca565b60078252662339393030393960c81b6020830152565b6040519061268f82610cca565b600782526611a3231b1b232360c91b6020830152565b604051906126b282610cca565b60078252661198182323232360c91b6020830152565b604051906126d582610cca565b60078252661198181c211c2160c91b6020830152565b604051906126f882610cca565b600782526611a2982323232360c91b6020830152565b6040519061271b82610cca565b600782526611999921a2199960c91b6020830152565b6040519061273e82610cca565b60078252660233030363430360cc1b6020830152565b6040519061276182610cca565b600782526604672708c8472760cb1b6020830152565b6040519061278482610cca565b60078252660234646343530360cc1b6020830152565b604051906127a782610cca565b60078252660233842303030360cc1b6020830152565b604051906127ca82610cca565b60078252662346464130374160c81b6020830152565b604051906127ed82610cca565b600782526611a318231c232360c91b6020830152565b6040519061281082610cca565b60078252662342304334444560c81b6020830152565b6040519061283382610cca565b600782526611a3232323232360c91b6020830152565b6040519061285682610cca565b60078252662338423435313360c81b6020830152565b6040519061287982610cca565b60078252662335443430333760c81b6020830152565b6040519061289c82610cca565b60078252662344323639314560c81b6020830152565b604051906128bf82610cca565b60078252662332313231323160c81b6020830152565b604051906128e282610cca565b6007825266119a191a191a1960c91b6020830152565b6040519061290582610cca565b60078252660234646443730360cc1b6020830152565b6040519061292882610cca565b60078252660234441413532360cc1b6020830152565b6040519061294b82610cca565b600782526608d191919050d160ca1b6020830152565b6040519061296e82610cca565b60078252660233030303038360cc1b6020830152565b6040519061299182610cca565b600782526608cc0c0c0c10d160ca1b6020830152565b604051906129b482610cca565b60078252662334313639453160c81b6020830152565b604051906129d782610cca565b60078252660233830303038360cc1b6020830152565b604051906129fa82610cca565b6007825266119a2118181c1960c91b6020830152565b60405190612a1d82610cca565b6007825266119c999b98222160c91b6020830152565b90601e811015611a1c5760051b0190565b612a4c611e88565b5060ff612a57610d06565b91612a60610d26565b612a68611eb7565b8152612a72611eda565b9060209182820152612a82611efd565b90604091828201528552612a94610d26565b612a9c611f20565b8152612aa6611f43565b83820152612ab2611f66565b8282015282860152612ac2610d26565b612aca611f89565b8152612ad4611fac565b83820152612ae0611fcf565b8282015281860152612af0610d26565b612af8611ff2565b8152612b02612015565b83820152612b0e612038565b828201526060860152612b1f610d26565b612b2761205b565b8152612b3161207e565b83820152612b3d6120a1565b828201526080860152612b4e610d26565b612b566120c4565b8152612b606120e7565b83820152612b6c61210a565b8282015260a0860152612b7d610d26565b612b8561212d565b8152612b8f612150565b83820152612b9b612173565b8282015260c0860152612bac610d26565b612bb4612196565b8152612bbe6121b9565b83820152612bca6121dc565b8282015260e0860152612bdb610d26565b612be36121ff565b8152612bed612222565b83820152612bf9612245565b82820152610100860152612c0b610d26565b612c13612268565b8152612c1d61228b565b83820152612c296122ae565b82820152610120860152612c3b610d26565b612c436122d1565b8152612c4d6122f4565b83820152612c59612317565b82820152610140860152612c6b610d26565b612c73612015565b8152612c7d61233a565b83820152612c89612196565b82820152610160860152612c9b610d26565b612ca361235d565b8152612cad612380565b83820152612cb96123a3565b82820152610180860152612ccb610d26565b612cd36123c6565b8152612cdd6123e9565b83820152612ce961240c565b828201526101a0860152612cfb610d26565b612d0361242f565b8152612d0d612452565b83820152612d19612475565b828201526101c0860152612d2b610d26565b612d33612498565b8152612d3d6124bb565b83820152612d496124de565b828201526101e0860152612d5b610d26565b612d63612501565b8152612d6d612524565b83820152612d79612547565b82820152610200860152612d8b610d26565b612d9361256a565b8152612d9d61258d565b83820152612da96125b0565b82820152610220860152612dbb610d26565b612dc36125d3565b8152612dcd6125f6565b83820152612dd9612245565b82820152610240860152612deb610d26565b612df3612619565b8152612dfd612452565b83820152612e096120a1565b82820152610260860152612e1b610d26565b612e2361263c565b8152612e2d61265f565b83820152612e39612682565b82820152610280860152612e4b610d26565b612e536126a5565b8152612e5d6126c8565b83820152612e696126eb565b828201526102a0860152612e7b610d26565b612e8361270e565b8152612e8d612731565b83820152612e99612754565b828201526102c0860152612eab610d26565b612eb3612777565b8152612ebd61279a565b83820152612ec96127bd565b828201526102e0860152612edb610d26565b612ee36127e0565b8152612eed612803565b83820152612ef9612826565b82820152610300860152612f0b610d26565b612f13612849565b8152612f1d61286c565b83820152612f2961288f565b82820152610320860152612f3b610d26565b612f436128b2565b8152612f4d611a4a565b83820152612f596128d5565b82820152610340860152612f6b610d26565b612f736128f8565b8152612f7d61291b565b83820152612f8961293e565b82820152610360860152612f9b610d26565b612fa3612961565b8152612fad612984565b83820152612fb96129a7565b82820152610380860152612fcb610d26565b91612fd46129ca565b8352612fde6129ed565b90830152612fea612a10565b908201526103a084015216601e81101561300b5761300791612a33565b5190565b505190565b6040519061301d82610cca565b600782526608d18c918cd18d60ca1b6020830152565b6040519061304082610cca565b60078252662345414641463160c81b6020830152565b6040519061306382610cca565b60078252662346454639453760c81b6020830152565b6040519061308682610cca565b60078252660468c6a8a8a8c760cb1b6020830152565b604051906130a982610cca565b600782526611a2a1231aa32160c91b6020830152565b604051906130cc82610cca565b60078252662346444544454360c81b6020830152565b604051906130ef82610cca565b600782526611a29c2220a2a360c91b6020830152565b6040519061311282610cca565b60078252662344354635453360c81b6020830152565b6040519061313582610cca565b600782526611a321a319a1a360c91b6020830152565b6040519061315882610cca565b6007825266046886c8a828c760cb1b6020830152565b90600a811015611a1c5760051b0190565b60ff613189610d35565b91613192613010565b835261319c613033565b60208401526131a9613056565b60408401526131b6613079565b60608401526131c361309c565b60808401526131d06130bf565b60a08401526131dd6130e2565b60c08401526131ea613105565b60e08401526131f7613128565b61010084015261320561314b565b61012084015216600a81101561300b576130079161316e565b604051906101008083018381106001600160401b03821117610caa57604052368337565b60ff9061324d61321e565b50168015613590576001811461354b57600281146134ca5760038114613471576004811461342c57600581146133ee57600681146133b057600781146133505760088114613312576009146132d5576132a4610d55565b60008082528060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b6132dd610d55565b6330000000815260008060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b5061331b610d55565b6000808252600f605e1b60208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b50613359610d55565b7f100000000000000000000000000000010000000000000000000000000000000180825260018060fc1b0180602084015280604084015280606084015280608084015260a083015260c0820152600060e082015290565b506133b9610d55565b6000808252600160611b60208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b506133f7610d55565b6000808252603f60501b60208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b50613435610d55565b6a1500000000000003f00000815260008060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b5061347a610d55565b60008082528060208301528060408301527e0c000000000000003f000000000000003f000000000000000c00000000000060608301528060808301528060a08301528060c083015260e082015290565b506134d3610d55565b600081526000602082015270030000000000000000000000000000000360408201527803000000000000000300000000000000030000000000000003606082015278030000000000000003000000000000000c000000000000000c6080820152600060a0820152600060c0820152600060e082015290565b50613554610d55565b6a3f00000000000003f00000815260008060208301528060408301528060608301528060808301528060a08301528060c083015260e082015290565b506132a4610d55565b60ff906135a461321e565b501660028114613830576001811461374d5760031461368a576135c5610d55565b60008082526c5555000000000002affa80000060208301527d02aefa800000000002fffa800000000002efaa800000000001555500000060408301527d02d7d7800000000002affa800000000015555554000000001f2c3ce4000060608301527d15bfee540000000019afaa64000000001d2aa8640000000015475154000060808301527d15a69a540000000006f6af900000000001a55a400000000001541540000060a08301526b05955565000000000555555560921b60c083015260e082015290565b613692610d55565b60008082527c800080000000000320023000000000000aa80000000000000aa800000060208301527c0ffc0000000000000ddc0000000000000ffc0000000000030ffc30000060408301527cbaab8000000000002aaa0000000000003aab0000000000003aab00000060608301527c3aab0000000000003aab0000000000000f280000000000000f280000006080830152710f280000000000004f28400000000000151560581b60a083015260c0820181905260e082015290565b50613756610d55565b643ffc00000081527c1ff4000000000002aaaa800000000002bffe800000000002b7de80000060208201527d02bffe800000000002bffe800000000002aaaa80000000000febebf0000060408201527d0febebf0000000000febebf0000000003c2be83c000000003eabeabc000060608201527d3eabeabc000000003eabeabc0000000002abea800000000002abea80000060808201527d2aabeaa8000000002aabeaa8000000002aabeaa8000000002aabeaa8000060a08201526b05557d550000000005557d5560931b60c0820152600060e082015290565b50613839610d55565b6c1104000000000000333c00000081527c7ffd0000000000007ffd0000000000003ffc15000000000037dc08000060208201527c2aa81500000000002aa80c00000000002aa80c0000000006affa9c000060408201527d26affa9c0000000026affa9c0000000026affa9c0000000026affa9c000060608201527d26affa9c0000000026affa9c0000000006affa9c0000000006affa9c000060808201527d06affa9c0000000006affa9c0000000006affa900000000006affa90000060a08201526a6affa9000000000055555560941b60c0820152600060e082015290565b6040519061392682610cca565b600582526410dbdd5c9d60da1b6020830152565b60ff166003811461399e576002811461397d5760011461395c5761036a613919565b60405161396881610cca565b600581526428bab2b2b760d91b602082015290565b5060405161398a81610cca565b60048152634b696e6760e01b602082015290565b506040516139ab81610cca565b60058152642537b5b2b960d91b602082015290565b3d156139eb573d906139d182610d75565b916139df6040519384610ce5565b82523d6000602084013e565b606090565b6002600a5414613a01576002600a55565b604051633ee5aeb560e01b8152600490fd5b613a1c81613b6c565b1561079c57600052600e60205260ff60406000205416613a3e57600090600090565b600d60205260ff6040600020541690600190565b60ff60135416613a88576001600160a01b03166000908152600560205260409081902054901c6001600160401b0316600c541190565b50600090565b6001600160401b038111610caa5760051b60200190565b90613aaf82613a8e565b613abc6040519182610ce5565b8281528092611622601f1991613a8e565b8051821015611a1c5760209160051b010190565b613af5816000526004602052604060002090565b54908115613b0c5750600160e01b81166141e95790565b90506000908154811015613b5d575b60001901600081815260046020526040902054908115613b565750600160e01b811615613b5157636f96cda160e11b8252600482fd5b905090565b9050613b1b565b636f96cda160e11b8252600482fd5b90600091600080548210613b7e575050565b92505b8083526004602052604083205480613ba35750801561094d5760001901613b81565b600160e01b1615925050565b9190613bba82613ae1565b6001600160a01b0393841693818116859003613d3a5760008481526006602052604090208054613bf96001600160a01b03881633908114908314171590565b613cec575b613ce2575b506001600160a01b038581166000908152600560209081526040808320805460001901905592861682528282208054600101905586825260049052209083169190600160e11b904260a01b841782179055811615613c98575b508281857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a415613c9357610d3392613d3f565b61421b565b60018401613cb0816000526004602052604060002090565b5415613cbd575b50613c5c565b6000548114613cb757613cda906000526004602052604060002090565b553880613cb7565b6000905538613c03565b613d30610fca613d2933613d128b60018060a01b03166000526007602052604060002090565b9060018060a01b0316600052602052604060002090565b5460ff1690565b15613bfe5761420a565b6141fa565b6001600160a01b039190821615613d5557505050565b90919260005b600180821015613ebc5790613d9b91613d7482886115ed565b90613d8f610fca613d2984600052600e602052604060002090565b613da0575b50506119e6565b613d5b565b613e657fabe2dd785dc96ee74bd71829da26ef21eb2a306561a15a8bb8570a3f9f8883b591613ddb6020613dd3866118dc565b015160ff1690565b9060ff821660038103613e6f575050613dfd613df86012546119e6565b601255565b613e2481613e1586600052600d602052604060002090565b9060ff1660ff19825416179055565b613e48613e3b85600052600e602052604060002090565b805460ff19166001179055565b6040805194855260ff909116602085015287891693918291820190565b0390a23880613d94565b60028103613e91575050613e8c613e876011546119e6565b601155565b613dfd565b03613ea957613e8c613ea46010546119e6565b601055565b613e8c613eb7600f546119e6565b600f55565b505092505050565b9060005b838110613ed55750505050565b80613ee3613f0892846115ed565b613efd610fca613d2983600052600e602052604060002090565b613f0d575b506119e6565b613ec8565b7fabe2dd785dc96ee74bd71829da26ef21eb2a306561a15a8bb8570a3f9f8883b5613fad613f3f6020613dd3856118dc565b60ff811660038103613fb65750613f5a613df86012546119e6565b613f7281613e1586600052600d602052604060002090565b613f89613e3b85600052600e602052604060002090565b6040805194855260ff90911660208501526001600160a01b03881693918291820190565b0390a238613f02565b60028103613fd25750613fcd613e876011546119e6565b613f5a565b600103613fe757613fcd613ea46010546119e6565b613fcd613eb7600f546119e6565b929190614003828286613baf565b803b614010575b50505050565b6140199361404d565b15614027573880808061400a565b6368d2bf6b60e11b60005260046000fd5b9081602091031261029e575161036a8161028c565b604051630a85bd0160e11b8082523360048301526001600160a01b0392831660248301526044820194909452608060648201529293602092849290918391600091839061409e906084830190610334565b0393165af1600091816140db575b506140cd576140b96139c0565b8051156140c857805190602001fd5b614027565b6001600160e01b0319161490565b6140fd91925060203d8111614104575b6140f58183610ce5565b810190614038565b90386140ac565b503d6140eb565b919060009283549082156141da5760008281526004602052604090206001956001600160a01b038316914260a01b86891460e11b17831790556001600160a01b0383166000908152600560205260409020680100000000000000018602815401905581156141d55784840191849780805b614190575b505050610d3395965055613ec4565b156141c4575b82818a84867fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a461417c565b809801978389036141965780614181565b61422c565b63b562e8dd60e01b8552600485fd5b636f96cda160e11b60005260046000fd5b62a1148160e81b60005260046000fd5b632ce44b5f60e11b60005260046000fd5b633a954ecd60e21b60005260046000fd5b622e076360e81b60005260046000fdfea2646970667358221220c912be208f0f0a5a8d69cebea6aad356daf3d1f4fbe218da9289734b2b442b0064736f6c63430008140033
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.