ERC-1129 DAPP announcement standard (Standardised DAPP announcements)
Stagnant · Other · created 2018-05-31
Defines a standard structure and permission system that lets a DAPP or service operator post and remove announcements, such as service shutdowns or migrations, within a contract.
Why it is needed
Without this standard, DAPPs or ERC20-style token services have no common way to inform users of situations such as maintenance, contract replacement, or service shutdown. Because each operator posts announcements on different channels such as Twitter, their official site, or Discord, it is hard for users to know where to check, and if an announcement is deleted or edited there is no way to trace what happened in the past. In particular, there is no mechanism at the contract level to guarantee who has the authority to post announcements, or when and why an announcement was taken down, leaving room for impersonation or opaque operation.
What to implement
struct Announcer{ bool allowedToPost; string name; }: Stores an announcer's posting permission and a human-readable name.struct Announcement{ string author; address authorAddress; string post; }: Stores the author name, author address, and content of each individual announcement.function theNumberOfAnnouncements() public constant returns(uint256 _numberOfAnnouncements): Returns the number of currently active announcements.function readPosts(uint256 _postNumber) public constant returns(string _author, string _post): Returns the announcement at the specified number along with the author's name.function givePostingPermission(address _newAnnouncer, bool _postingPrivileges, string _posterName) public onlyOwner returns(bool success): Grants or revokes announcement posting permission for a specific address and registers the author's name.modifier canPost{ require(posterData[msg.sender].allowedToPost); _; }: Allows the function to execute only if the caller has posting permission.function postAnnouncement(string _message) public canPost: An address with posting permission registers a new announcement.function removeAnnouncement(uint256 _messageNumber, string _removalReason) public: Removes the announcement at the specified number, reorders the remaining ones without leaving an empty slot, and records the reason for removal.event NewAnnouncement(string author, string message): Fires every time a new announcement is registered, announcing the author and content.event RemovedAnnouncement(string author, string message, string reason, address remover);: Fires every time an announcement is removed, announcing the author, content, reason for removal, and the remover's address.
In depth
Announcer struct
allowedToPost is a bool value indicating whether the address has permission to post announcements, and the canPost modifier checks this value. name is a string used to display the author in a human-readable way.
Announcement struct
author stores a human-readable author identifier, authorAddress stores the Ethereum address linked to the author, and post stores the announcement content itself.
Querying the announcement count
theNumberOfAnnouncements is an OPTIONAL function that returns the number of currently active announcements, intended to display information in a UI faster, and it is stated that the same value can also be obtained from the numberOfMessages variable.
Reading announcements
readPosts looks up the announcement corresponding to _postNumber and returns the author name _author together with the content _post.
Managing posting permission
givePostingPermission is restricted to onlyOwner, so only the owner can call it. It grants or revokes permission by setting the _postingPrivileges value for the _newAnnouncer address, and registers that author's human-friendly name via _posterName.
The canPost modifier
Consists of a require statement checking that posterData[msg.sender].allowedToPost is true, and the function body only executes if this condition passes. It is applied to postAnnouncement to block posting from unauthorized addresses.
Posting and removing announcements
postAnnouncement has the canPost modifier applied, so only an authorized address can post a new announcement with the _message content. removeAnnouncement removes the announcement specified by _messageNumber and reorders the mapping so no empty slot remains, with _removalReason informing the user whether the issue was resolved or what the next steps are.
Events and proposal status
NewAnnouncement MUST be emitted whenever a new announcement is created, reporting the author and message, and RemovedAnnouncement MUST be emitted whenever an announcement is removed, recording the author, message, removal reason, and the address that performed the removal. This proposal's status is Stagnant: it was written in 2018 and has not progressed since, remaining a stalled draft.