Verified contractExactMIT
CarnageStill
Address0x5aa325ea1c204dbff7449661604775f7d3bf64a1
- Balance
0 ETH
- Transactions
5
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,358,699
- Creation transaction
- 0xcf46e75a11…a883c461d2
2 files
- src/CarnageStill.solmain5.3 KB
- src/CarnageAdmin.sol1.87 KB
src/CarnageStill.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
interface IStillAdmin {
function owner() external view returns (address);
function backup() external view returns (address);
function refreshMetadata() external;
function totalMinted() external view returns (uint256);
}
import {CarnageAdmin} from "./CarnageAdmin.sol";
interface IStillStore {
function chunks(bytes32 name) external view returns (address[] memory);
}
interface IStillDerive {
function recipe(address[] calldata shared, address[] calldata dtab, uint256 token, bytes calldata anchor)
external view returns (bytes memory rc, uint256 face, int256[3][16] memory colq);
}
interface IStillBuild {
function mesh(address[] calldata shared, address[] calldata dtab, bytes calldata rc, uint256 face) external view returns (bytes memory);
}
/// The CARNAGE still: each token's picture, drawn on chain from its number - the review-PDF
/// drawing in the pose Jim picked, on its irregular sky lines.
///
/// The drawing is three module contracts (derive, build, draw: together ~50 KB, over the
/// 24 KB a contract may be) called in turn. Their data lives in the collection's
/// CarnageStore as five files: still-shared (geometry tables), still-derive (derivation
/// tables), still-anchors (13 bytes a token: the face anchor), still-picks (1 byte a token:
/// the pose) and still-params (pose table, constants, palette). Modules, store and data
/// can all be replaced by this contract's own owner or backup (CarnageAdmin - not the
/// NFT's, since 2 Nov 2026); every change refreshes marketplaces through the NFT, which
/// can be changed with setNft.
contract CarnageStill is CarnageAdmin {
error NoSuchToken();
error NotAnNft();
event NftSet(address nft);
bytes32 public constant SHARED = "still-shared";
bytes32 public constant DERIVE = "still-derive";
bytes32 public constant ANCHORS = "still-anchors";
bytes32 public constant PICKS = "still-picks";
bytes32 public constant PARAMS = "still-params";
IStillAdmin public nft;
IStillStore public store;
address public derive;
address public build;
address public draw;
constructor(address nft_, address store_, address derive_, address build_, address draw_)
CarnageAdmin(_nftBackup(nft_))
{
nft = IStillAdmin(nft_); store = IStillStore(store_); derive = derive_; build = build_; draw = draw_;
}
modifier onlyAdmin() {
_checkAdmin();
_;
try nft.refreshMetadata() {} catch {}
}
/// Point at a different NFT contract (only used to ask it to refresh marketplaces).
function setNft(address nft_) external onlyAdmin {
if (nft_.code.length == 0) revert NotAnNft();
try IStillAdmin(nft_).totalMinted() returns (uint256) {} catch { revert NotAnNft(); }
nft = IStillAdmin(nft_);
emit NftSet(nft_);
}
function _nftBackup(address nft_) private view returns (address b) {
if (nft_.code.length == 0) return address(0);
try IStillAdmin(nft_).backup() returns (address x) { b = x; } catch {}
}
function setStore(address s) external onlyAdmin { store = IStillStore(s); }
function setModules(address derive_, address build_, address draw_) external onlyAdmin { derive = derive_; build = build_; draw = draw_; }
/// the still for `token`, as SVG text
function svg(uint256 token) external view returns (string memory) {
bytes memory anc = _file(ANCHORS);
if (13 * token + 13 > anc.length) revert NoSuchToken();
bytes memory a = new bytes(13);
for (uint256 i; i < 13; i++) a[i] = anc[13 * token + i];
uint256 pose = uint8(_file(PICKS)[token]);
(int256[] memory PM, int256[] memory K, bytes memory pal) = abi.decode(_file(PARAMS), (int256[], int256[], bytes));
address[] memory sh = store.chunks(SHARED);
address[] memory dt = store.chunks(DERIVE);
(bytes memory rc, uint256 face, int256[3][16] memory colq) = IStillDerive(derive).recipe(sh, dt, token, a);
bytes memory m = IStillBuild(build).mesh(sh, dt, rc, face);
// the drawing's answer is handed straight back: copying ~100 KB of SVG again costs memory gas
bytes memory cd = abi.encodeWithSignature("draw(bytes,int256[3][16],uint256,uint256,int256[],int256[],bytes)", m, colq, token, pose, PM, K, pal);
address d = draw;
assembly {
let ok := staticcall(gas(), d, add(cd, 32), mload(cd), 0, 0)
let p := mload(0x40)
returndatacopy(p, 0, returndatasize())
if iszero(ok) { revert(p, returndatasize()) }
return(p, returndatasize())
}
}
function _file(bytes32 name) internal view returns (bytes memory b) {
address[] memory c = store.chunks(name);
uint256 total;
for (uint256 i; i < c.length; i++) total += c[i].code.length - 1;
b = new bytes(total);
assembly ("memory-safe") {
let d := add(b, 32)
for { let i := 0 } lt(i, mload(c)) { i := add(i, 1) } {
let x := mload(add(add(c, 32), shl(5, i)))
let n := sub(extcodesize(x), 1)
extcodecopy(x, d, 1, n)
d := add(d, n)
}
}
}
}
src/CarnageAdmin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
/// Owner + backup for the collection's supporting contracts (store, renderer, still).
/// Each has its OWN owner rather than asking the NFT, so the NFT can be replaced or
/// re-pointed without these contracts losing their admin (Jim, 2 Nov 2026).
/// - owner: set to the deployer; changed by a two-step transfer (the new owner must
/// accept, so a typo cannot lose the contract)
/// - backup: a second wallet with the same admin rights, set by the owner
abstract contract CarnageAdmin {
error NotAdmin();
error NotOwner();
error NotPendingOwner();
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event BackupSet(address backup);
address public owner;
address public pendingOwner;
address public backup;
constructor(address backup_) {
owner = msg.sender;
backup = backup_;
emit OwnershipTransferred(address(0), msg.sender);
emit BackupSet(backup_);
}
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwner();
_;
}
function _checkAdmin() internal view {
if (msg.sender != owner && msg.sender != backup) revert NotAdmin();
}
function setBackup(address backup_) external onlyOwner {
backup = backup_;
emit BackupSet(backup_);
}
function transferOwnership(address newOwner) external onlyOwner {
pendingOwner = newOwner;
emit OwnershipTransferStarted(owner, newOwner);
}
function acceptOwnership() external {
if (msg.sender != pendingOwner) revert NotPendingOwner();
emit OwnershipTransferred(owner, msg.sender);
owner = msg.sender;
pendingOwner = address(0);
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.