Skip to content

Add Event Indexing Guide and social_feed example#80

Open
deranalabs wants to merge 3 commits intocedra-labs:mainfrom
deranalabs:main
Open

Add Event Indexing Guide and social_feed example#80
deranalabs wants to merge 3 commits intocedra-labs:mainfrom
deranalabs:main

Conversation

@deranalabs
Copy link
Copy Markdown

@deranalabs deranalabs commented Nov 20, 2025

Cedra Builders Forge - Submission

Season 1

📋 Task Information

Task Title: Event Indexing Guide (Issue #63)

Issue Link: #63

Telegram: @deranaz


✅ Checklist

  • Commented "I'm taking this task" on the issue before starting
  • This PR contains ONE task only
  • All work is original (no copy-paste)
  • Code compiles without errors and all tests pass
  • Includes README, tests, and documentation
  • Will share PR in Cedra Builders Telegram

📝 What Was Built

I built a complete Event Indexing Guide and an example Move Package that demonstrates how to implement gas-efficient social feeds on Cedra using events instead of on-chain vectors.

Key Features:

  • Guide: README.md explains the problem of state bloat and introduces the "Events as Storage" pattern.
  • Contract: Example module cedra_guide::social_feed that emits PostEvent instead of storing posts in global state.
  • Tests: End-to-end Move unit test that verifies the full flow from register → post → event emission.

Technical Approach:
I created a minimal Move package CedraEventGuide with a UserEvents resource holding an EventHandle<PostEvent> per user. The post entry function only emits events and never appends to an on-chain vector, keeping gas usage low and state small.


🧪 Testing

Setup:

# From the docs repository root
cd docs/guides/event-indexing

How to Test:

  1. Ensure Aptos CLI is installed (tested with v7.11.0).
  2. Run the test command:
aptos move test --skip-fetch-latest-git-deps
  1. Expected Results: The command should compile AptosFramework at aptos-release-v1.9.0, build the CedraEventGuide package, and run tests successfully.
INCLUDING DEPENDENCY AptosFramework
BUILDING CedraEventGuide
Running Move unit tests
[ PASS    ] 0x...::social_feed::test_end_to_end
Test result: OK. Total tests: 1; passed: 1; failed: 0

⚠️ Note to Reviewers: The current cedra CLI (v1.0.4) ships with an older Move compiler and fails while compiling recent AptosFramework versions due to unsupported ability constraints. I verified the logic using the aptos CLI, and it is fully compatible with the Cedra Network.

📚 Documentation

  • README with setup instructions
  • Code comments on complex logic
  • Working usage examples (Move + TypeScript event query)
  • API / function behavior documented in the guide

🎯 Quality Check

I confirm my submission:

  • Handles edge cases and errors properly (e.g., user must register before posting)
  • Follows Move conventions and best practices
  • Is gas efficient and reusable (events instead of stored vectors)
  • Has clear structure and helpful error messages
  • Does NOT contain plagiarism, malicious code, or spam

📸 Demo (Optional)

Screenshot 2025-11-21 at 01 24 19

I have read and agree to follow all Cedra Builders Forge rules.

Closes #63

This document outlines the Event Indexing pattern for building gas-efficient social feeds on Cedra, addressing state bloat and gas costs, and providing a code walkthrough for implementing the solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event Indexing Guide

1 participant