文件 1 的 1:HasaquiGlyphs.sol
pragma solidity ^0.8.0;
contract HasaquiGlyphs {
uint256 public glyphCount = 0;
event GlyphCreated(uint256 id, address creator);
function createGlyph() public returns (uint256) {
uint256 newId = glyphCount;
glyphCount++;
emit GlyphCreated(newId, msg.sender);
return newId;
}
function getGlyph(uint256 id) public view returns (string memory) {
require(id < glyphCount, "Glyph does not exist.");
return generateGlyph(id, msg.sender);
}
function generateGlyph(uint256 id, address creator) internal pure returns (string memory) {
bytes memory glyphData;
uint256 baseSeed = uint256(keccak256(abi.encodePacked(id, creator)));
uint256 size = 12;
bytes memory pattern = bytes("hasaqui hasaqui hasaqui ");
for (uint256 i = 0; i < size; i++) {
uint256 seed = uint256(keccak256(abi.encodePacked(baseSeed, i)));
for (uint256 j = 0; j < size; j++) {
uint256 patternIndex = (seed % pattern.length);
glyphData = abi.encodePacked(glyphData, pattern[patternIndex]);
seed /= pattern.length;
}
glyphData = abi.encodePacked(glyphData, "\n");
}
return string(glyphData);
}
}
{
"compilationTarget": {
"HasaquiGlyphs.sol": "HasaquiGlyphs"
},
"evmVersion": "cancun",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}