Contract 0x1b8eb3dca429410074d3dda3e3608c42fa75d02c 1

 

Contract Overview

Balance:
0 MATIC

MATIC Value:
$0.00

Token:
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x2c0dc8dc2b23be6e8a170b5b063e5fd0fead45bf6dec836ea9e6e87e29ba32c1Send New Message211380342021-11-08 17:51:18240 days 5 hrs ago0x40f237eb44581c79ef4a2231912afd8978e317b3 IN  0x1b8eb3dca429410074d3dda3e3608c42fa75d02c0 MATIC0.00539721633
0xbc194dcf4a01c44fd3a6c3625da31a2f86ccb1e210464193a8e571f3ffb7e96dRegister Topic211378772021-11-08 17:45:56240 days 5 hrs ago0x40f237eb44581c79ef4a2231912afd8978e317b3 IN  0x1b8eb3dca429410074d3dda3e3608c42fa75d02c0 MATIC0.0034323630
0x336c78930667b7ba3eb2c11515f1abb8a39d3fb99ef132674beeb5918e40077e0x60806040210866292021-11-07 10:36:59241 days 12 hrs ago0x8caa7421b5721f1377605af36df0f91d5f200975 IN  Create: Announcer0 MATIC0.0222199830
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Announcer

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 2000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 1 : Announcer.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.6;

/// @title Public on-chain announcements for teams
/// @author Jorge A. Cortés - cortesja.com

