Skip to content
Verified contractExactGPL-3.0

X1AdRegistry

Address0xc831bb5372eccd94e755ed61d1c6aebcd7a60773
Balance

0 ETH

 

Transactions

10

 

Compiler

solc 0.8.35

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.35+commit.47b9dedd
Language
solidity
Optimization
No
License
GPL-3.0
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,457,552
Creation transaction
0xf02ec69a62…aa839bb9b3

MEH/X1AdRegistry.sol

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;

interface IX1GenesisController {
    function ownerOf(uint256 tokenId) external view returns (address);
    function isClaimed(uint256 tokenId) external view returns (bool);
    function isGenesis(uint256 tokenId, bytes32[] calldata proof)
        external
        pure
        returns (bool);
    function controllerOf(uint256 tokenId) external view returns (address);
}

/// @title X1 City Ad Registry
/// @notice Before a Genesis Right is claimed, the frozen legacy NFT owner
///         controls its ad. After claim, control follows the transferable X1R.
/// @dev There is no owner, administrator, fee, upgrade, or pause mechanism.
contract X1AdRegistry {
    struct Creative {
        string imageURI;
        string targetURI;
        string headline;
        uint64 updatedAt;
        address publisher;
    }

    uint256 public constant MAX_TOKENS_PER_PUBLISH = 100;
    uint256 public constant MAX_IMAGE_URI_BYTES = 512;
    uint256 public constant MAX_TARGET_URI_BYTES = 512;
    uint256 public constant MAX_HEADLINE_BYTES = 160;

    IX1GenesisController public immutable genesisRights;
    uint256 public creativeCount;

    mapping(uint256 => Creative) public creatives;
    mapping(uint256 => uint256) public creativeOf;

    error NotController(uint256 tokenId);
    error NotGenesisToken(uint256 tokenId);
    error EmptyTokenList();
    error TooManyTokens();
    error FieldTooLong();

    event AdPublished(
        uint256 indexed creativeId,
        address indexed publisher,
        uint256[] tokenIds,
        string imageURI,
        string targetURI,
        string headline
    );
    event AdCleared(uint256 indexed tokenId, address indexed controller);

    constructor(address genesisRights_) {
        require(genesisRights_ != address(0), "rights NFT is zero");
        genesisRights = IX1GenesisController(genesisRights_);
    }

    function controllerOf(uint256 tokenId) public view returns (address) {
        return genesisRights.controllerOf(tokenId);
    }

    function publish(
        uint256[] calldata tokenIds,
        bytes32[][] calldata proofs,
        string calldata imageURI,
        string calldata targetURI,
        string calldata headline
    ) external returns (uint256 creativeId) {
        uint256 count = tokenIds.length;
        if (count == 0) revert EmptyTokenList();
        if (count > MAX_TOKENS_PER_PUBLISH) revert TooManyTokens();
        if (proofs.length != count) revert NotGenesisToken(0);
        if (
            bytes(imageURI).length > MAX_IMAGE_URI_BYTES ||
            bytes(targetURI).length > MAX_TARGET_URI_BYTES ||
            bytes(headline).length > MAX_HEADLINE_BYTES
        ) revert FieldTooLong();

        creativeId = ++creativeCount;
        creatives[creativeId] = Creative({
            imageURI: imageURI,
            targetURI: targetURI,
            headline: headline,
            updatedAt: uint64(block.timestamp),
            publisher: msg.sender
        });

        for (uint256 i; i < count; ++i) {
            uint256 tokenId = tokenIds[i];
            if (!genesisRights.isGenesis(tokenId, proofs[i])) {
                revert NotGenesisToken(tokenId);
            }
            if (controllerOf(tokenId) != msg.sender) {
                revert NotController(tokenId);
            }
            creativeOf[tokenId] = creativeId;
        }

        emit AdPublished(
            creativeId,
            msg.sender,
            tokenIds,
            imageURI,
            targetURI,
            headline
        );
    }

    function clear(uint256 tokenId, bytes32[] calldata proof) external {
        if (!genesisRights.isGenesis(tokenId, proof)) {
            revert NotGenesisToken(tokenId);
        }
        if (controllerOf(tokenId) != msg.sender) {
            revert NotController(tokenId);
        }
        delete creativeOf[tokenId];
        emit AdCleared(tokenId, msg.sender);
    }

    function adForToken(uint256 tokenId)
        external
        view
        returns (uint256 creativeId, Creative memory creative)
    {
        creativeId = creativeOf[tokenId];
        creative = creatives[creativeId];
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.