文件 1 的 21:Abstract1155Factory.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/access/AccessControl.sol";
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol';
import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol';
import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol';
abstract contract Abstract1155Factory is AccessControl, ERC1155Pausable, ERC1155Supply, ERC1155Burnable, Ownable {
string public name_;
string public symbol_;
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function setURI(string memory baseURI) external onlyOwner {
_setURI(baseURI);
}
function name() public view returns (string memory) {
return name_;
}
function symbol() public view returns (string memory) {
return symbol_;
}
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual override(ERC1155, ERC1155Supply) {
super._mint(account, id, amount, data);
}
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155, ERC1155Supply) {
super._mintBatch(to, ids, amounts, data);
}
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual override(ERC1155, ERC1155Supply) {
super._burn(account, id, amount);
}
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual override(ERC1155, ERC1155Supply) {
super._burnBatch(account, ids, amounts);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155Pausable, ERC1155) {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
function setOwner(address _addr) public onlyOwner {
transferOwnership(_addr);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
文件 2 的 21:AccessControl.sol
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
文件 3 的 21:Address.sol
pragma solidity ^0.8.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 4 的 21:Commerce.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import './Abstract1155Factory.sol';
contract Commerce is Abstract1155Factory {
using SafeMath for uint256;
using Counters for Counters.Counter;
Counters.Counter private tokenCounter;
mapping(uint256 => Token) public tokens;
event Purchased(uint[] index, address indexed account, uint[] amount);
struct Token {
string ipfsMetadataHash;
string extraDataUri;
mapping(address => uint256) claimedTokens;
mapping(uint => address) redeemableContracts;
uint256 numRedeemableContracts;
mapping(uint => Whitelist) whitelistData;
uint256 numTokenWhitelists;
MintingConfig mintingConfig;
WhiteListConfig whiteListConfig;
bool isTokenPack;
TokenPackConfig tokenPackConfig;
}
struct MintingConfig {
bool saleIsOpen;
uint256 windowOpens;
uint256 windowCloses;
uint256 mintPrice;
uint256 maxSupply;
uint256 maxPerWallet;
uint256 maxMintPerTxn;
uint256 numMinted;
}
struct WhiteListConfig {
bool maxQuantityMappedByWhitelistHoldings;
bool requireAllWhiteLists;
bool hasMerkleRoot;
bytes32 merkleRoot;
}
struct TokenPackConfig {
uint256[] packTokens;
bool isRandomPack;
uint numRandom;
uint numWhiteListBonus;
bool allotOwnedTokenQuantity;
bool isWhiteListBonusAggregatedAcrossAllWhiteLists;
}
struct Whitelist {
string tokenType;
address tokenAddress;
uint mustOwnQuantity;
uint256 tokenId;
bool active;
}
string public _contractURI;
constructor(
string memory _name,
string memory _symbol,
address[] memory _admins,
string memory _contract_URI
) ERC1155("ipfs://") {
name_ = _name;
symbol_ = _symbol;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
for (uint i=0; i< _admins.length; i++) {
_setupRole(DEFAULT_ADMIN_ROLE, _admins[i]);
}
_contractURI = _contract_URI;
}
function getOpenSaleTokens() public view returns (string memory){
string memory open = "";
uint256 numTokens = 0;
while(!compareStrings(tokens[numTokens].ipfsMetadataHash, "")) {
if(isSaleOpen(numTokens)){
open = string(abi.encodePacked(open, Strings.toString(numTokens), ","));
}
numTokens++;
}
return open;
}
function addToken(
string memory _ipfsMetadataHash,
string memory _extraDataUri,
uint256 _windowOpens,
uint256 _windowCloses,
uint256 _mintPrice,
uint256 _maxSupply,
uint256 _maxMintPerTxn,
uint256 _maxPerWallet,
bool _maxQuantityMappedByWhitelistHoldings,
bool _requireAllWhiteLists,
address[] memory _redeemableContracts
) external onlyRole(DEFAULT_ADMIN_ROLE) {
editToken(tokenCounter.current(), _ipfsMetadataHash, _extraDataUri, _windowOpens, _windowCloses, _mintPrice, _maxSupply, _maxMintPerTxn, _maxPerWallet, _maxQuantityMappedByWhitelistHoldings, _requireAllWhiteLists, _redeemableContracts);
tokenCounter.increment();
}
function editToken(
uint256 _tokenIndex,
string memory _ipfsMetadataHash,
string memory _extraDataUri,
uint256 _windowOpens,
uint256 _windowCloses,
uint256 _mintPrice,
uint256 _maxSupply,
uint256 _maxMintPerTxn,
uint256 _maxPerWallet,
bool _maxQuantityMappedByWhitelistHoldings,
bool _requireAllWhiteLists,
address[] memory _redeemableContracts
) public onlyRole(DEFAULT_ADMIN_ROLE) {
Token storage token = tokens[_tokenIndex];
token.mintingConfig.windowOpens = _windowOpens;
token.mintingConfig.windowCloses = _windowCloses;
token.mintingConfig.mintPrice = _mintPrice;
token.mintingConfig.maxSupply = _maxSupply;
token.mintingConfig.maxMintPerTxn = _maxMintPerTxn;
token.mintingConfig.maxPerWallet = _maxPerWallet;
token.ipfsMetadataHash = _ipfsMetadataHash;
token.extraDataUri = _extraDataUri;
for (uint i=0; i<_redeemableContracts.length; i++) {
token.redeemableContracts[i] = _redeemableContracts[i];
}
token.numRedeemableContracts = _redeemableContracts.length;
token.whiteListConfig.maxQuantityMappedByWhitelistHoldings = _maxQuantityMappedByWhitelistHoldings;
token.whiteListConfig.requireAllWhiteLists = _requireAllWhiteLists;
}
function configTokenPack(
uint256 _tokenIndex,
bool _isTokenPack,
uint256[] memory _packTokens,
bool _isRandomPack,
uint _numRandom,
uint _numWhiteListBonus,
bool _allotOwnedTokenQuantity,
bool _isWhiteListBonusAggregatedAcrossAllWhiteLists
)external onlyRole(DEFAULT_ADMIN_ROLE) {
TokenPackConfig storage tokenPackConfig = tokens[_tokenIndex].tokenPackConfig;
tokens[_tokenIndex].isTokenPack = _isTokenPack;
tokenPackConfig.packTokens = _packTokens;
tokenPackConfig.isRandomPack = _isRandomPack;
tokenPackConfig.numRandom = _numRandom;
tokenPackConfig.numWhiteListBonus = _numWhiteListBonus;
tokenPackConfig.allotOwnedTokenQuantity = _allotOwnedTokenQuantity;
tokenPackConfig.isWhiteListBonusAggregatedAcrossAllWhiteLists = _isWhiteListBonusAggregatedAcrossAllWhiteLists;
}
function addWhiteList(
uint256 _tokenIndex,
string memory _tokenType,
address _tokenAddress,
uint _tokenId,
uint _mustOwnQuantity
)external onlyRole(DEFAULT_ADMIN_ROLE) {
Whitelist storage whitelist = tokens[_tokenIndex].whitelistData[tokens[_tokenIndex].numTokenWhitelists];
whitelist.tokenType = _tokenType;
whitelist.tokenId = _tokenId;
whitelist.active = true;
whitelist.tokenAddress = _tokenAddress;
whitelist.mustOwnQuantity = _mustOwnQuantity;
tokens[_tokenIndex].numTokenWhitelists = tokens[_tokenIndex].numTokenWhitelists + 1;
}
function disableWhiteList(
uint256 _tokenIndex,
uint _whiteListIndexToRemove
)external onlyRole(DEFAULT_ADMIN_ROLE) {
tokens[_tokenIndex].whitelistData[_whiteListIndexToRemove].active = false;
}
function editTokenWhiteListMerkleRoot(
uint256 _tokenIndex,
bytes32 _merkleRoot,
bool enabled
) external onlyRole(DEFAULT_ADMIN_ROLE) {
tokens[_tokenIndex].whiteListConfig.merkleRoot = _merkleRoot;
tokens[_tokenIndex].whiteListConfig.hasMerkleRoot = enabled;
}
function burnFromRedeem(
address account,
uint256 tokenIndex,
uint256 amount
) external {
Token storage token = tokens[tokenIndex];
bool hasValidRedemptionContract = false;
if(token.numRedeemableContracts > 0){
for (uint i=0; i < token.numRedeemableContracts; i++) {
if(token.redeemableContracts[i] == msg.sender){
hasValidRedemptionContract = true;
}
}
}
require(hasValidRedemptionContract, "b1");
_burn(account, tokenIndex, amount);
}
function purchase(
uint256[] calldata _quantities,
uint256[] calldata _tokenIndexes,
uint256[] calldata _merkleAmounts,
bytes32[][] calldata _merkleProofs
) external payable {
require(!paused(), "p0");
uint256 totalPrice = 0;
for (uint i=0; i< _tokenIndexes.length; i++) {
totalPrice = totalPrice.add(_quantities[i].mul(tokens[_tokenIndexes[i]].mintingConfig.mintPrice));
}
require(msg.value >= totalPrice, "p1");
for (uint i=0; i< _tokenIndexes.length; i++) {
uint256 quantityToMint = getQualifiedAllocation(msg.sender,_tokenIndexes[i], _quantities[i],_merkleAmounts[i],_merkleProofs[i], true);
require(quantityToMint > 0 && quantityToMint >= _quantities[i], "p2");
uint256[] memory idsToMint;
uint256[] memory quantitiesToMint;
if(tokens[_tokenIndexes[i]].isTokenPack){
quantityToMint = getQualifiedAllocation(msg.sender,_tokenIndexes[i], _quantities[i],_merkleAmounts[i],_merkleProofs[i], false);
for (uint j=0; j < _quantities[i]; j++) {
uint256[] memory inStockTokens = filterInStockTokensFromPack(tokens[_tokenIndexes[i]].tokenPackConfig, j);
if(tokens[_tokenIndexes[i]].tokenPackConfig.isRandomPack){
idsToMint = new uint256[](quantityToMint);
quantitiesToMint = new uint256[](quantityToMint);
uint startingIndex = 0;
uint q = 0;
while(q < quantityToMint) {
idsToMint[q] = inStockTokens[startingIndex];
quantitiesToMint[q] = 1;
if(startingIndex < inStockTokens.length - 1){
startingIndex = startingIndex + 1;
}
else{
startingIndex = 0;
}
q = q + 1;
}
}
else{
idsToMint = new uint256[](inStockTokens.length);
for (uint q=0; q < inStockTokens.length; q++) {
idsToMint[q] = inStockTokens[q];
quantitiesToMint[q] = 1;
}
}
_mintBatch(msg.sender, idsToMint, quantitiesToMint, "");
emit Purchased(idsToMint, msg.sender, quantitiesToMint);
tokens[_tokenIndexes[i]].mintingConfig.numMinted = tokens[_tokenIndexes[i]].mintingConfig.numMinted + 1;
}
}
else{
idsToMint = new uint256[](1);
idsToMint[0] = _tokenIndexes[i];
quantitiesToMint = new uint256[](1);
quantitiesToMint[0] = _quantities[i];
_mintBatch(msg.sender, idsToMint, quantitiesToMint, "");
emit Purchased(idsToMint, msg.sender, quantitiesToMint);
}
tokens[_tokenIndexes[i]].claimedTokens[msg.sender] = tokens[_tokenIndexes[i]].claimedTokens[msg.sender].add(_quantities[i]);
}
}
function filterInStockTokensFromPack(TokenPackConfig memory tokenPackConfig, uint seed) internal view returns(uint256[] memory){
tokenPackConfig.packTokens = shuffle(tokenPackConfig.packTokens, false, seed);
uint256[] memory inStockTokens;
uint totalInStock = 0;
for (uint i=0; i < tokenPackConfig.packTokens.length; i++) {
if(getTokenSupply(tokenPackConfig.packTokens[i]) < tokens[tokenPackConfig.packTokens[i]].mintingConfig.maxSupply){
totalInStock++;
}
}
inStockTokens = new uint256[](totalInStock);
uint startingIndex = 0;
for (uint i=0; i < tokenPackConfig.packTokens.length; i++) {
if(getTokenSupply(tokenPackConfig.packTokens[i]) < tokens[tokenPackConfig.packTokens[i]].mintingConfig.maxSupply){
inStockTokens[startingIndex] = tokenPackConfig.packTokens[i];
startingIndex++;
}
}
return inStockTokens;
}
function shuffle(uint256[] memory numberArr, bool returnRandomIndex, uint seed) internal view returns(uint256[] memory){
if(!returnRandomIndex){
for (uint256 i = 0; i < numberArr.length; i++) {
uint256 n = i + uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % (numberArr.length - i);
uint256 temp = numberArr[n];
numberArr[n] = numberArr[i];
numberArr[i] = temp;
}
}
else{
uint randomHash = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % numberArr.length;
uint256[] memory retNumberArr = new uint256[](1);
retNumberArr[0] = numberArr[randomHash];
numberArr = retNumberArr;
}
return numberArr;
}
function mintBatch(
address to,
uint256[] calldata qty,
uint256[] calldata _tokens) public onlyRole(DEFAULT_ADMIN_ROLE)
{
_mintBatch(to, _tokens, qty, "");
}
function getQualifiedAllocation(address sender,
uint256 tokenIndex,
uint256 quantity,
uint256 amount,
bytes32[] calldata merkleProof,
bool returnAllocationOnly) public view returns (uint256) {
Token storage token = tokens[tokenIndex];
if(!returnAllocationOnly){
require(token.mintingConfig.saleIsOpen, "v1");
require(!paused(), "v2");
require(token.mintingConfig.windowOpens > 0, "v3");
require (block.timestamp > token.mintingConfig.windowOpens && block.timestamp < token.mintingConfig.windowCloses, "v4");
require(token.claimedTokens[sender].add(quantity) <= amount, "v5");
require(token.claimedTokens[sender].add(quantity) <= token.mintingConfig.maxPerWallet, "v6");
require(quantity <= token.mintingConfig.maxMintPerTxn, "v7");
require(getTokenSupply(tokenIndex) + quantity <= token.mintingConfig.maxSupply, "v8");
}
uint256 totalAllowed = token.mintingConfig.maxPerWallet;
if(token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
totalAllowed = 0;
}
uint256 whiteListsValidAmounts = 0;
if(token.numTokenWhitelists > 0){
uint256 balance = 0;
uint256 _wl_amount = 0;
for (uint i=0; i < token.numTokenWhitelists; i++) {
if(token.whitelistData[i].active){
_wl_amount = verifyWhitelist(sender, tokenIndex, i, returnAllocationOnly);
if(token.whiteListConfig.requireAllWhiteLists){
require( verifyWhitelist(sender, tokenIndex, i, returnAllocationOnly) > 0, "v9");
}
if(token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
Whitelist memory balanceRequest;
balanceRequest.tokenType = token.whitelistData[i].tokenType;
balanceRequest.tokenAddress = token.whitelistData[i].tokenAddress;
balanceRequest.tokenId = token.whitelistData[i].tokenId;
balance = getExternalTokenBalance(sender, balanceRequest);
totalAllowed += balance;
whiteListsValidAmounts += balance;
}
else{
whiteListsValidAmounts = _wl_amount;
}
}
}
}
else{
whiteListsValidAmounts = token.mintingConfig.maxMintPerTxn;
}
if(!returnAllocationOnly){
require(whiteListsValidAmounts > 0, "v10");
if(token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
require(token.claimedTokens[sender].add(quantity) <= totalAllowed, "v11");
}
}
if(token.whiteListConfig.hasMerkleRoot){
require(
verifyMerkleProof(merkleProof, tokenIndex, amount),
"v12"
);
}
if(returnAllocationOnly){
return whiteListsValidAmounts < quantity ? whiteListsValidAmounts : quantity;
}
else{
return whiteListsValidAmounts;
}
}
function verifyWhitelist(address sender, uint256 tokenIndex, uint whitelistIndex, bool returnAllocationOnly) internal view returns (uint256) {
uint256 isValid = 0;
uint256 balanceOf = 0;
Token storage token = tokens[tokenIndex];
Whitelist memory balanceRequest;
balanceRequest.tokenType = token.whitelistData[whitelistIndex].tokenType;
balanceRequest.tokenAddress = token.whitelistData[whitelistIndex].tokenAddress;
balanceRequest.tokenId = token.whitelistData[whitelistIndex].tokenId;
balanceOf = getExternalTokenBalance(sender, balanceRequest);
bool meetsWhiteListReqs = (balanceOf >= token.whitelistData[whitelistIndex].mustOwnQuantity);
if(token.isTokenPack && !returnAllocationOnly){
if(token.tokenPackConfig.isRandomPack){
isValid = isValid + token.tokenPackConfig.numRandom;
}
else{
isValid = isValid + token.tokenPackConfig.packTokens.length;
}
if(token.tokenPackConfig.numWhiteListBonus > 0 && meetsWhiteListReqs){
isValid = isValid + token.tokenPackConfig.numWhiteListBonus;
}
}
else if(token.isTokenPack && token.tokenPackConfig.allotOwnedTokenQuantity && meetsWhiteListReqs){
isValid = balanceOf;
}
else if(!token.isTokenPack && token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
isValid = balanceOf;
}
else if( meetsWhiteListReqs){
isValid = token.mintingConfig.maxMintPerTxn;
}
if(isValid == 0 && !token.whiteListConfig.requireAllWhiteLists){
isValid = token.mintingConfig.maxMintPerTxn;
}
return isValid;
}
function getExternalTokenBalance (address sender, Whitelist memory balanceRequest) public view returns (uint256) {
if(compareStrings(balanceRequest.tokenType, "ERC721")){
WhitelistContract721 _contract = WhitelistContract721(balanceRequest.tokenAddress);
return _contract.balanceOf(sender);
}
else if(compareStrings(balanceRequest.tokenType, "ERC1155")){
WhitelistContract1155 _contract = WhitelistContract1155(balanceRequest.tokenAddress);
return _contract.balanceOf(sender, balanceRequest.tokenId);
}
}
function isSaleOpen(uint256 tokenIndex) public view returns (bool) {
Token storage token = tokens[tokenIndex];
if(paused()){
return false;
}
if(block.timestamp > token.mintingConfig.windowOpens && block.timestamp < token.mintingConfig.windowCloses){
return token.mintingConfig.saleIsOpen;
}
return false;
}
function toggleSale(uint256 mpIndex, bool on) public onlyRole(DEFAULT_ADMIN_ROLE) {
tokens[mpIndex].mintingConfig.saleIsOpen = on;
}
function makeLeaf(address _addr, uint amount) internal view returns (string memory) {
bytes memory s = new bytes(40);
for (uint i = 0; i < 20; i++) {
bytes1 b = bytes1(uint8(uint(uint160(_addr)) / (2**(8*(19 - i)))));
bytes1 hi = bytes1(uint8(b) / 16);
bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));
s[2*i] = char(hi);
s[2*i+1] = char(lo);
}
return string(abi.encodePacked(string(s), "_", Strings.toString(amount)));
}
function verifyMerkleProof(bytes32[] calldata merkleProof, uint256 mpIndex, uint amount) internal view returns (bool) {
if(!tokens[mpIndex].whiteListConfig.hasMerkleRoot){
return true;
}
string memory leaf = makeLeaf(msg.sender, amount);
bytes32 node = keccak256(abi.encode(leaf));
return MerkleProof.verify(merkleProof, tokens[mpIndex].whiteListConfig.merkleRoot, node);
}
function compareStrings(string memory a, string memory b) internal view returns (bool) {
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
}
function char(bytes1 b) internal view returns (bytes1 c) {
if (uint8(b) < 10) return bytes1(uint8(b) + 0x30);
else return bytes1(uint8(b) + 0x57);
}
function withdrawEther(address payable _to, uint256 _amount) public onlyOwner
{
_to.transfer(_amount);
}
function uri(uint256 _id) public view override returns (string memory) {
require(getTokenSupply(_id) > 0, "URI: na");
if(compareStrings(tokens[_id].ipfsMetadataHash, "")){
return string(abi.encodePacked(super.uri(_id), Strings.toString(_id)));
}
else{
return string(abi.encodePacked(tokens[_id].ipfsMetadataHash));
}
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function getTokenSupply(uint256 tokenIndex) public view returns (uint256) {
Token storage token = tokens[tokenIndex];
return token.isTokenPack ? token.mintingConfig.numMinted : totalSupply(tokenIndex);
}
}
contract WhitelistContract1155 {
function balanceOf(address account, uint256 id) external view returns (uint256) {}
}
contract WhitelistContract721 {
function balanceOf(address account) external view returns (uint256) {}
}
文件 5 的 21:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 6 的 21:Counters.sol
pragma solidity ^0.8.0;
library Counters {
struct Counter {
uint256 _value;
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
文件 7 的 21:ERC1155.sol
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
mapping(uint256 => mapping(address => uint256)) private _balances;
mapping(address => mapping(address => bool)) private _operatorApprovals;
string private _uri;
constructor(string memory uri_) {
_setURI(uri_);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
function setApprovalForAll(address operator, bool approved) public virtual override {
require(_msgSender() != operator, "ERC1155: setting approval status for self");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(account != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][account] += amount;
emit TransferSingle(operator, address(0), account, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data);
}
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 accountBalance = _balances[id][account];
require(accountBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][account] = accountBalance - amount;
}
emit TransferSingle(operator, account, address(0), id, amount);
}
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 accountBalance = _balances[id][account];
require(accountBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][account] = accountBalance - amount;
}
}
emit TransferBatch(operator, account, address(0), ids, amounts);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
文件 8 的 21:ERC1155Burnable.sol
pragma solidity ^0.8.0;
import "../ERC1155.sol";
abstract contract ERC1155Burnable is ERC1155 {
function burn(
address account,
uint256 id,
uint256 value
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
function burnBatch(
address account,
uint256[] memory ids,
uint256[] memory values
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burnBatch(account, ids, values);
}
}
文件 9 的 21:ERC1155Pausable.sol
pragma solidity ^0.8.0;
import "../ERC1155.sol";
import "../../../security/Pausable.sol";
abstract contract ERC1155Pausable is ERC1155, Pausable {
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
require(!paused(), "ERC1155Pausable: token transfer while paused");
}
}
文件 10 的 21:ERC1155Supply.sol
pragma solidity ^0.8.0;
import "../ERC1155.sol";
abstract contract ERC1155Supply is ERC1155 {
mapping(uint256 => uint256) private _totalSupply;
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply[id];
}
function exists(uint256 id) public view virtual returns (bool) {
return ERC1155Supply.totalSupply(id) > 0;
}
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual override {
super._mint(account, id, amount, data);
_totalSupply[id] += amount;
}
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._mintBatch(to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] += amounts[i];
}
}
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual override {
super._burn(account, id, amount);
_totalSupply[id] -= amount;
}
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual override {
super._burnBatch(account, ids, amounts);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] -= amounts[i];
}
}
}
文件 11 的 21:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 12 的 21:IAccessControl.sol
pragma solidity ^0.8.0;
interface IAccessControl {
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
文件 13 的 21:IERC1155.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155 is IERC165 {
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
event URI(string value, uint256 indexed id);
function balanceOf(address account, uint256 id) external view returns (uint256);
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
function setApprovalForAll(address operator, bool approved) external;
function isApprovedForAll(address account, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
文件 14 的 21:IERC1155MetadataURI.sol
pragma solidity ^0.8.0;
import "../IERC1155.sol";
interface IERC1155MetadataURI is IERC1155 {
function uri(uint256 id) external view returns (string memory);
}
文件 15 的 21:IERC1155Receiver.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155Receiver is IERC165 {
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
文件 16 的 21:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 17 的 21:MerkleProof.sol
pragma solidity ^0.8.0;
library MerkleProof {
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash == root;
}
}
文件 18 的 21:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_setOwner(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 19 的 21:Pausable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
function paused() public view virtual returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 20 的 21:SafeMath.sol
pragma solidity ^0.8.0;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
文件 21 的 21:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
{
"compilationTarget": {
"contracts/Commerce.sol": "Commerce"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address[]","name":"_admins","type":"address[]"},{"internalType":"string","name":"_contract_URI","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"index","type":"uint256[]"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"amount","type":"uint256[]"}],"name":"Purchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_ipfsMetadataHash","type":"string"},{"internalType":"string","name":"_extraDataUri","type":"string"},{"internalType":"uint256","name":"_windowOpens","type":"uint256"},{"internalType":"uint256","name":"_windowCloses","type":"uint256"},{"internalType":"uint256","name":"_mintPrice","type":"uint256"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"},{"internalType":"uint256","name":"_maxMintPerTxn","type":"uint256"},{"internalType":"uint256","name":"_maxPerWallet","type":"uint256"},{"internalType":"bool","name":"_maxQuantityMappedByWhitelistHoldings","type":"bool"},{"internalType":"bool","name":"_requireAllWhiteLists","type":"bool"},{"internalType":"address[]","name":"_redeemableContracts","type":"address[]"}],"name":"addToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIndex","type":"uint256"},{"internalType":"string","name":"_tokenType","type":"string"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_mustOwnQuantity","type":"uint256"}],"name":"addWhiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFromRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIndex","type":"uint256"},{"internalType":"bool","name":"_isTokenPack","type":"bool"},{"internalType":"uint256[]","name":"_packTokens","type":"uint256[]"},{"internalType":"bool","name":"_isRandomPack","type":"bool"},{"internalType":"uint256","name":"_numRandom","type":"uint256"},{"internalType":"uint256","name":"_numWhiteListBonus","type":"uint256"},{"internalType":"bool","name":"_allotOwnedTokenQuantity","type":"bool"},{"internalType":"bool","name":"_isWhiteListBonusAggregatedAcrossAllWhiteLists","type":"bool"}],"name":"configTokenPack","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIndex","type":"uint256"},{"internalType":"uint256","name":"_whiteListIndexToRemove","type":"uint256"}],"name":"disableWhiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIndex","type":"uint256"},{"internalType":"string","name":"_ipfsMetadataHash","type":"string"},{"internalType":"string","name":"_extraDataUri","type":"string"},{"internalType":"uint256","name":"_windowOpens","type":"uint256"},{"internalType":"uint256","name":"_windowCloses","type":"uint256"},{"internalType":"uint256","name":"_mintPrice","type":"uint256"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"},{"internalType":"uint256","name":"_maxMintPerTxn","type":"uint256"},{"internalType":"uint256","name":"_maxPerWallet","type":"uint256"},{"internalType":"bool","name":"_maxQuantityMappedByWhitelistHoldings","type":"bool"},{"internalType":"bool","name":"_requireAllWhiteLists","type":"bool"},{"internalType":"address[]","name":"_redeemableContracts","type":"address[]"}],"name":"editToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIndex","type":"uint256"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"editTokenWhiteListMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"string","name":"tokenType","type":"string"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"mustOwnQuantity","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct Commerce.Whitelist","name":"balanceRequest","type":"tuple"}],"name":"getExternalTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOpenSaleTokens","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"},{"internalType":"bool","name":"returnAllocationOnly","type":"bool"}],"name":"getQualifiedAllocation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"}],"name":"getTokenSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"}],"name":"isSaleOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"qty","type":"uint256[]"},{"internalType":"uint256[]","name":"_tokens","type":"uint256[]"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_quantities","type":"uint256[]"},{"internalType":"uint256[]","name":"_tokenIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"_merkleAmounts","type":"uint256[]"},{"internalType":"bytes32[][]","name":"_merkleProofs","type":"bytes32[][]"}],"name":"purchase","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setURI","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":[],"name":"symbol_","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"mpIndex","type":"uint256"},{"internalType":"bool","name":"on","type":"bool"}],"name":"toggleSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"string","name":"ipfsMetadataHash","type":"string"},{"internalType":"string","name":"extraDataUri","type":"string"},{"internalType":"uint256","name":"numRedeemableContracts","type":"uint256"},{"internalType":"uint256","name":"numTokenWhitelists","type":"uint256"},{"components":[{"internalType":"bool","name":"saleIsOpen","type":"bool"},{"internalType":"uint256","name":"windowOpens","type":"uint256"},{"internalType":"uint256","name":"windowCloses","type":"uint256"},{"internalType":"uint256","name":"mintPrice","type":"uint256"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"maxPerWallet","type":"uint256"},{"internalType":"uint256","name":"maxMintPerTxn","type":"uint256"},{"internalType":"uint256","name":"numMinted","type":"uint256"}],"internalType":"struct Commerce.MintingConfig","name":"mintingConfig","type":"tuple"},{"components":[{"internalType":"bool","name":"maxQuantityMappedByWhitelistHoldings","type":"bool"},{"internalType":"bool","name":"requireAllWhiteLists","type":"bool"},{"internalType":"bool","name":"hasMerkleRoot","type":"bool"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct Commerce.WhiteListConfig","name":"whiteListConfig","type":"tuple"},{"internalType":"bool","name":"isTokenPack","type":"bool"},{"components":[{"internalType":"uint256[]","name":"packTokens","type":"uint256[]"},{"internalType":"bool","name":"isRandomPack","type":"bool"},{"internalType":"uint256","name":"numRandom","type":"uint256"},{"internalType":"uint256","name":"numWhiteListBonus","type":"uint256"},{"internalType":"bool","name":"allotOwnedTokenQuantity","type":"bool"},{"internalType":"bool","name":"isWhiteListBonusAggregatedAcrossAllWhiteLists","type":"bool"}],"internalType":"struct Commerce.TokenPackConfig","name":"tokenPackConfig","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"}]