contract Announcer {

    struct Topic {
        string name;
        address creator;
        address admin;
        mapping (address => bool) writers;
        string lastMessage;
    }
    uint256 public numTopics;
    mapping (uint256 => Topic) public topics;

    event MessageSent(uint256 indexed topic, address indexed from, string message);
    event NewTopic(uint256 indexed topic, address indexed creator, string name);
    event NewAdmin(uint256 indexed topic, address indexed admin);
    event NewWriter(uint256 indexed topic, address indexed writer);
    event RemovedWriter(uint256 indexed topic, address indexed writer);

    constructor() {} // solhint-disable-line no-empty-blocks

    /// Checks that the caller is a registered admin
    modifier onlyAdmin(uint256 topic) {
        require(
            msg.sender == topics[topic].admin,
            "Only topic admin allowed"
        );
        _;
    }

    /// Checks that the caller is a registered writer or admin
    modifier onlyTeam(uint256 topic) {
        require(
            msg.sender == topics[topic].admin || 
            true == topics[topic].writers[msg.sender],
            "Only topic admin or writers"
        );
        _;
    }

    modifier notEmpty(string calldata message) {
        require(bytes(message).length > 0, "Message cannot be empty");
        _;
    }

    /// Creates a new topic and the creator becomes topic admin
    function registerTopic(string memory name) external returns (uint256) {
        uint256 newTopic = numTopics;
        topics[numTopics].creator = msg.sender;
        topics[numTopics].admin = msg.sender;
        topics[numTopics].name = name;
        numTopics++;
        emit NewTopic(newTopic, msg.sender, name);
        return newTopic;
    }

    /// Transfer administration rights from one address to another
    function adminTransfer(uint256 topic, address newAdmin) external onlyAdmin(topic) {
        topics[topic].admin = newAdmin;
        emit NewAdmin(topic, newAdmin);
    }

    /// Leaves a topic without admin forever
    function adminResign(uint256 topic) external onlyAdmin(topic) {
        topics[topic].admin = address(0);
        emit NewAdmin(topic, address(0));
    }

    /// Adds a writer to the topic
    function addTopicWriter(uint256 topic, address writer) external onlyAdmin(topic) {
        topics[topic].writers[writer] = true;
        emit NewWriter(topic, writer);
    }

    /// Removes a writer to the topic
    function removeTopicWriter(uint256 topic, address writer) external onlyAdmin(topic) {
        topics[topic].writers[writer] = false;
        emit RemovedWriter(topic, writer);
    }

    /// Sends a new message to the topic and stores it.
    function sendNewMessage(uint256 topic, string calldata message) external onlyTeam(topic) notEmpty(message) {
        /// Store last message for easy quering
        topics[topic].lastMessage = message;
        emit MessageSent(topic, msg.sender, message);
    }

    /// Checks if an address is writer of a topic
    function isTopicWriter(uint256 topic, address writer) public view returns (bool) {
        return topics[topic].writers[writer];
    }

}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 2000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"topic","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"MessageSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"topic","type":"uint256"},{"indexed":true,"internalType":"address","name":"admin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"topic","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"NewTopic","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"topic","type":"uint256"},{"indexed":true,"internalType":"address","name":"writer","type":"address"}],"name":"NewWriter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"topic","type":"uint256"},{"indexed":true,"internalType":"address","name":"writer","type":"address"}],"name":"RemovedWriter","type":"event"},{"inputs":[{"internalType":"uint256","name":"topic","type":"uint256"},{"internalType":"address","name":"writer","type":"address"}],"name":"addTopicWriter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"topic","type":"uint256"}],"name":"adminResign","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"topic","type":"uint256"},{"internalType":"address","name":"newAdmin","type":"address"}],"name":"adminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"topic","type":"uint256"},{"internalType":"address","name":"writer","type":"address"}],"name":"isTopicWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numTopics","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"registerTopic","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"topic","type":"uint256"},{"internalType":"address","name":"writer","type":"address"}],"name":"removeTopicWriter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"topic","type":"uint256"},{"internalType":"string","name":"message","type":"string"}],"name":"sendNewMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"topics","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"string","name":"lastMessage","type":"string"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50610c72806100206000396000f3fe608060405234801561001057600080fd5b50600436106100a35760003560e01c8063749c49ce11610076578063af5c468d1161005b578063af5c468d14610139578063c107dedf1461014c578063e90bc3c21461019957600080fd5b8063749c49ce1461011d578063a29092ed1461013057600080fd5b80630483fc5e146100a857806318d9adab146100bd57806354ac2136146100e95780636926b3e7146100fc575b600080fd5b6100bb6100b6366004610a0f565b6101ac565b005b6100d06100cb3660046109f6565b610286565b6040516100e09493929190610b5d565b60405180910390f35b6100bb6100f7366004610a0f565b6103d0565b61010f61010a366004610945565b61049f565b6040519081526020016100e0565b6100bb61012b366004610a4b565b61055c565b61010f60005481565b6100bb6101473660046109f6565b6106aa565b61018961015a366004610a0f565b60008281526001602090815260408083206001600160a01b038516845260030190915290205460ff1692915050565b60405190151581526020016100e0565b6100bb6101a7366004610a0f565b61076e565b60008281526001602052604090206002015482906001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920746f7069632061646d696e20616c6c6f776564000000000000000060448201526064015b60405180910390fd5b600083815260016020526040808220600201805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386169081179091559051909185917f2eb98f50e80ce2c2f5398f33a6dec15dad669f98d3d51c7e434389a4a1a20b079190a3505050565b6001602052600090815260409020805481906102a190610ba4565b80601f01602080910402602001604051908101604052809291908181526020018280546102cd90610ba4565b801561031a5780601f106102ef5761010080835404028352916020019161031a565b820191906000526020600020905b8154815290600101906020018083116102fd57829003601f168201915b5050506001840154600285015460048601805495966001600160a01b039384169692909316945091925061034d90610ba4565b80601f016020809104026020016040519081016040528092919081815260200182805461037990610ba4565b80156103c65780601f1061039b576101008083540402835291602001916103c6565b820191906000526020600020905b8154815290600101906020018083116103a957829003601f168201915b5050505050905084565b60008281526001602052604090206002015482906001600160a01b0316331461043b5760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920746f7069632061646d696e20616c6c6f77656400000000000000006044820152606401610213565b60008381526001602081815260408084206001600160a01b0387168086526003909101909252808420805460ff19169093179092559051909185917f87facfa8fa865e7297d194df3864b426336645baab527d92c3adcb1cef92884d9190a3505050565b6000805480825260016020818152604080852090920180543373ffffffffffffffffffffffffffffffffffffffff19918216811790925585548652838620600201805490911690911790558354845290832084516104ff92860190610838565b5060008054908061050f83610bdf565b9190505550336001600160a01b0316817f22e8f83ca6aad8b5a1276ae5a578c31e7d05f2208852f699c2a4b3286014ad638560405161054e9190610b43565b60405180910390a392915050565b60008381526001602052604090206002015483906001600160a01b03163314806105a6575060008181526001602081815260408084203385526003019091529091205460ff161515145b6105f25760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c7920746f7069632061646d696e206f72207772697465727300000000006044820152606401610213565b8282806106415760405162461bcd60e51b815260206004820152601760248201527f4d6573736167652063616e6e6f7420626520656d7074790000000000000000006044820152606401610213565b600086815260016020526040902061065d9060040186866108bc565b50336001600160a01b0316867fa758af4732a8088ab75915c760fabb11b22db520c32f4ee5cdc6651c268d3afa878760405161069a929190610b14565b60405180910390a3505050505050565b60008181526001602052604090206002015481906001600160a01b031633146107155760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920746f7069632061646d696e20616c6c6f77656400000000000000006044820152606401610213565b600082815260016020526040808220600201805473ffffffffffffffffffffffffffffffffffffffff191690555183907f2eb98f50e80ce2c2f5398f33a6dec15dad669f98d3d51c7e434389a4a1a20b07908390a35050565b60008281526001602052604090206002015482906001600160a01b031633146107d95760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920746f7069632061646d696e20616c6c6f77656400000000000000006044820152606401610213565b60008381526001602090815260408083206001600160a01b0386168085526003909101909252808320805460ff1916905551909185917ffe4313e6ec1247eaa14646c711ac096753e497002df5fe50ea41114b42821b5b9190a3505050565b82805461084490610ba4565b90600052602060002090601f01602090048101928261086657600085556108ac565b82601f1061087f57805160ff19168380011785556108ac565b828001600101855582156108ac579182015b828111156108ac578251825591602001919060010190610891565b506108b8929150610930565b5090565b8280546108c890610ba4565b90600052602060002090601f0160209004810192826108ea57600085556108ac565b82601f106109035782800160ff198235161785556108ac565b828001600101855582156108ac579182015b828111156108ac578235825591602001919060010190610915565b5b808211156108b85760008155600101610931565b60006020828403121561095757600080fd5b813567ffffffffffffffff8082111561096f57600080fd5b818401915084601f83011261098357600080fd5b81358181111561099557610995610c26565b604051601f8201601f19908116603f011681019083821181831017156109bd576109bd610c26565b816040528281528760208487010111156109d657600080fd5b826020860160208301376000928101602001929092525095945050505050565b600060208284031215610a0857600080fd5b5035919050565b60008060408385031215610a2257600080fd5b8235915060208301356001600160a01b0381168114610a4057600080fd5b809150509250929050565b600080600060408486031215610a6057600080fd5b83359250602084013567ffffffffffffffff80821115610a7f57600080fd5b818601915086601f830112610a9357600080fd5b813581811115610aa257600080fd5b876020828501011115610ab457600080fd5b6020830194508093505050509250925092565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f01601f19169290920160200192915050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b602081526000610b566020830184610ac7565b9392505050565b608081526000610b706080830187610ac7565b6001600160a01b038681166020850152851660408401528281036060840152610b998185610ac7565b979650505050505050565b600181811c90821680610bb857607f821691505b60208210811415610bd957634e487b7160e01b600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610c1f57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220c0fa3cdc8dd94780d0b5f6da7da43cd07b63a4f50135e158f868c8000fcc22dd64736f6c63430008060033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.