Skip to content

KeywordChain

Solidity + frontend dApp where each new message must start with the last message’s keyword, and the next keyword is derived from the last word, with validation, pagination, search, custom errors, and reentrancy protection on Sepolia.

SolidityHardhatEVM
Sepolia

Overview

KeywordChain is a blockchain-based message chain where each new message must start with the last message’s keyword, enforcing continuity and a “story-like” flow. The next keyword is extracted from the last word of the new message. It’s implemented as a Solidity smart contract on Sepolia, paired with a frontend that lets users connect a wallet, browse messages with pagination, and submit new entries with client-side validation.


What it demonstrates

  • Constraint-driven onchain data design (prefix rule + last-word keyword derivation)
  • Input validation + custom errors for gas efficiency
  • Pagination + exact-keyword search patterns for onchain message retrieval
  • Full dApp integration: wallet connect → read/write → UI feedback

Design notes (why this matters)

  • Custom errors reduce gas and make failures explicit at the ABI level
  • The 256/32 character caps keep storage predictable and UI consistent
  • Pagination avoids heavy reads and keeps UX responsive onchain
  • Future anti-spam controls fit the public nature of the chain

Contract details

  • Contract: MessageChain
  • Network: Sepolia (Chain ID: 11155111)
  • Address: 0xAD17ee34a3A2b59727C08E992a84a1F160BF21C0
  • Rule: message must start with last message’s keyword
  • Keyword derivation: last word of message
  • Limits:
    • Message length max: 256 chars
    • Keyword length max: 32 chars
    • Keyword charset: alphanumeric

This deployment is on Sepolia (testnet). Data and ETH there are for testing only.


Live demo


Quickstart (repo)

Bash
git clone https://github.com/casaisdev/KeywordChain.git

For install/run/env vars, see the repo README.


Next steps

If I were to evolve KeywordChain further:

  • Add an indexer-backed search layer (fast global keyword search + better UX)
  • Add anti-spam controls for public deployments (rate limits / allowlists / fees)
  • Add clearer UI “next keyword” guidance (show the required keyword prominently)
  • Improve pagination UX (infinite scroll + cached pages)
  • Add richer analytics (messages per keyword, user activity, trend keywords)