Skip to content
Verified contractExactMIT

AnnouncementRegistry

Address0x2d75afc0cdf502e4381dc0b23327bfed358ba43a
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
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,350,850
Creation transaction
0x7cc4e9141e…d5ff1d6e88

src/AnnouncementRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/// @title AnnouncementRegistry
interface ICreatorAuthority {
    function currentCreatorOf(address token) external view returns (address currentCreator);
}

/// @notice Optional, zero-live-roles creator announcements feed. The factory registers canonical launch tokens,
///         while creator authorization is resolved dynamically so rights transfers require no registry update.
contract AnnouncementRegistry {
    address public immutable factory;

    mapping(address token => bool registered) public isTokenRegistered;
    mapping(address token => mapping(bytes32 announcementId => bool used)) public isAnnouncementIdUsed;

    error NotFactory();
    error NotCreator();
    error AlreadyRegistered();
    error IdAlreadyUsed();
    error ZeroAddress();

    event TokenRegistered(address indexed token);
    event AnnouncementPosted(
        address indexed token,
        address indexed creator,
        bytes32 indexed announcementId,
        string description,
        string announcementURI
    );

    constructor(address factoryAddress) {
        if (factoryAddress == address(0) || factoryAddress.code.length == 0) revert ZeroAddress();
        factory = factoryAddress;
    }

    function registerToken(address token) external {
        if (msg.sender != factory) revert NotFactory();
        if (token == address(0)) revert ZeroAddress();
        if (isTokenRegistered[token]) revert AlreadyRegistered();
        isTokenRegistered[token] = true;
        emit TokenRegistered(token);
    }

    function postAnnouncement(
        address token,
        bytes32 announcementId,
        string calldata description,
        string calldata announcementURI
    ) external {
        if (!isTokenRegistered[token] || msg.sender != ICreatorAuthority(factory).currentCreatorOf(token)) {
            revert NotCreator();
        }
        if (isAnnouncementIdUsed[token][announcementId]) revert IdAlreadyUsed();
        isAnnouncementIdUsed[token][announcementId] = true;
        emit AnnouncementPosted(token, msg.sender, announcementId, description, announcementURI);
    }
}
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/",
    "base-std/=lib/base-std/src/",
    "base-std-test/=lib/base-std/test/",
    "v4-core/=lib/v4-core/",
    "@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
    "solmate/=lib/v4-core/lib/solmate/",
    "ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
    "@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
    "hardhat/=lib/v4-core/node_modules/hardhat/",
    "openzeppelin-contracts/=lib/v4-core/lib/openzeppelin-contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.