文件 1 的 13: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);
}
}
}
}
文件 2 的 13: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;
}
}
文件 3 的 13: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;
}
}
文件 4 的 13:ERC721.sol
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 => address) private _owners;
mapping(address => uint256) private _balances;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
文件 5 的 13:Gen.sol
pragma solidity ^0.8.7;
contract Gen {
mapping(string => uint) internal charsMap;
mapping(uint => uint) internal tokenIdToSeed;
mapping(uint => uint[8]) internal tokenIdToShuffleShift;
mapping(uint => uint) internal shuffleCount;
mapping(address => bool) internal hasClaimed;
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);
}
uint16[297] ps = [
1000, 1889, 2889, 3556, 5223, 6223, 7334, 8778, 9334, 9556, 10000,
381, 952, 1428, 1809, 2761, 4856, 6094, 7523, 9523, 9809, 10000,
198, 792, 1584, 2079, 2574, 3267, 3366, 5643, 7029, 9900, 10000,
714, 1071, 1607, 2232, 2945, 4285, 5178, 6516, 7856, 9195, 10000,
385, 1348, 3467, 5201, 6163, 7127, 9824, 9920, 9939, 9958, 10000,
135, 405, 1081, 1216, 1892, 2703, 4325, 5541, 7568, 9730, 10000,
2443, 2932, 3421, 3910, 4561, 5212, 6677, 8470, 9936, 9985, 10000,
1239, 1770, 2655, 4071, 5310, 6726, 7257, 9912, 9947, 9982, 10000,
268, 281, 294, 328, 1668, 4751, 7432, 9979, 9986, 9993, 10000,
291, 679, 1164, 1649, 2329, 3106, 3689, 4951, 6504, 9708, 10000,
353, 706, 1923, 3510, 5097, 7672, 8818, 9964, 9982, 9991, 10000,
755, 1227, 1416, 1605, 1888, 2077, 2171, 3114, 9246, 9812, 10000,
695, 721, 747, 834, 851, 3023, 5195, 6846, 9974, 9991, 10000,
103, 308, 513, 821, 1437, 2566, 3901, 7289, 9958, 9979, 10000,
294, 588, 735, 750, 1337, 2071, 2805, 4127, 6183, 8239, 10000,
88, 1148, 2561, 2738, 3975, 4682, 4859, 5389, 7156, 9983, 10000,
325, 760, 1303, 1629, 1955, 3367, 4670, 6624, 8253, 9990, 10000,
4955, 9910, 9920, 9930, 9940, 9950, 9960, 9970, 9980, 9990, 10000,
214, 428, 641, 663, 1197, 1411, 1454, 2522, 3590, 4658, 10000,
196, 784, 2548, 3332, 4312, 5488, 7644, 9800, 9996, 9998, 10000,
475, 1424, 1661, 2848, 4272, 5933, 8544, 9256, 9968, 9992, 10000,
515, 618, 1133, 1442, 2267, 3298, 4947, 6493, 7730, 9483, 10000,
202, 1412, 3025, 5444, 7662, 9880, 9920, 9940, 9960, 9980, 10000,
23, 252, 480, 2657, 2886, 4719, 7354, 9645, 9874, 9885, 10000,
433, 866, 1732, 3464, 5195, 8659, 9525, 9698, 9871, 9958, 10000,
601, 901, 1502, 2103, 3605, 4806, 6007, 9010, 9310, 9400, 10000,
204, 511, 613, 714, 1737, 3782, 9917, 9968, 9978, 9988, 10000];
string[] nextChars = [
"fbrwsaltpzj",
"gmldslrtnkb",
"blriiluoaey",
"rliktauhooe",
"ruaoiiegfws",
"mfteladsnrg",
"luaarreioyw",
"luiraohezgy",
"urryoiaejlw",
"gredlocstnb",
"iieaaouuytf",
"aollarsieut",
"ussdyoaielf",
"smmupioaeyn",
"aauyiosetgd",
"zolwtmfurny",
"tupiilaores",
"uuaeiosrfyw",
"nudytslaioe",
"puhaoietwyq",
"usraieohhty",
"ebgzplsntrm",
"uoaieeyvxrl",
"snnoheaiuyr",
"oaueeityxth",
"lmaiseeouvx",
"uyooiaelzrl"];
function mapChars() internal {
string[27] memory chars = [" ", "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
for (uint i=0; i<27; i++) {
charsMap[chars[i]] = i;
}
}
function stringLength(string memory _string) internal pure returns(uint) {
return bytes(_string).length;
}
function getChar(uint row, uint col) internal view returns(string memory) {
bytes memory line = bytes(nextChars[row]);
string memory temp = new string(1);
bytes memory output = bytes(temp);
output[0] = line[col];
return string(output);
}
function determineWordLength(uint rand) internal pure returns(uint) {
uint16[16] memory cumulativeDistribution = [2,99,761,1929,3175,4694,6291,7654,8744,9328,9678,9872,9938,9976,9991,10000];
uint i = 0;
while (i <= 15) {
if (rand <= cumulativeDistribution[i]) {
break;
}
i++;
}
return i+1;
}
function generateWord(uint256 _tokenId, uint _totalSeed) internal view returns(string memory) {
require(_tokenId >= 1 && _tokenId <= 10000, "Invalid tokenId.");
string memory word;
string memory char;
uint lengthRand = (uint(keccak256(abi.encodePacked(_tokenId, _totalSeed)))% 10000);
uint rand = (uint(keccak256(abi.encodePacked(_tokenId, lengthRand, _totalSeed)))% 10000) + 1;
for (uint n=1; n <= determineWordLength(lengthRand); n++) {
uint i = 0;
while (i < 11) {
if (rand <= ps[(charsMap[char]*11)+i]) {
break;
}
i++;
}
char = getChar(charsMap[char], i);
word = string(abi.encodePacked(word, char));
rand = (uint(keccak256(abi.encodePacked(_tokenId, rand, word, n, _totalSeed)))% 10000) + 1;
}
return word;
}
}
文件 6 的 13:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 7 的 13:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
文件 8 的 13:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 9 的 13:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 10 的 13:Lootlang.sol
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./Gen.sol";
library Base64 {
bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (len == 0) return "";
uint256 encodedLen = 4 * ((len + 2) / 3);
bytes memory result = new bytes(encodedLen + 32);
bytes memory table = TABLE;
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
return string(result);
}
}
contract Lootlang is ERC721, Ownable, Gen {
uint public enabled;
uint internal mints;
uint internal claims;
uint internal nextTokenId;
uint public contractBalance;
string internal contractURIstring;
uint public freezeBlock;
uint internal freezeBlockChanges;
bytes32 internal root;
constructor() Ownable() ERC721('Lootlang', 'LANG') {
nextTokenId = 1;
freezeBlock = 13487654;
contractURIstring = "https://lootlang.com/metadata.json";
mapChars();
}
event Shuffled(uint tokenId);
function setRoot(bytes32 _newRoot) external onlyOwner {
root = _newRoot;
}
function setFreezeBlock(uint _newFreezeBlockNumber) external onlyOwner {
require(freezeBlockChanges < 1, "Freeze block already changed");
freezeBlock = _newFreezeBlockNumber;
freezeBlockChanges++;
}
function withdrawFunds(address payable _to, uint _amount) external onlyOwner {
require(_amount <= contractBalance, "Withdrawal amount greater than balance");
contractBalance -= _amount;
_to.transfer(_amount);
}
function setEnable(uint _enabled) external onlyOwner {
enabled = _enabled;
}
function setContractURI(string memory _contractURIstring) external onlyOwner {
contractURIstring = _contractURIstring;
}
function mint() external payable {
require(enabled == 1, "Minting is yet to be enabled");
require(nextTokenId <= 10000 && mints <= 9700, "All NFTs have been minted");
require(msg.value >= (2*10**16), "Insufficient funds provided");
mints++;
contractBalance += msg.value;
sharedMintCode();
}
function claim(bytes32[] memory proof) external {
require(enabled == 1, "Minting is yet to be enabled");
require(hasClaimed[msg.sender] == false, "Already claimed");
require(nextTokenId <= 10000 && claims <= 300, "All NFTs have been minted");
require(MerkleProof.verify(proof, root, keccak256(abi.encodePacked(msg.sender))) == true, "Not on pre-approved claim list");
claims++;
hasClaimed[msg.sender] = true;
sharedMintCode();
}
function sharedMintCode() internal {
uint tokenId = nextTokenId;
nextTokenId++;
tokenIdToSeed[tokenId] = uint(keccak256(abi.encodePacked(tokenId, msg.sender, block.timestamp)))%1000000;
_safeMint(msg.sender, tokenId);
}
function shuffle(uint _tokenId, uint one, uint two, uint three, uint four, uint five, uint six, uint seven, uint eight) external {
require(ownerOf(_tokenId) == msg.sender, "Must be NFT owner");
require(shuffleCount[_tokenId] < 5, "Shuffled max amount already");
require(block.number < freezeBlock, "Shuffling has been frozen!");
require((one+two+three+four+five+six+seven+eight) > 0, "No words selected to be shuffled");
uint randomish = uint(keccak256(abi.encodePacked(block.number)))%1000000;
uint[8] memory indexesToChange = [one, two, three, four, five, six, seven, eight];
for (uint i=0; i<8; i++) {
if (indexesToChange[i] > 0) {
tokenIdToShuffleShift[_tokenId][i] += randomish;
}
}
shuffleCount[_tokenId]++;
emit Shuffled(_tokenId);
}
function totalSupply() external view returns(uint) {
return mints+claims;
}
function contractURI() public view returns (string memory) {
return contractURIstring;
}
function getMetaText(string memory word) internal pure returns(string memory) {
string memory length = string(abi.encodePacked("\"", toString(stringLength(word)), " letters", "\""));
return length;
}
function getMetaWord(string memory word) internal pure returns(string memory) {
string memory length = string(abi.encodePacked("\"", word, "\""));
return length;
}
function totalSeedGen(uint tokenId, uint wordNum) internal view returns(uint) {
return uint(keccak256(abi.encodePacked(uint(wordNum), tokenIdToSeed[tokenId], tokenIdToShuffleShift[tokenId][wordNum-1])));
}
function tokenURI(uint256 tokenId) override public view returns (string memory) {
require(_exists(tokenId), "URI query for nonexistent token");
string[17] memory parts;
parts[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 20px; }</style><rect width="100%" height="100%" fill="black" /><text x="15" y="30" class="base">';
parts[1] = generateWord(tokenId, totalSeedGen(tokenId, 1));
parts[2] = '</text><text x="15" y="65" class="base">';
parts[3] = generateWord(tokenId, totalSeedGen(tokenId, 2));
parts[4] = '</text><text x="15" y="100" class="base">';
parts[5] = generateWord(tokenId, totalSeedGen(tokenId, 3));
parts[6] = '</text><text x="15" y="135" class="base">';
parts[7] = generateWord(tokenId, totalSeedGen(tokenId, 4));
parts[8] = '</text><text x="15" y="170" class="base">';
parts[9] = generateWord(tokenId, totalSeedGen(tokenId, 5));
parts[10] = '</text><text x="15" y="205" class="base">';
parts[11] = generateWord(tokenId, totalSeedGen(tokenId, 6));
parts[12] = '</text><text x="15" y="240" class="base">';
parts[13] = generateWord(tokenId, totalSeedGen(tokenId, 7));
parts[14] = '</text><text x="15" y="275" class="base">';
parts[15] = generateWord(tokenId, totalSeedGen(tokenId, 8));
parts[16] = '</text></svg>';
string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8]));
output = string(abi.encodePacked(output, parts[9], parts[10], parts[11], parts[12], parts[13], parts[14], parts[15], parts[16]));
string memory json = string(abi.encodePacked('{"name": "Pack #', toString(tokenId), '", "description": "Pack of 8 Lootlang words", "attributes": [{"trait_type": "Shuffles Used", "value":', getMetaWord(toString(shuffleCount[tokenId])), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[1]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[3]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[5]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[7]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[9]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[11]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[13]), '}, {"trait_type": "Word Length", "value":', getMetaText(parts[15]), '}'));
json = Base64.encode(bytes(string(abi.encodePacked(json, ', {"trait_type": "Word", "value":', getMetaWord(parts[1]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[3]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[5]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[7]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[9]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[11]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[13]), '}, {"trait_type": "Word", "value":', getMetaWord(parts[15]), '}], "image": "data:image/svg+xml;base64, ', Base64.encode(bytes(output)), '"}'))));
output = string(abi.encodePacked('data:application/json;base64,', json));
return output;
}
}
文件 11 的 13: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;
}
}
文件 12 的 13: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);
}
}
文件 13 的 13: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": {
"Lootlang.sol": "Lootlang"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Shuffled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enabled","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezeBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"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":"_contractURIstring","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_enabled","type":"uint256"}],"name":"setEnable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newFreezeBlockNumber","type":"uint256"}],"name":"setFreezeBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_newRoot","type":"bytes32"}],"name":"setRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"one","type":"uint256"},{"internalType":"uint256","name":"two","type":"uint256"},{"internalType":"uint256","name":"three","type":"uint256"},{"internalType":"uint256","name":"four","type":"uint256"},{"internalType":"uint256","name":"five","type":"uint256"},{"internalType":"uint256","name":"six","type":"uint256"},{"internalType":"uint256","name":"seven","type":"uint256"},{"internalType":"uint256","name":"eight","type":"uint256"}],"name":"shuffle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFunds","outputs":[],"stateMutability":"nonpayable","type":"function"}]