Contract detail
HellboxRarityLedger
Live Robinhood Chain account facts for 0xeeed0550…95c92d69 with at least 10 observed transactions. The history total is updating as indexing continues.
- Address type
- Smart contract
- Transactions
- 10+ observed
- First indexed block
- #63291914
- Latest indexed block
- #63292440
- History coverage
- Recent activity available; total is catching up
- Emitted events
- 3
- Verification
- Verified
- Compiler
- 0.8.36+commit.8a079791
- Verification match
- exact
- Creation transaction
- 0xa44d6745…4443eb34
- Created at block
- #63291914
- Language
- Solidity
- EVM version
- shanghai
- License
- MIT
- Compiler optimization
- Enabled · 200 runs
- Deployed bytecode hash
- 0xfba48cdca70ef3af79337d26683f7e0b94b226e61a02cb4b5d123f5f00755ec7
Related activity
Transactions
Verified contract
Contract source code
// SPDX-License-Identifier: MIT
pragma solidity 0.8.36;
import {Ownable, Ownable2Step} from "openzeppelin-contracts/contracts/access/Ownable2Step.sol";
import {IHellboxLifecycleSink} from "./interfaces/IHellboxLifecycleSink.sol";
import {HellboxRarityMath} from "./lifecycle/HellboxRarityMath.sol";
import {HellboxBirthPolicy} from "./HellboxBirthPolicy.sol";
/// @title HellboxRarityLedger
/// @notice The master rarity list's on-chain inputs (Copy Lifecycle v6, B4 /
/// B16): global survivor counts per mark, per defect and per exact
/// pair across every registered chain, the add-only trait
/// vocabulary, the registry of pool-eligible titles with their
/// committed inventories, and the canonical rarity formula as pure
/// views. No money lives here. Counts move only through the two
/// movers the owner binds once: the holders pool (PulseChain mints
/// and burns, attested remote burns) and the attestation gateway
/// (remote INVENTORY reports), each bounded by the title's committed
/// inventory so no report can invent copies.
/// @dev Separate from the pool so the counting logic is small, auditable on
/// its own, and readable by anyone re-deriving the master list.
contract HellboxRarityLedger is Ownable2Step {
using HellboxRarityMath for HellboxBirthPolicy.ScarcityFacts;
uint8 public constant AXIS_MARK = 0;
uint8 public constant AXIS_DEFECT = 1;
uint8 public constant AXIS_PAIR = 2;
uint8 public constant MOVE_MINT = 1;
uint8 public constant MOVE_BURN = 2;
uint8 public constant MOVE_INVENTORY = 3;
uint256 public immutable homeChainId;
/// @notice House print-run reference (216) and the bottle scale (1e18).
uint256 public immutable S_REF;
uint256 public immutable BOTTLE_SCALE;
struct Title {
bool registered;
uint32 n0;
uint32 minted;
bytes32 configHash;
uint64 inventorySeq;
}
/// @dev One cumulative count for one class of a remote title
/// (axis 0 mark, 1 defect, 2 pair with `code = pairKey`).
struct InventoryCount {
uint8 axis;
bytes32 code;
uint32 mintedCumulative;
}
uint256 public globalSupply;
mapping(uint8 axis => mapping(bytes32 code => uint256)) public globalCount;
mapping(bytes32 pairKey => uint256) public globalPair;
mapping(uint256 chainId => uint256) public chainSupply;
mapping(uint8 axis => mapping(bytes32 code => bool)) public validCode;
uint32 public vocabularyVersion;
mapping(uint256 chainId => mapping(address publication => Title)) internal _titles;
mapping(uint256 chainId => mapping(address publication => mapping(uint8 axis => mapping(bytes32 code => uint32))))
public titleConfigured;
mapping(uint256 chainId => mapping(address publication => mapping(uint8 axis => mapping(bytes32 code => uint32))))
public titleMinted;
address public pool;
address public gateway;
event TraitCodeAdded(uint8 axis, bytes32 code, uint32 vocabularyVersion);
event PublicationRegistered(uint256 indexed chainId, address indexed publication, bytes32 configHash, uint32 n0);
event GlobalCountsMoved(
uint8 cause, uint256 indexed chainId, address indexed publication, bytes32 mark, bytes32 defect, int256 delta
);
event MoversSet(address pool, address gateway);
error OwnershipRenunciationDisabled();
error OnlyPool(address caller);
error OnlyGateway(address caller);
error InvalidAxis(uint8 axis);
error UnknownTraitCode(uint8 axis, bytes32 code);
error CodeAlreadyValid(uint8 axis, bytes32 code);
error TitleAlreadyRegistered(uint256 chainId, address publication);
error UnregisteredTitle(uint256 chainId, address publication);
error RemoteChainOnly(uint256 chainId);
error InvalidConfiguredTotal();
error InventoryInconsistent(uint256 chainId, address publication);
error InventoryOutOfBounds(uint256 chainId, address publication, uint8 axis, bytes32 code);
error CountUnderflow(uint256 chainId, address publication);
error SeqReplay(uint64 expected, uint64 got);
constructor(address owner_, uint256 sRef, uint256 bottleScale) Ownable(owner_) {
homeChainId = block.chainid;
S_REF = sRef;
BOTTLE_SCALE = bottleScale;
}
function renounceOwnership() public view override onlyOwner {
revert OwnershipRenunciationDisabled();
}
/// @notice Binds the two movers. Set once at deploy; changing them is an
/// owner action disclosed in A6.
function setMovers(address pool_, address gateway_) external onlyOwner {
pool = pool_;
gateway = gateway_;
emit MoversSet(pool_, gateway_);
}
// ---------------------------------------------------------------------
// Vocabulary (add-only)
// ---------------------------------------------------------------------
function addTraitCode(uint8 axis, bytes32 code) external onlyOwner {
if (axis > AXIS_DEFECT) {
revert InvalidAxis(axis);
}
if (code == bytes32(0) || validCode[axis][code]) {
revert CodeAlreadyValid(axis, code);
}
validCode[axis][code] = true;
++vocabularyVersion;
emit TraitCodeAdded(axis, code, vocabularyVersion);
}
// ---------------------------------------------------------------------
// Title registration
// ---------------------------------------------------------------------
/// @notice Pool only (the pool checks the PulseChain factory is calling
/// it at publish): registers a pool-eligible home title.
function registerPublication(
address publication,
uint32 configuredTotal,
IHellboxLifecycleSink.InventoryEntry[] calldata inventory
) external {
_onlyPool();
_registerTitle(homeChainId, publication, bytes32(0), configuredTotal, inventory);
}
/// @notice Owner: mirrors a title published on another chain. Append-only.
function registerRemotePublication(
uint256 chainId,
address publication,
bytes32 configHash,
uint32 configuredTotal,
IHellboxLifecycleSink.InventoryEntry[] calldata inventory
) external onlyOwner {
if (chainId == homeChainId) {
revert RemoteChainOnly(chainId);
}
_registerTitle(chainId, publication, configHash, configuredTotal, inventory);
}
function _registerTitle(
uint256 chainId,
address publication,
bytes32 configHash,
uint32 configuredTotal,
IHellboxLifecycleSink.InventoryEntry[] calldata inventory
) internal {
Title storage t = _titles[chainId][publication];
if (t.registered) {
revert TitleAlreadyRegistered(chainId, publication);
}
if (configuredTotal == 0) {
revert InvalidConfiguredTotal();
}
uint256 markSum;
uint256 defectSum;
for (uint256 i = 0; i < inventory.length; ++i) {
IHellboxLifecycleSink.InventoryEntry calldata e = inventory[i];
if (e.axis > AXIS_DEFECT) {
revert InvalidAxis(e.axis);
}
if (!validCode[e.axis][e.code]) {
revert UnknownTraitCode(e.axis, e.code);
}
if (titleConfigured[chainId][publication][e.axis][e.code] != 0) {
revert InventoryInconsistent(chainId, publication);
}
titleConfigured[chainId][publication][e.axis][e.code] = e.count;
if (e.axis == AXIS_MARK) {
markSum += e.count;
} else {
defectSum += e.count;
}
}
if (markSum != configuredTotal || defectSum != configuredTotal) {
revert InventoryInconsistent(chainId, publication);
}
t.registered = true;
t.n0 = configuredTotal;
t.configHash = configHash;
emit PublicationRegistered(chainId, publication, configHash, configuredTotal);
}
function isRegistered(uint256 chainId, address publication) external view returns (bool) {
return _titles[chainId][publication].registered;
}
function titleOf(uint256 chainId, address publication) external view returns (Title memory) {
return _titles[chainId][publication];
}
// ---------------------------------------------------------------------
// Movers
// ---------------------------------------------------------------------
/// @notice Pool only: one PulseChain copy was pressed.
function recordMint(address publication, bytes32 mark, bytes32 defect) external {
_onlyPool();
Title storage t = _titles[homeChainId][publication];
if (!t.registered) {
revert UnregisteredTitle(homeChainId, publication);
}
if (t.minted >= t.n0) {
revert InventoryOutOfBounds(homeChainId, publication, AXIS_PAIR, bytes32(0));
}
++t.minted;
++titleMinted[homeChainId][publication][AXIS_MARK][mark];
++titleMinted[homeChainId][publication][AXIS_DEFECT][defect];
++titleMinted[homeChainId][publication][AXIS_PAIR][HellboxRarityMath.pairKey(mark, defect)];
_move(MOVE_MINT, homeChainId, publication, mark, defect, true);
}
/// @notice Pool only: one copy (any chain) was burned.
function recordBurn(uint256 chainId, address publication, bytes32 mark, bytes32 defect) external {
_onlyPool();
if (!_titles[chainId][publication].registered) {
revert UnregisteredTitle(chainId, publication);
}
_move(MOVE_BURN, chainId, publication, mark, defect, false);
}
/// @notice Gateway only: a remote title's cumulative births. Bounded by
/// the title's committed n0 and per-code counts; mark, defect and
/// pair deltas must each equal the supply delta.
function applyInventory(
uint256 chainId,
address publication,
uint64 seq,
uint32 mintedCumulative,
InventoryCount[] calldata inventory
) external {
if (msg.sender != gateway) {
revert OnlyGateway(msg.sender);
}
if (chainId == homeChainId) {
revert RemoteChainOnly(chainId);
}
Title storage t = _titles[chainId][publication];
if (!t.registered) {
revert UnregisteredTitle(chainId, publication);
}
if (seq != t.inventorySeq + 1) {
revert SeqReplay(t.inventorySeq + 1, seq);
}
t.inventorySeq = seq;
if (mintedCumulative < t.minted || mintedCumulative > t.n0) {
revert InventoryOutOfBounds(chainId, publication, AXIS_PAIR, bytes32(0));
}
uint256 supplyDelta = mintedCumulative - t.minted;
uint256[3] memory deltas; // mark, defect, pair
for (uint256 i = 0; i < inventory.length; ++i) {
deltas[inventory[i].axis > AXIS_PAIR ? 0 : inventory[i].axis] +=
_applyInventoryEntry(chainId, publication, t.n0, inventory[i]);
}
if (deltas[0] != supplyDelta || deltas[1] != supplyDelta || deltas[2] != supplyDelta) {
revert InventoryInconsistent(chainId, publication);
}
t.minted = mintedCumulative;
globalSupply += supplyDelta;
chainSupply[chainId] += supplyDelta;
emit GlobalCountsMoved(MOVE_INVENTORY, chainId, publication, bytes32(0), bytes32(0), int256(supplyDelta));
}
function _applyInventoryEntry(uint256 chainId, address publication, uint32 n0, InventoryCount calldata e)
internal
returns (uint256 delta)
{
uint32 stored = titleMinted[chainId][publication][e.axis][e.code];
if (e.mintedCumulative < stored) {
revert InventoryOutOfBounds(chainId, publication, e.axis, e.code);
}
delta = e.mintedCumulative - stored;
if (e.axis == AXIS_PAIR) {
if (e.mintedCumulative > n0) {
revert InventoryOutOfBounds(chainId, publication, e.axis, e.code);
}
globalPair[e.code] += delta;
} else if (e.axis <= AXIS_DEFECT) {
if (!validCode[e.axis][e.code] || e.mintedCumulative > titleConfigured[chainId][publication][e.axis][e.code]) {
revert InventoryOutOfBounds(chainId, publication, e.axis, e.code);
}
globalCount[e.axis][e.code] += delta;
} else {
revert InvalidAxis(e.axis);
}
titleMinted[chainId][publication][e.axis][e.code] = e.mintedCumulative;
}
function _move(uint8 cause, uint256 chainId, address publication, bytes32 mark, bytes32 defect, bool up) internal {
bytes32 pair = HellboxRarityMath.pairKey(mark, defect);
if (up) {
++globalSupply;
++globalCount[AXIS_MARK][mark];
++globalCount[AXIS_DEFECT][defect];
++globalPair[pair];
++chainSupply[chainId];
} else {
if (
globalSupply == 0 || globalCount[AXIS_MARK][mark] == 0 || globalCount[AXIS_DEFECT][defect] == 0
|| globalPair[pair] == 0 || chainSupply[chainId] == 0
) {
revert CountUnderflow(chainId, publication);
}
--globalSupply;
--globalCount[AXIS_MARK][mark];
--globalCount[AXIS_DEFECT][defect];
--globalPair[pair];
--chainSupply[chainId];
}
emit GlobalCountsMoved(cause, chainId, publication, mark, defect, up ? int256(1) : int256(-1));
}
function _onlyPool() internal view {
if (msg.sender != pool) {
revert OnlyPool(msg.sender);
}
}
// ---------------------------------------------------------------------
// Canonical formula
// ---------------------------------------------------------------------
/// @notice Global rarity of a copy with these facts against the live counts.
function rhoOf(HellboxBirthPolicy.ScarcityFacts memory f) public view returns (uint256) {
return HellboxRarityMath.rho(
f,
globalSupply,
globalCount[AXIS_MARK][f.mark],
globalCount[AXIS_DEFECT][f.defect],
globalPair[HellboxRarityMath.pairKey(f.mark, f.defect)],
S_REF
);
}
/// @notice The bottle of Spirits a copy of rarity `rhoValue` distills.
function bottleOf(uint256 rhoValue) public view returns (uint256) {
return HellboxRarityMath.bottleProof(rhoValue, BOTTLE_SCALE);
}
/// @notice Pure quotes from explicit inputs (outposts, the D1 cache and
/// third parties compute the same numbers).
function quoteRho(
HellboxBirthPolicy.ScarcityFacts calldata f,
uint256 gSupply,
uint256 gMark,
uint256 gDefect,
uint256 gPair
) external view returns (uint256) {
return HellboxRarityMath.rho(f, gSupply, gMark, gDefect, gPair, S_REF);
}
function quoteBottle(
HellboxBirthPolicy.ScarcityFacts calldata f,
uint256 gSupply,
uint256 gMark,
uint256 gDefect,
uint256 gPair
) external view returns (uint256) {
return HellboxRarityMath.bottleProof(HellboxRarityMath.rho(f, gSupply, gMark, gDefect, gPair, S_REF), BOTTLE_SCALE);
}
}