Verified contractExactMIT
LostFreedom
Address0x0e5bbbcf3bb76646bf8474d84292ad4af83e7958
- Balance
0 ETH
- Transactions
281
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,821,791
- Creation transaction
- 0xd23e89d7bc…eb68a24275
contracts/src/LostFreedom.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title Lost Freedom
/// @author 1980k
/// @notice 35 fully on-chain 1/1s.
///
/// Source art below is visible on Etherscan after verify. Not in tokenURI.
//////////////////////////////////////////////////////////////////////////////////////////
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━/Y0U/4R3/7H3/4LG0/━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ //
// ┃O |___| O |___| O |___| ^^=*~^/+= |___| O |___| O |___| O |___| O |___| O |___| O ┃ //
// ┃|\___|_/|\___|_//~=+_*=|-•••••••=_+///-|+*___|_/|\___|_/|\___|_/|\___|_/|\___|_/|\┃ //
// ┃ \__^|\/=-^+^/░░ \__|/░░ /░░░░░░░░__|_/░░░░░░░░//░░_|__/░░_/░░░░░░░░|__/ \__|__/ \┃ //
// ┃*-=/~•••••••• ▒▒_/▒▒O ▒▒__▒▒/////__ O ///_▒▒//_|_▒▒ O _|▒▒_ ▒▒///// O _|___ O _|__┃ //
// ┃•••••••••••••\▓▓__▓▓|\▓▓__▓▓|\|___|/|\|___▓▓|\|__▓▓/|\|_▓▓|/▓▓|___|/|\|___|/|\|___┃ //
// ┃•••••••••••••\██_|██ \██_|██████_|_/ \___|██ \___█████████_/██████_/ \___|_/ \___|┃ //
// ┃=|+^\=-=••+_^_▓▓|_▓▓|_▓▓|_▓▓///_|___|___|_▓▓|___|▓▓////_▓▓__▓▓///___|___|___|___|_┃ //
// ┃O _|___==++|__▒▒O ▒▒__▒▒O ▒▒___ O _|___ O ▒▒___ O▒▒|___ ▒▒_|▒▒_ O _|___ O _|___ O ┃ //
// ┃|\|___|/|\|__/|░░░/_░░░/|\░░░░░░░░|___|/|\░░__|/|░░___|/░░|_░░░░░░░░__|/|\|___|/|\┃ //
// ┃ \___|_/ \___|///\_///_/ ////////\___|_/ //__|_///___|_//\_////////__|_/ \___|_/ \┃ //
// ┃|___|___|___|___|___|___|___|___|___|___|___|___|___|___|/__|___|___|___|___|___|_┃ //
// ┃___ O _|___ O _|___ O _|___ O _|___ O _~/\|\O =\^~~ O+\+**+*/\^+=-_ O _|___ O _|__┃ //
// ┃__|/|┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\|^__┃ //
// ┃=^+_=┃//O\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//O\\ ┃-|-~^┃ //
// ┃•••••┃━━━━━━━━━━━━━━━━━━━━━━━━━┃ ALWAYS WATCHING ┃━━━━━━━━━━━━━━━━━━━━━━━━━━┃•••••┃ //
// ┃•••••┃ O O O O O O O O O O O O O O O O ┃••••+┃ //
// ┃^+~//┃ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ ┃_+-*\┃ //
// ┃_|_ O┃ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ┃\___|┃ //
// ┃|__/|┃ O O O O O O O O O O O O O O ┃\__|_┃ //
// ┃___/ ┃ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ ┃\_|__┃ //
// ┃__|__┃ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ┃_|___┃ //
// ┃_|_ O┃ O O O O O O O O O O O O O O O O ┃ ___|┃ //
// ┃|__/|┃ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ /|\ ┃\__|_┃ //
// ┃___/ ┃ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ┃\_|__┃ //
// ┃__|__┃━━━━━━━━━━━━━━━━━━━━━━━━━┃ YOU ARE THE ALGO ┃━━━━━━━━━━━━━━━━━━━━━━━━━┃_|___┃ //
// ┃O ___┃\\O//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\O// ┃|_ O ┃ //
// ┃|\__|┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛__/|\┃ //
// ┃ \_|___/ \_|___/ \_|___/ \_|___/ \_|___/ \_|___/ \_|___/ \_|___/ \_|___/ \_|___/ \┃ //
// ┃__|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___┃ //
// ┃_|_ O ___|/░░░░░░░░ O/░░░░░░░░__/░░░░░░░_|/░░░░░░░░ O/░░_|_ O _/░░░░░░░░_|_ O ___|┃ //
// ┃|__/|\__|__▒▒////_▒▒|\▒▒/////\_/▒▒////_▒▒__▒▒////_▒▒|\▒▒|__/|\__▒▒/////_|__/|\__|_┃ //
// ┃___/ \_|___▓▓\_|__▓▓ \▓▓___/ \_|▓▓_/ \_▓▓__▓▓\_|__▓▓ \▓▓___/ \_|▓▓_/ \_|___/ \_|__┃ //
// ┃__|___|___|████████___██████__|_██|___|██_|████████___██__|___|_██████|___|___|___┃ //
// ┃_|_ O __ O ▓▓/////_ O ▓▓/// O O▓▓ O _▓▓|_▓▓/////_ O▓▓ O O __▓▓/// __ O O _^*┃ //
// ┃O O\__/|\▒▒|\_|__/|\▒▒|__/|\/|▒▒/|\\_▒▒__▒▒\__|__//|▒▒/|\/|\__▒▒_/|\__\|_*=-*^••┃ //
// ┃|\ /|\_|/ \░░ \|___/ \░░░░░░░░//\░░░░░░░___░░\_|___// ░░░░░░░░_|░░░░░░░░••••••••••┃ //
// ┃ \ / \| O //__| O |__////////_| /////// O //__| O |__////////_|//////// +=|^|_/=_*┃ //
// ┃ O O\__^^|*\|•••••••••••••••••••••••-=|//^^~*\_~^\-++_~_|_/|\___|_/|O O ┃ //
// ┃\\ /|\ /|\__|__/ ~^+\\/~\•-\*++••••\/=^_~*__|__/ \__|__/ \__|__/ \__|__//|\ /|\ //┃ //
// ┃\\ / \ / \_|___|___|___|+|+|__^_-+_____|___|___|___|___|___|___|___|___|/ \ / \ //┃ //
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━/Y0U/4R3/7H3/4LG0/━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ //
//////////////////////////////////////////////////////////////////////////////////////////
contract LostFreedom {
uint256 public constant MAX = 35;
uint256 public constant CHUNK_MAX = 20_000;
string public constant name = "Lost Freedom";
string public constant symbol = "LF";
address public owner;
uint256 public mintPrice;
bool public mintOpen;
bool public stored;
mapping(uint256 => address) public ownerOf;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => bool)) public isApprovedForAll;
mapping(uint256 => address) public getApproved;
mapping(address => bool) public minted;
mapping(uint256 => address[]) internal _svg;
mapping(uint256 => address[]) internal _html;
mapping(uint256 => string) internal _tokenName;
mapping(uint256 => string) internal _description;
mapping(uint256 => string) internal _attributesJson;
string public collectionAbout =
"Lost Freedom is a reflection on modern existence. Privacy dissolves, identity is commodified, security becomes illusion, and desire turns into the ultimate form of control.";
error NotOwner();
error BadId();
error AlreadyMinted();
error NotStored();
error AlreadyFrozen();
error Incomplete();
error MintClosed();
error WrongPrice();
error OnePerWallet();
error WriteFailed();
error ChunkTooBig();
error NotAuthorized();
error ZeroAddress();
error UnsafeRecipient();
event Transfer(address indexed from, address indexed to, uint256 indexed id);
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event MetaStored(uint256 indexed id);
event SvgAppended(uint256 indexed id, uint256 chunks);
event HtmlAppended(uint256 indexed id, uint256 chunks);
event MintPriceSet(uint256 price);
event MintOpenSet(bool open);
event Frozen();
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
modifier live() {
if (stored) revert AlreadyFrozen();
_;
}
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
function transferOwnership(address next) external onlyOwner {
if (next == address(0)) revert ZeroAddress();
emit OwnershipTransferred(owner, next);
owner = next;
}
function storeMeta(
uint256 id,
string calldata tokenName,
string calldata description,
string calldata attributesJson
) external onlyOwner live {
_ok(id);
_tokenName[id] = tokenName;
_description[id] = description;
_attributesJson[id] = attributesJson;
emit MetaStored(id);
}
function resetSvg(uint256 id) external onlyOwner live {
_ok(id);
delete _svg[id];
}
function resetHtml(uint256 id) external onlyOwner live {
_ok(id);
delete _html[id];
}
function appendSvg(uint256 id, bytes calldata chunk) external onlyOwner live {
_ok(id);
_svg[id].push(_write(chunk));
emit SvgAppended(id, _svg[id].length);
}
function appendHtml(uint256 id, bytes calldata chunk) external onlyOwner live {
_ok(id);
_html[id].push(_write(chunk));
emit HtmlAppended(id, _html[id].length);
}
function freezeStorage() external onlyOwner live {
for (uint256 id = 1; id <= MAX; ++id) {
if (!ready(id)) revert Incomplete();
}
stored = true;
emit Frozen();
}
function setMintPrice(uint256 price) external onlyOwner {
mintPrice = price;
emit MintPriceSet(price);
}
function setMintOpen(bool open) external onlyOwner {
mintOpen = open;
emit MintOpenSet(open);
}
function withdraw(address payable to) external onlyOwner {
if (to == address(0)) revert ZeroAddress();
to.transfer(address(this).balance);
}
function mint(uint256 id) external payable {
if (!stored) revert NotStored();
if (!mintOpen) revert MintClosed();
if (minted[msg.sender]) revert OnePerWallet();
if (msg.value != mintPrice) revert WrongPrice();
minted[msg.sender] = true;
_mint(msg.sender, id);
}
function ownerMint(uint256 id, address to) external onlyOwner {
if (!stored) revert NotStored();
_mint(to, id);
}
function approve(address spender, uint256 id) external {
address tokenOwner = ownerOf[id];
if (tokenOwner == address(0)) revert BadId();
if (msg.sender != tokenOwner && !isApprovedForAll[tokenOwner][msg.sender]) {
revert NotAuthorized();
}
getApproved[id] = spender;
emit Approval(tokenOwner, spender, id);
}
function setApprovalForAll(address operator, bool approved) external {
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function transferFrom(address from, address to, uint256 id) public {
_transfer(from, to, id);
}
function safeTransferFrom(address from, address to, uint256 id) external {
_transfer(from, to, id);
_checkOnReceived(from, to, id, "");
}
function safeTransferFrom(address from, address to, uint256 id, bytes calldata data) external {
_transfer(from, to, id);
_checkOnReceived(from, to, id, data);
}
function tokenURI(uint256 id) external view returns (string memory) {
if (ownerOf[id] == address(0)) revert BadId();
return string.concat(
"data:application/json;utf8,",
'{"name":"',
_json(_tokenName[id]),
'","description":"',
_json(_description[id]),
'","animation_url":"data:text/html;charset=utf-8,',
_json(string(_readAll(_html[id]))),
'","background_color":"000000","attributes":',
_attributesJson[id],
"}"
);
}
function tokenHTML(uint256 id) external view returns (string memory) {
_ok(id);
return string(_readAll(_html[id]));
}
function tokenSVG(uint256 id) external view returns (string memory) {
_ok(id);
return string(_readAll(_svg[id]));
}
function ready(uint256 id) public view returns (bool) {
return bytes(_tokenName[id]).length != 0 && _html[id].length != 0;
}
function storedCount() external view returns (uint256 n) {
for (uint256 id = 1; id <= MAX; ++id) {
if (ready(id)) n += 1;
}
}
function htmlChunks(uint256 id) external view returns (uint256) {
return _html[id].length;
}
function svgChunks(uint256 id) external view returns (uint256) {
return _svg[id].length;
}
function supportsInterface(bytes4 id) external pure returns (bool) {
return id == 0x01ffc9a7 || id == 0x80ac58cd || id == 0x5b5e139f;
}
function _mint(address to, uint256 id) internal {
_ok(id);
if (to == address(0)) revert ZeroAddress();
if (ownerOf[id] != address(0)) revert AlreadyMinted();
ownerOf[id] = to;
unchecked {
balanceOf[to] += 1;
}
emit Transfer(address(0), to, id);
}
function _transfer(address from, address to, uint256 id) internal {
if (to == address(0)) revert ZeroAddress();
address tokenOwner = ownerOf[id];
if (tokenOwner == address(0) || tokenOwner != from) revert NotAuthorized();
if (
msg.sender != from
&& getApproved[id] != msg.sender
&& !isApprovedForAll[from][msg.sender]
) revert NotAuthorized();
delete getApproved[id];
ownerOf[id] = to;
unchecked {
balanceOf[from] -= 1;
balanceOf[to] += 1;
}
emit Transfer(from, to, id);
}
function _checkOnReceived(address from, address to, uint256 id, bytes memory data) internal {
if (to.code.length == 0) return;
(bool ok, bytes memory ret) = to.call(
abi.encodeWithSignature(
"onERC721Received(address,address,uint256,bytes)",
msg.sender,
from,
id,
data
)
);
if (!ok || ret.length < 32 || bytes4(ret) != 0x150b7a02) revert UnsafeRecipient();
}
function _ok(uint256 id) internal pure {
if (id < 1 || id > MAX) revert BadId();
}
function _write(bytes calldata data) internal returns (address pointer) {
if (data.length == 0 || data.length > CHUNK_MAX) revert ChunkTooBig();
bytes memory runtime = abi.encodePacked(hex"00", data);
bytes memory creation = abi.encodePacked(
hex"63",
uint32(runtime.length),
hex"80600E6000396000F3",
runtime
);
assembly {
pointer := create(0, add(creation, 32), mload(creation))
}
if (pointer == address(0)) revert WriteFailed();
}
function _read(address pointer) internal view returns (bytes memory data) {
uint256 size;
assembly {
size := extcodesize(pointer)
}
if (size <= 1) return "";
data = new bytes(size - 1);
assembly {
extcodecopy(pointer, add(data, 32), 1, sub(size, 1))
}
}
function _readAll(address[] storage parts) internal view returns (bytes memory out) {
for (uint256 i; i < parts.length; ++i) {
out = bytes.concat(out, _read(parts[i]));
}
}
function _json(string memory s) internal pure returns (string memory) {
bytes memory src = bytes(s);
uint256 extra;
for (uint256 i; i < src.length; ++i) {
bytes1 c = src[i];
if (c == '"' || c == "\\" || c == "\n" || c == "\r" || c == "\t") extra += 1;
}
bytes memory dst = new bytes(src.length + extra);
uint256 j;
for (uint256 i; i < src.length; ++i) {
bytes1 c = src[i];
if (c == '"' || c == "\\") {
dst[j++] = "\\";
dst[j++] = c;
} else if (c == "\n") {
dst[j++] = "\\";
dst[j++] = "n";
} else if (c == "\r") {
dst[j++] = "\\";
dst[j++] = "r";
} else if (c == "\t") {
dst[j++] = "\\";
dst[j++] = "t";
} else {
dst[j++] = c;
}
}
return string(dst);
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=contracts/lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.