¡El código fuente de este contrato está verificado!
Metadatos del Contrato
Compilador
0.8.17+commit.8df45f5f
Idioma
Solidity
Código Fuente del Contrato
Archivo 1 de 20: Address.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)pragmasolidity ^0.8.1;/**
* @dev Collection of functions related to the address type
*/libraryAddress{
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/functionisContract(address account) internalviewreturns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0// for contracts in construction, since the code is only stored at the end// of the constructor execution.return account.code.length>0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/functionsendValue(addresspayable recipient, uint256 amount) internal{
require(address(this).balance>= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/functionfunctionCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value
) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemory errorMessage
) internalreturns (bytesmemory) {
require(address(this).balance>= value, "Address: insufficient balance for call");
(bool success, bytesmemory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target, bytesmemory data) internalviewreturns (bytesmemory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/functionverifyCallResultFromTarget(address target,
bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
if (success) {
if (returndata.length==0) {
// only check isContract if the call was successful and the return data is empty// otherwise we already know that it was a contractrequire(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/functionverifyCallResult(bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalpurereturns (bytesmemory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function_revert(bytesmemory returndata, stringmemory errorMessage) privatepure{
// Look for revert reason and bubble it up if presentif (returndata.length>0) {
// The easiest way to bubble the revert reason is using memory via assembly/// @solidity memory-safe-assemblyassembly {
let returndata_size :=mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Código Fuente del Contrato
Archivo 2 de 20: BitMaps.sol
// SPDX-License-Identifier: MIT/**
_____ ___ ___ __ ____ _ __
/ ___/____ / (_)___/ (_) /___ __ / __ )(_) /______
\__ \/ __ \/ / / __ / / __/ / / / / __ / / __/ ___/
___/ / /_/ / / / /_/ / / /_/ /_/ / / /_/ / / /_(__ )
/____/\____/_/_/\__,_/_/\__/\__, / /_____/_/\__/____/
/____/
- npm: https://www.npmjs.com/package/solidity-bits
- github: https://github.com/estarriolvetch/solidity-bits
*/pragmasolidity ^0.8.0;import"./BitScan.sol";
import"./Popcount.sol";
/**
* @dev This Library is a modified version of Openzeppelin's BitMaps library with extra features.
*
* 1. Functions of finding the index of the closest set bit from a given index are added.
* The indexing of each bucket is modifed to count from the MSB to the LSB instead of from the LSB to the MSB.
* The modification of indexing makes finding the closest previous set bit more efficient in gas usage.
* 2. Setting and unsetting the bitmap consecutively.
* 3. Accounting number of set bits within a given range.
*
*//**
* @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential.
* Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].
*/libraryBitMaps{
usingBitScanforuint256;
uint256privateconstant MASK_INDEX_ZERO = (1<<255);
uint256privateconstant MASK_FULL =type(uint256).max;
structBitMap {
mapping(uint256=>uint256) _data;
}
/**
* @dev Returns whether the bit at `index` is set.
*/functionget(BitMap storage bitmap, uint256 index) internalviewreturns (bool) {
uint256 bucket = index >>8;
uint256 mask = MASK_INDEX_ZERO >> (index &0xff);
return bitmap._data[bucket] & mask !=0;
}
/**
* @dev Sets the bit at `index` to the boolean `value`.
*/functionsetTo(
BitMap storage bitmap,
uint256 index,
bool value
) internal{
if (value) {
set(bitmap, index);
} else {
unset(bitmap, index);
}
}
/**
* @dev Sets the bit at `index`.
*/functionset(BitMap storage bitmap, uint256 index) internal{
uint256 bucket = index >>8;
uint256 mask = MASK_INDEX_ZERO >> (index &0xff);
bitmap._data[bucket] |= mask;
}
/**
* @dev Unsets the bit at `index`.
*/functionunset(BitMap storage bitmap, uint256 index) internal{
uint256 bucket = index >>8;
uint256 mask = MASK_INDEX_ZERO >> (index &0xff);
bitmap._data[bucket] &=~mask;
}
/**
* @dev Consecutively sets `amount` of bits starting from the bit at `startIndex`.
*/functionsetBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal{
uint256 bucket = startIndex >>8;
uint256 bucketStartIndex = (startIndex &0xff);
unchecked {
if(bucketStartIndex + amount <256) {
bitmap._data[bucket] |= MASK_FULL << (256- amount) >> bucketStartIndex;
} else {
bitmap._data[bucket] |= MASK_FULL >> bucketStartIndex;
amount -= (256- bucketStartIndex);
bucket++;
while(amount >256) {
bitmap._data[bucket] = MASK_FULL;
amount -=256;
bucket++;
}
bitmap._data[bucket] |= MASK_FULL << (256- amount);
}
}
}
/**
* @dev Consecutively unsets `amount` of bits starting from the bit at `startIndex`.
*/functionunsetBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal{
uint256 bucket = startIndex >>8;
uint256 bucketStartIndex = (startIndex &0xff);
unchecked {
if(bucketStartIndex + amount <256) {
bitmap._data[bucket] &=~(MASK_FULL << (256- amount) >> bucketStartIndex);
} else {
bitmap._data[bucket] &=~(MASK_FULL >> bucketStartIndex);
amount -= (256- bucketStartIndex);
bucket++;
while(amount >256) {
bitmap._data[bucket] =0;
amount -=256;
bucket++;
}
bitmap._data[bucket] &=~(MASK_FULL << (256- amount));
}
}
}
/**
* @dev Returns number of set bits within a range.
*/functionpopcountA(BitMap storage bitmap, uint256 startIndex, uint256 amount) internalviewreturns(uint256 count) {
uint256 bucket = startIndex >>8;
uint256 bucketStartIndex = (startIndex &0xff);
unchecked {
if(bucketStartIndex + amount <256) {
count += Popcount.popcount256A(
bitmap._data[bucket] & (MASK_FULL << (256- amount) >> bucketStartIndex)
);
} else {
count += Popcount.popcount256A(
bitmap._data[bucket] & (MASK_FULL >> bucketStartIndex)
);
amount -= (256- bucketStartIndex);
bucket++;
while(amount >256) {
count += Popcount.popcount256A(bitmap._data[bucket]);
amount -=256;
bucket++;
}
count += Popcount.popcount256A(
bitmap._data[bucket] & (MASK_FULL << (256- amount))
);
}
}
}
/**
* @dev Returns number of set bits within a range.
*/functionpopcountB(BitMap storage bitmap, uint256 startIndex, uint256 amount) internalviewreturns(uint256 count) {
uint256 bucket = startIndex >>8;
uint256 bucketStartIndex = (startIndex &0xff);
unchecked {
if(bucketStartIndex + amount <256) {
count += Popcount.popcount256B(
bitmap._data[bucket] & (MASK_FULL << (256- amount) >> bucketStartIndex)
);
} else {
count += Popcount.popcount256B(
bitmap._data[bucket] & (MASK_FULL >> bucketStartIndex)
);
amount -= (256- bucketStartIndex);
bucket++;
while(amount >256) {
count += Popcount.popcount256B(bitmap._data[bucket]);
amount -=256;
bucket++;
}
count += Popcount.popcount256B(
bitmap._data[bucket] & (MASK_FULL << (256- amount))
);
}
}
}
/**
* @dev Find the closest index of the set bit before `index`.
*/functionscanForward(BitMap storage bitmap, uint256 index) internalviewreturns (uint256 setBitIndex) {
uint256 bucket = index >>8;
// index within the bucketuint256 bucketIndex = (index &0xff);
// load a bitboard from the bitmap.uint256 bb = bitmap._data[bucket];
// offset the bitboard to scan from `bucketIndex`.
bb = bb >> (0xff^ bucketIndex); // bb >> (255 - bucketIndex)if(bb >0) {
unchecked {
setBitIndex = (bucket <<8) | (bucketIndex - bb.bitScanForward256());
}
} else {
while(true) {
require(bucket >0, "BitMaps: The set bit before the index doesn't exist.");
unchecked {
bucket--;
}
// No offset. Always scan from the least significiant bit now.
bb = bitmap._data[bucket];
if(bb >0) {
unchecked {
setBitIndex = (bucket <<8) | (255- bb.bitScanForward256());
break;
}
}
}
}
}
functiongetBucket(BitMap storage bitmap, uint256 bucket) internalviewreturns (uint256) {
return bitmap._data[bucket];
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)pragmasolidity ^0.8.0;/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
}
Código Fuente del Contrato
Archivo 5 de 20: DEDPRZ.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.17;import"erc1155delta/contracts/extensions/ERC1155DeltaQueryable.sol";
import"operator-filter-registry/src/DefaultOperatorFilterer.sol";
import {ERC2981} from"@openzeppelin/contracts/token/common/ERC2981.sol";
/**
/$$$$$$$ /$$$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$$$
| $$__ $$| $$_____/| $$__ $$| $$__ $$| $$__ $$|_____ $$
| $$ \ $$| $$ | $$ \ $$| $$ \ $$| $$ \ $$ /$$/
| $$ | $$| $$$$$ | $$ | $$| $$$$$$$/| $$$$$$$/ /$$/
| $$ | $$| $$__/ | $$ | $$| $$____/ | $$__ $$ /$$/
| $$ | $$| $$ | $$ | $$| $$ | $$ \ $$ /$$/
| $$$$$$$/| $$$$$$$$| $$$$$$$/| $$ | $$ | $$ /$$$$$$$$
|_______/ |________/|_______/ |__/ |__/ |__/|________/
www.dedprz.io
*//**
* @title DEDPRZ Contract
* @dev Extends ERC1155Delta Non-Fungible Token Standard
* @author @devgod_eth
*/contractDEDPRZisERC1155DeltaQueryable, ERC2981, DefaultOperatorFilterer{
addresspublic admin; // contract adminuint256publicconstant NUM_MAX =10000; // max supplyuint256public mintPrice; // mint priceuint16internalconstant _MAX_MINTS_PER_ADDRESS =10; // max per walletboolpublic mintable; // mintable stateuint256internal adminMint =0; // admin mintedeventMinted(addressindexed to, uint256indexed amount); // minted eventconstructor()
ERC1155Delta("https://dedprz.s3.amazonaws.com/{id}")
{
admin =msg.sender;
mintable =false;
mintPrice =0.099ether;
_setDefaultRoyalty(admin, 690);
}
/// @dev Receive etherreceive() externalpayable{}
/// @dev Modifier for admin only functionsmodifieronlyAdmin() {
require(msg.sender== admin, "OnlyAdmin");
_;
}
/// @dev Override to use filter operatorfunctionsetApprovalForAll(address operator, bool approved) publicoverrideonlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
/// @dev Override transfer to use filter operatorfunctionsafeTransferFrom(addressfrom, address to, uint256 tokenId, uint256 amount, bytesmemory data)
publicoverrideonlyAllowedOperator(from)
{
super.safeTransferFrom(from, to, tokenId, amount, data);
}
/// @dev Override batch transfer to use filter operatorfunctionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) publicvirtualoverrideonlyAllowedOperator(from) {
super.safeBatchTransferFrom(from, to, ids, amounts, data);
}
/// @dev Override ERC1155Delta to also support ERC2981 royalty standardfunctionsupportsInterface(bytes4 interfaceId)
publicviewvirtualoverride (ERC1155Delta, ERC2981)
returns (bool)
{
// dm nickp on twitter and tell him devs are based afreturn ERC1155Delta.supportsInterface(interfaceId) || ERC2981.supportsInterface(interfaceId);
}
/// @notice Mint tokens to address/// @param to Address to mint to/// @param amount Amount to mintfunctionmint(address to, uint256 amount) externalpayable{
require(mintable, "Not mintable");
require(_totalMinted() + amount <= NUM_MAX, "Minted out");
require(msg.value>= mintPrice * amount, "Insufficient funds");
require(balanceOf(to) + amount <= _MAX_MINTS_PER_ADDRESS, "Limit 10");
_mint(to, amount);
emit Minted(to, amount);
}
/// @notice Mint tokens to address for multisig only/// @param to Address to mint to/// @param amount Amount to mintfunctionmintAdmin(address to, uint256 amount) externalonlyAdmin{
// max 20 for adminrequire(adminMint + amount <=20, "Limit 20");
// mint
_mint(to, amount);
// update multisig minted
adminMint += amount;
emit Minted(to, amount);
}
/// @notice Burn token/// @param tokenId Token ID to burnfunctionburn(uint256 tokenId) external{
_burn(msg.sender, tokenId);
}
/// @notice Burn tokens/// @param tokenIds Token IDs to burnfunctionburnBatch(uint256[] memory tokenIds) external{
_burnBatch(msg.sender, tokenIds);
}
/// @notice Claim admin fundsfunctionadminClaim() external{
payable(admin).transfer(address(this).balance);
}
/// @notice Get total mintedfunctiontotalMinted() publicviewreturns (uint256) {
return _totalMinted();
}
/// @notice Set admin addressfunctionsetAdmin(address newAdmin) externalonlyAdmin{
admin = newAdmin;
}
/// @notice Set minting statefunctionsetMintable(bool _mintable) externalonlyAdmin{
mintable = _mintable;
}
/// @notice Set URI of tokens for later reveal to protect randomnessfunctionsetURI(stringmemory newuri) externalvirtualonlyAdmin{
_setURI(newuri);
}
/// @notice Set royalty for marketplaces complying with ERC2981 standardfunctionsetDefaultRoyalty(address receiver, uint96 feeNumerator) publiconlyAdmin{
_setDefaultRoyalty(receiver, feeNumerator);
}
}
Código Fuente del Contrato
Archivo 6 de 20: DefaultOperatorFilterer.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.13;import {OperatorFilterer} from"./OperatorFilterer.sol";
/**
* @title DefaultOperatorFilterer
* @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.
*/abstractcontractDefaultOperatorFiltererisOperatorFilterer{
addressconstant DEFAULT_SUBSCRIPTION =address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
}
Código Fuente del Contrato
Archivo 7 de 20: ERC1155Delta.sol
// SPDX-License-Identifier: MIT// Creator: Ctor Lab (https://ctor.xyz)pragmasolidity ^0.8.0;import"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import"@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import"@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol";
import"@openzeppelin/contracts/utils/Address.sol";
import"@openzeppelin/contracts/utils/Context.sol";
import"@openzeppelin/contracts/utils/introspection/ERC165.sol";
import"solidity-bits/contracts/BitMaps.sol";
import"./IERC1155Delta.sol";
contractERC1155DeltaisContext, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Delta{
usingAddressforaddress;
usingBitMapsforBitMaps.BitMap;
// Mapping from accout to owned tokensmapping(address=> BitMaps.BitMap) internal _owned;
// Mapping from account to operator approvalsmapping(address=>mapping(address=>bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.jsonstringprivate _uri;
// The next token ID to be minted.uint256private _currentIndex;
/**
* @dev See {_setURI}.
*/constructor(stringmemory uri_) {
_setURI(uri_);
_currentIndex = _startTokenId();
}
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/function_startTokenId() internalpurevirtualreturns (uint256) {
return0;
}
/**
* @dev Returns the next token ID to be minted.
*/function_nextTokenId() internalviewreturns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/function_totalMinted() internalviewreturns (uint256) {
return _nextTokenId() - _startTokenId();
}
/**
* @dev Returns true if the account owns the `id` token.
*/functionisOwnerOf(address account, uint256 id) publicviewvirtualoverridereturns(bool) {
return _owned[account].get(id);
}
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(ERC165, IERC165) returns (bool) {
return
interfaceId ==type(IERC1155).interfaceId||
interfaceId ==type(IERC1155MetadataURI).interfaceId||
interfaceId ==type(IERC1155Delta).interfaceId||super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/functionuri(uint256) publicviewvirtualoverridereturns (stringmemory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/functionbalanceOf(address account, uint256 id) publicviewvirtualoverridereturns (uint256) {
if(account ==address(0)) {
revert BalanceQueryForZeroAddress();
}
if(_owned[account].get(id)) {
return1;
} else {
return0;
}
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/functionbalanceOfBatch(address[] memory accounts, uint256[] memory ids)
publicviewvirtualoverridereturns (uint256[] memory)
{
if(accounts.length!= ids.length) {
revert InputLengthMistmatch();
}
uint256[] memory batchBalances =newuint256[](accounts.length);
for (uint256 i =0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/functionsetApprovalForAll(address operator, bool approved) publicvirtualoverride{
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/functionisApprovedForAll(address account, address operator) publicviewvirtualoverridereturns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/functionsafeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) publicvirtualoverride{
if(from== _msgSender() || isApprovedForAll(from, _msgSender())){
_safeTransferFrom(from, to, id, amount, data);
} else {
revert TransferCallerNotOwnerNorApproved();
}
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/functionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) publicvirtualoverride{
if(!(from== _msgSender() || isApprovedForAll(from, _msgSender()))) {
revert TransferCallerNotOwnerNorApproved();
}
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `amount` cannot be zero.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/function_safeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) internalvirtual{
if(to ==address(0)) {
revert TransferToZeroAddress();
}
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
_beforeTokenTransfer(operator, from, to, ids, data);
if(amount ==1&& _owned[from].get(id)) {
_owned[from].unset(id);
_owned[to].set(id);
} else {
revert TransferFromIncorrectOwnerOrInvalidAmount();
}
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/function_safeBatchTransferFrom(addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) internalvirtual{
if(ids.length!= amounts.length) {
revert InputLengthMistmatch();
}
if(to ==address(0)) {
revert TransferToZeroAddress();
}
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, data);
for (uint256 i =0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
if(amount ==1&& _owned[from].get(id)) {
_owned[from].unset(id);
_owned[to].set(id);
} else {
revert TransferFromIncorrectOwnerOrInvalidAmount();
}
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/function_setURI(stringmemory newuri) internalvirtual{
_uri = newuri;
}
function_mint(address to,
uint256 amount
) internalvirtual{
_mint(to, amount, "");
}
/**
* @dev Creates `amount` tokens, and assigns them to `to`.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `amount` cannot be zero.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/function_mint(address to,
uint256 amount,
bytesmemory data
) internalvirtual{
if(to ==address(0)) {
revert MintToZeroAddress();
}
if(amount ==0) {
revert MintZeroQuantity();
}
address operator = _msgSender();
uint256[] memory ids =newuint256[](amount);
uint256[] memory amounts =newuint256[](amount);
uint256 startTokenId = _nextTokenId();
unchecked {
require(type(uint256).max- amount >= startTokenId);
for(uint256 i =0; i < amount; i++) {
ids[i] = startTokenId + i;
amounts[i] =1;
}
}
_beforeTokenTransfer(operator, address(0), to, ids, data);
_owned[to].setBatch(startTokenId, amount);
_currentIndex += amount;
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, data);
uint256 end = _currentIndex;
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
if (_currentIndex != end) revert();
}
/**
* @dev Destroys token of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have the token of token type `id`.
*/function_burn(addressfrom,
uint256 id
) internalvirtual{
if(from==address(0)){
revert BurnFromZeroAddress();
}
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
_beforeTokenTransfer(operator, from, address(0), ids, "");
if(!_owned[from].get(id)) {
revert BurnFromNonOnwerAddress();
}
_owned[from].unset(id);
emit TransferSingle(operator, from, address(0), id, 1);
_afterTokenTransfer(operator, from, address(0), ids, "");
}
/**
* @dev Destroys tokens of token types in `ids` from `from`
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have the token of token types in `ids`.
*/function_burnBatch(addressfrom,
uint256[] memory ids
) internalvirtual{
if(from==address(0)){
revert BurnFromZeroAddress();
}
address operator = _msgSender();
uint256[] memory amounts =newuint256[](ids.length);
_beforeTokenTransfer(operator, from, address(0), ids, "");
unchecked {
for(uint256 i =0; i < ids.length; i++) {
amounts[i] =1;
uint256 id = ids[i];
if(!_owned[from].get(id)) {
revert BurnFromNonOnwerAddress();
}
_owned[from].unset(id);
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/function_setApprovalForAll(address owner,
address operator,
bool approved
) internalvirtual{
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/function_beforeTokenTransfer(address operator,
addressfrom,
address to,
uint256[] memory ids,
bytesmemory data
) internalvirtual{}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/function_afterTokenTransfer(address operator,
addressfrom,
address to,
uint256[] memory ids,
bytesmemory data
) internalvirtual{}
function_doSafeTransferAcceptanceCheck(address operator,
addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) private{
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert TransferToNonERC1155ReceiverImplementer();
}
} catchError(stringmemory reason) {
revert(reason);
} catch {
revert TransferToNonERC1155ReceiverImplementer();
}
}
}
function_doSafeBatchTransferAcceptanceCheck(address operator,
addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) private{
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert TransferToNonERC1155ReceiverImplementer();
}
} catchError(stringmemory reason) {
revert(reason);
} catch {
revert TransferToNonERC1155ReceiverImplementer();
}
}
}
function_asSingletonArray(uint256 element) privatepurereturns (uint256[] memory array) {
array =newuint256[](1);
array[0] = element;
}
}
Código Fuente del Contrato
Archivo 8 de 20: ERC1155DeltaQueryable.sol
// SPDX-License-Identifier: MIT// Creator: Ctor Lab (https://ctor.xyz)pragmasolidity ^0.8.0;import"solidity-bits/contracts/BitMaps.sol";
import"../ERC1155Delta.sol";
import"./IERC1155DeltaQueryable.sol";
abstractcontractERC1155DeltaQueryableisIERC1155DeltaQueryable, ERC1155Delta{
usingBitMapsforBitMaps.BitMap;
/**
* @dev Returns the number of tokens owned by `owner`.
*/functionbalanceOf(address owner) publicviewvirtualoverridereturns (uint256) {
return balanceOf(owner, _startTokenId(), _nextTokenId());
}
/**
* @dev Returns the number of tokens owned by `owner`,
* in the range [`start`, `stop`)
* (i.e. `start <= tokenId < stop`).
*
* Requirements:
*
* - `start < stop`
*/functionbalanceOf(address owner, uint256 start, uint256 stop) publicviewvirtualoverridereturns (uint256) {
return _owned[owner].popcountB(start, stop - start);
}
/**
* @dev Returns an array of token IDs owned by `owner`,
* in the range [`start`, `stop`)
* (i.e. `start <= tokenId < stop`).
*
* This function allows for tokens to be queried if the collection
* grows too big for a single call of {ERC1155DelataQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start < stop`
*/functiontokensOfOwnerIn(address owner,
uint256 start,
uint256 stop
) publicviewvirtualoverridereturns (uint256[] memory) {
unchecked {
if (start >= stop) revert InvalidQueryRange();
// Set `start = max(start, _startTokenId())`.if (start < _startTokenId()) {
start = _startTokenId();
}
// Set `stop = min(stop, stopLimit)`.uint256 stopLimit = _nextTokenId();
if (stop > stopLimit) {
stop = stopLimit;
}
uint256 tokenIdsLength;
if(start < stop) {
tokenIdsLength = balanceOf(owner, start, stop);
} else {
tokenIdsLength =0;
}
uint256[] memory tokenIds =newuint256[](tokenIdsLength);
BitMaps.BitMap storage bmap = _owned[owner];
for ((uint256 i, uint256 tokenIdsIdx) = (start, 0); tokenIdsIdx != tokenIdsLength; ++i) {
if(bmap.get(i) ) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
}
/**
* @dev Returns an array of token IDs owned by `owner`.
*
* This function scans the ownership mapping and is O(`totalSupply`) in complexity.
* It is meant to be called off-chain.
*
* See {ERC1155DeltaQueryable-tokensOfOwnerIn} for splitting the scan into
* multiple smaller scans if the collection is large enough to cause
* an out-of-gas error (10K collections should be fine).
*/functiontokensOfOwner(address owner) publicviewvirtualoverridereturns (uint256[] memory) {
if(_totalMinted() ==0) {
returnnewuint256[](0);
}
return tokensOfOwnerIn(owner, _startTokenId(), _nextTokenId());
}
}
Código Fuente del Contrato
Archivo 9 de 20: ERC165.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)pragmasolidity ^0.8.0;import"./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/abstractcontractERC165isIERC165{
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverridereturns (bool) {
return interfaceId ==type(IERC165).interfaceId;
}
}
Código Fuente del Contrato
Archivo 10 de 20: ERC2981.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)pragmasolidity ^0.8.0;import"../../interfaces/IERC2981.sol";
import"../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/abstractcontractERC2981isIERC2981, ERC165{
structRoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256=> RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(IERC165, ERC165) returns (bool) {
return interfaceId ==type(IERC2981).interfaceId||super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/functionroyaltyInfo(uint256 _tokenId, uint256 _salePrice) publicviewvirtualoverridereturns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver ==address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/function_feeDenominator() internalpurevirtualreturns (uint96) {
return10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/function_setDefaultRoyalty(address receiver, uint96 feeNumerator) internalvirtual{
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver !=address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/function_deleteDefaultRoyalty() internalvirtual{
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/function_setTokenRoyalty(uint256 tokenId,
address receiver,
uint96 feeNumerator
) internalvirtual{
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver !=address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/function_resetTokenRoyalty(uint256 tokenId) internalvirtual{
delete _tokenRoyaltyInfo[tokenId];
}
}
Código Fuente del Contrato
Archivo 11 de 20: IERC1155.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)pragmasolidity ^0.8.0;import"../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/interfaceIERC1155isIERC165{
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/eventTransferSingle(addressindexed operator, addressindexedfrom, addressindexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/eventTransferBatch(addressindexed operator,
addressindexedfrom,
addressindexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/eventApprovalForAll(addressindexed account, addressindexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/eventURI(string value, uint256indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/functionbalanceOf(address account, uint256 id) externalviewreturns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/functionbalanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
externalviewreturns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/functionsetApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/functionisApprovedForAll(address account, address operator) externalviewreturns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/functionsafeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytescalldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/functionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytescalldata data
) external;
}
Código Fuente del Contrato
Archivo 12 de 20: IERC1155Delta.sol
// SPDX-License-Identifier: MIT// Creator: Ctor Lab (https://ctor.xyz)pragmasolidity ^0.8.0;interfaceIERC1155Delta{
/**
* The caller must own the token or be an approved operator.
*/errorApprovalCallerNotOwnerNorApproved();
/**
* Cannot query the balance for the zero address.
*/errorBalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/errorMintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/errorMintZeroQuantity();
/**
* Cannot burn from the zero address.
*/errorBurnFromZeroAddress();
/**
* Cannot burn from the address that doesn't owne the token.
*/errorBurnFromNonOnwerAddress();
/**
* The caller must own the token or be an approved operator.
*/errorTransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from` or the `amount` is not 1.
*/errorTransferFromIncorrectOwnerOrInvalidAmount();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC1155Receiver interface.
*/errorTransferToNonERC1155ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/errorTransferToZeroAddress();
/**
* The length of input arraies is not matching.
*/errorInputLengthMistmatch();
functionisOwnerOf(address account, uint256 id) externalviewreturns(bool);
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)pragmasolidity ^0.8.0;import"../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/interfaceIERC1155MetadataURIisIERC1155{
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/functionuri(uint256 id) externalviewreturns (stringmemory);
}
Código Fuente del Contrato
Archivo 15 de 20: IERC1155Receiver.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)pragmasolidity ^0.8.0;import"../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/interfaceIERC1155ReceiverisIERC165{
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/functiononERC1155Received(address operator,
addressfrom,
uint256 id,
uint256 value,
bytescalldata data
) externalreturns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/functiononERC1155BatchReceived(address operator,
addressfrom,
uint256[] calldata ids,
uint256[] calldata values,
bytescalldata data
) externalreturns (bytes4);
}
Código Fuente del Contrato
Archivo 16 de 20: IERC165.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)pragmasolidity ^0.8.0;/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/interfaceIERC165{
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/functionsupportsInterface(bytes4 interfaceId) externalviewreturns (bool);
}
Código Fuente del Contrato
Archivo 17 de 20: IERC2981.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)pragmasolidity ^0.8.0;import"../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/interfaceIERC2981isIERC165{
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/functionroyaltyInfo(uint256 tokenId, uint256 salePrice)
externalviewreturns (address receiver, uint256 royaltyAmount);
}
// SPDX-License-Identifier: MITpragmasolidity ^0.8.13;import {IOperatorFilterRegistry} from"./IOperatorFilterRegistry.sol";
/**
* @title OperatorFilterer
* @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another
* registrant's entries in the OperatorFilterRegistry.
* @dev This smart contract is meant to be inherited by token contracts so they can use the following:
* - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.
* - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.
*/abstractcontractOperatorFilterer{
errorOperatorNotAllowed(address operator);
IOperatorFilterRegistry publicconstant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
// If an inheriting token contract is deployed to a network without the registry deployed, the modifier// will not revert, but the contract will need to be registered with the registry once it is deployed in// order for the modifier to filter addresses.if (address(OPERATOR_FILTER_REGISTRY).code.length>0) {
if (subscribe) {
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
} else {
if (subscriptionOrRegistrantToCopy !=address(0)) {
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
} else {
OPERATOR_FILTER_REGISTRY.register(address(this));
}
}
}
}
modifieronlyAllowedOperator(addressfrom) virtual{
// Allow spending tokens from addresses with balance// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred// from an EOA.if (from!=msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
modifieronlyAllowedOperatorApproval(address operator) virtual{
_checkFilterOperator(operator);
_;
}
function_checkFilterOperator(address operator) internalviewvirtual{
// Check registry code length to facilitate testing in environments without a deployed registry.if (address(OPERATOR_FILTER_REGISTRY).code.length>0) {
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
revert OperatorNotAllowed(operator);
}
}
}
}
Código Fuente del Contrato
Archivo 20 de 20: Popcount.sol
// SPDX-License-Identifier: MIT/**
_____ ___ ___ __ ____ _ __
/ ___/____ / (_)___/ (_) /___ __ / __ )(_) /______
\__ \/ __ \/ / / __ / / __/ / / / / __ / / __/ ___/
___/ / /_/ / / / /_/ / / /_/ /_/ / / /_/ / / /_(__ )
/____/\____/_/_/\__,_/_/\__/\__, / /_____/_/\__/____/
/____/
- npm: https://www.npmjs.com/package/solidity-bits
- github: https://github.com/estarriolvetch/solidity-bits
*/pragmasolidity ^0.8.0;libraryPopcount{
uint256privateconstant m1 =0x5555555555555555555555555555555555555555555555555555555555555555;
uint256privateconstant m2 =0x3333333333333333333333333333333333333333333333333333333333333333;
uint256privateconstant m4 =0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f;
uint256privateconstant h01 =0x0101010101010101010101010101010101010101010101010101010101010101;
functionpopcount256A(uint256 x) internalpurereturns (uint256 count) {
unchecked{
for (count=0; x!=0; count++)
x &= x -1;
}
}
functionpopcount256B(uint256 x) internalpurereturns (uint256) {
if (x ==type(uint256).max) {
return256;
}
unchecked {
x -= (x >>1) & m1; //put count of each 2 bits into those 2 bits
x = (x & m2) + ((x >>2) & m2); //put count of each 4 bits into those 4 bits
x = (x + (x >>4)) & m4; //put count of each 8 bits into those 8 bits
x = (x * h01) >>248; //returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ...
}
return x;
}
}