编译器
0.8.20+commit.a1b79de6
文件 1 的 4: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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 2 的 4:MerkleProof.sol
pragma solidity ^0.8.0;
library MerkleProof {
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
require(proofPos == proofLen, "MerkleProof: invalid multiproof");
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
require(proofPos == proofLen, "MerkleProof: invalid multiproof");
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
文件 3 的 4:Musubi_burninAddvanced.sol
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
pragma solidity >=0.7.0 <0.9.0;
interface iNFTCollection {
function balanceOf(address _owner) external view returns (uint);
function ownerOf(uint256 tokenId) external view returns (address);
}
contract Musubi_burninAddvanced_ERC721 is Ownable{
string public baseURI;
string public baseURIBurnin;
string public baseExtension = ".json";
mapping(uint256 => uint256) public burninFlag;
mapping(uint256 => mapping(address => uint256)) public userBurnedAmountByPhase;
constructor(){
setNFTCollection(0x83B265B7b89E967318334602be9ea57b1a8d3b47);
setBaseURI("https://musubicollection.xyz/data/metadata/");
setBaseURIBurnin("https://musubicollection.xyz/data/v3metadata/");
setMerkleRoot(0xb2bb5b47c83579fb453002bd4f3506701fa526112e6f5563948cbdf3e2979851);
}
address public withdrawAddress = 0x52C5DcF49f10C827E070cee4aDf1D006942eAaB6;
function setWithdrawAddress(address _withdrawAddress) public onlyOwner {
withdrawAddress = _withdrawAddress;
}
function withdraw() public payable onlyOwner {
(bool os, ) = payable(withdrawAddress).call{value: address(this).balance}('');
require(os);
}
uint256 public cost = 12000000000000000;
uint256 public maxBurnin = 150;
uint256 public totalBurnin = 0;
bool public paused = true;
bool public onlyAllowlisted = true;
bytes32 public merkleRoot;
uint256 public burninPhase = 1;
iNFTCollection public NFTCollection;
modifier callerIsUser() {
require(tx.origin == msg.sender, "The caller is another contract.");
_;
}
function burnin(uint256 _maxBurninAmount, bytes32[] calldata _merkleProof, uint256 _burnId) public payable callerIsUser {
require(!paused, "the contract is paused");
require(totalBurnin + 1 <= maxBurnin, "max NFT limit exceeded");
require(cost <= msg.value, "insufficient funds");
require(nftOwnerOf(_burnId) == msg.sender, "Owner is different");
require(burninFlag[_burnId] < burninPhase, "already burned in this phase");
uint256 burnedAmountThisPhase = userBurnedAmountByPhase[burninPhase][msg.sender];
uint256 maxMintAmountPerAddress = 0;
if (onlyAllowlisted == true) {
bytes32 leaf = keccak256(abi.encodePacked(msg.sender, _maxBurninAmount));
require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "user is not allowlisted");
maxMintAmountPerAddress = _maxBurninAmount;
require(burnedAmountThisPhase + 1 <= maxMintAmountPerAddress, "max NFT per address exceeded");
}
userBurnedAmountByPhase[burninPhase][msg.sender] = burnedAmountThisPhase + 1;
totalBurnin += 1;
burninFlag[_burnId] = burninPhase;
}
function advanceBurninPhase() public onlyOwner {
burninPhase++;
totalBurnin = 0;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setMaxBurnin(uint256 _maxBurnin) public onlyOwner {
maxBurnin = _maxBurnin;
}
function setPause(bool _state) public onlyOwner {
paused = _state;
}
function setOnlyAllowlisted(bool _state) public onlyOwner {
onlyAllowlisted = _state;
}
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner {
merkleRoot = _merkleRoot;
}
function setNFTCollection(address _address) public onlyOwner {
NFTCollection = iNFTCollection(_address);
}
function nftOwnerOf(uint256 _tokenId)public view returns(address){
return NFTCollection.ownerOf(_tokenId);
}
function nftBalanceOf(address _address)public view returns(uint256){
return NFTCollection.balanceOf(_address);
}
function nftTokensOfOwner(address _address) public view returns (uint256[] memory) {
uint256 tokenIdsIdx;
uint256 tokenIdsLength = NFTCollection.balanceOf(_address);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
for (uint256 i = 0; tokenIdsIdx != tokenIdsLength; ++i) {
if (NFTCollection.ownerOf(i) == _address) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
function burnedTokenIds() public view returns (uint256[] memory) {
uint256 tokenIdsIdx;
uint256 tokenIdsLength = totalBurnin;
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
for (uint256 i = 0; tokenIdsIdx != tokenIdsLength; ++i) {
if (burninFlag[i] > 0) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
function tokenURI(uint256 _tokenId) public view returns (string memory) {
if (burninFlag[_tokenId] == 0) {
return string(abi.encodePacked(baseURI, _toString(_tokenId), baseExtension));
} else {
return string(abi.encodePacked(baseURIBurnin, _toString(_tokenId), baseExtension));
}
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseURIBurnin(string memory _newBaseURI) public onlyOwner {
baseURIBurnin = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
str := add(mload(0x40), 0x80)
mstore(0x40, str)
let end := str
for { let temp := value } 1 {} {
str := sub(str, 1)
mstore8(str, add(48, mod(temp, 10)))
temp := div(temp, 10)
if iszero(temp) { break }
}
let length := sub(end, str)
str := sub(str, 0x20)
mstore(str, length)
}
}
}
文件 4 的 4: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() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/Musubi_burninAddvanced.sol": "Musubi_burninAddvanced_ERC721"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"viaIR": true
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"NFTCollection","outputs":[{"internalType":"contract iNFTCollection","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"advanceBurninPhase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"baseExtension","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURIBurnin","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnedTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxBurninAmount","type":"uint256"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"},{"internalType":"uint256","name":"_burnId","type":"uint256"}],"name":"burnin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"burninFlag","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burninPhase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBurnin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"nftBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"nftOwnerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"nftTokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onlyAllowlisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseExtension","type":"string"}],"name":"setBaseExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseURI","type":"string"}],"name":"setBaseURIBurnin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newCost","type":"uint256"}],"name":"setCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxBurnin","type":"uint256"}],"name":"setMaxBurnin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"setNFTCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setOnlyAllowlisted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_withdrawAddress","type":"address"}],"name":"setWithdrawAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBurnin","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":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userBurnedAmountByPhase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]