Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC-3722, which proposes a mechanism for accepting content and tags and publishing them as events.

This article translates, summarizes, and supplements the material linked below.

I have also covered other EIPs.

Overview

Poster is a minimal smart contract for decentralized social media. It accepts two strings, content (the post body) and tag (a label), and emits them in an event together with the sender's address (msg.sender).

It also proposes a standardized, Twitter-like JSON format that allows multiple posts or operations to be submitted in a single post() call.

Application state is intended to be reconstructed off-chain by an indexer that collects and organizes blockchain events.

Motivation

Poster is intended to provide a foundation for decentralized social media.

Using a singleton factory (a mechanism for deploying a contract at the same address across EVM-compatible networks), Poster can be deployed at the same address on most EVM-compatible networks. Any Ethereum account can then submit posts to the Poster contract on those networks, providing a general-purpose foundation for decentralized social applications.

Specification

The Poster contract provides a minimal posting interface.

js
event NewPost(address indexed user, string content, string indexed tag);

This event records a post. The user (sender address) and tag (post label) parameters are indexed to facilitate off-chain filtering. Because tag is a dynamic indexed string, its hash rather than its raw value is stored in the topic. The content field contains the original post body.

js
function post(string calldata content, string calldata tag) public

This function accepts the post body and tag and emits a NewPost event. The calldata data location refers to the read-only input supplied to the contract call, avoiding unnecessary memory copying and reducing gas costs.

ABI

json
[
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "user",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "string",
          "name": "content",
          "type": "string"
        },
        {
          "indexed": true,
          "internalType": "string",
          "name": "tag",
          "type": "string"
        }
      ],
      "name": "NewPost",
      "type": "event"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "content",
          "type": "string"
        },
        {
          "internalType": "string",
          "name": "tag",
          "type": "string"
        }
      ],
      "name": "post",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
]

The ABI (Application Binary Interface) defines the inputs and outputs used by external applications to interact with a contract in JSON format. Poster includes the following entries.

NewPost

  • "anonymous": false
    • The event signature is included as a log topic.
  • "inputs"
    • The type (address or string), name (user, content, or tag), and indexing configuration of each field.
  • "name": "NewPost"
    • Event name.
  • "type": "event"
    • ABI entry type.

post

  • "inputs"
    • Types and names of the function parameters.
  • "name": "post"
    • Function name.
  • "outputs": []
    • No return values.
  • "stateMutability": "nonpayable"
    • The function does not accept Ether.
  • "type": "function"
    • ABI entry type.

Wallets and libraries can use this ABI to encode function calls and decode logs automatically.

Standard JSON Format for Twitter-Like Posts

json
{
  "content": [
    {
      "type": "microblog",
      "text": "this is the first post in a thread"
    },
    {
      "type": "microblog",
      "text": "this is the second post in a thread",
      "replyTo": "this[0]"
    },
    {
      "type": "microblog",
      "text": "this is a reply to some other post",
      "replyTo": "some_post_id"
    },
    {
      "type": "microblog",
      "text": "this is a post with an image",
      "image": "ipfs://ipfs_hash"
    },
    {
      "type": "microblog",
      "text": "this post replaces a previously posted post",
      "edit": "some_post_id"
    },
    {
      "type": "delete",
      "target": "some_post_id"
    },
    {
      "type": "like",
      "target": "some_post_id"
    },
    {
      "type": "repost",
      "target": "some_post_id"
    },
    {
      "type": "follow",
      "target": "some_account"
    },
    {
      "type": "unfollow",
      "target": "some_account"
    },
    {
      "type": "block",
      "target": "some_account"
    },
    {
      "type": "report",
      "target": "some_account or some_post_id"
    },
    {
      "type": "permissions",
      "account": "<account_to_set_permissions>",
      "permissions": {
        "post": true,
        "delete": true,
        "like": true,
        "follow": true,
        "block": true,
        "report": true,
        "permissions": true
      }
    },
    {
      "type": "microblog",
      "text": "This is a post from an account with permissions to post on behalf of another account.",
      "from": "<from_address>"
    }
  ]
}

The proposal defines a JSON format for submitting multiple operations so that an off-chain indexer can reconstruct application state.

  • The root content key contains an array of operation objects.
  • Each object has a type field and additional fields describing the operation.

Posts (microblog)

  • text
    • Post body.
  • replyTo
    • References an entry in the same array using this[index] or an external post ID.
  • image
    • Image URI, such as ipfs://....
  • edit
    • ID of the post being edited.

Other Operations

The operations delete, like, repost, follow, unfollow, block, and report use the target field to identify a post or account.

Permissions (permissions)

  • account
    • Account to which permissions are assigned.
  • permissions
    • Boolean values indicating whether operations such as post and delete are permitted.

Posting on Behalf of Another Account (microblog with from)

  • from
    • Identifies the account on whose behalf the post is made.

By applying these operations in chronological order, an indexer can reconstruct threads, like counts, follow relationships, and other elements of a Twitter-like interface.

Additional Notes

No On-Chain Post IDs

The contract omits state management to avoid unnecessary complexity. Indexers commonly derive IDs from transaction hashes and log indices, so posts can be assigned identifiers off-chain.

Using a String for Content

The proposal prioritizes readability over more compact binary encodings such as CBOR. Human-readable string representations of JSON make content easier to inspect directly through existing interfaces such as Etherscan. More compact encodings would sacrifice readability.

Always Emitting Post Content as an Event

Omitting the event would reduce gas costs but make retrieval and filtering substantially more demanding for indexers. The proposal accepts the additional gas cost to prioritize efficient off-chain reconstruction of application state.

Security

Contract Layer

The minimal implementation limits complexity, although simplicity alone does not guarantee the absence of vulnerabilities.

Application-Layer Validation

When the from field differs from msg.sender, applications must check that a corresponding permissions post from the relevant account authorizes the operation. Unauthorized posts must be treated as invalid.

Data Sanitization

Before displaying or storing post content and tags, applications should validate and sanitize inputs appropriately to prevent XSS and malicious data insertion.

Citation

Auryn Macmillan (@auryn-macmillan), "ERC-3722: Poster [DRAFT]," Ethereum Improvement Proposals, no. 3722, July 2021. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-3722.

Conclusion

ERC-3722 proposes an event-based posting mechanism for content and tags, together with an off-chain model for interpreting social media operations.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

I also publish articles on the following platforms.

https://chaldene.net/