XMTP Mafia

Mafia game bot on XMTP with inline action buttons in group chats with time-based phases.

Visit Repo
XMTP Mafia banner

About

This project is a Mafia (social deduction) game built as an XMTP agent that runs entirely within XMTP chat groups. Players can create game lobbies, join via inline action buttons, complete tasks, attempt kills, and vote to eliminate suspects - all through XMTP messaging. The game features time-based phases that automatically advance, role-based gameplay with random Mafia/Town assignments, and interactive buttons for voting and killing. Tasks are distributed in group chats with player address mentions, while kill commands are handled privately via DMs. The game supports up to 6 players per game with configurable parameters for rounds, phase durations, and game mechanics. All game state is managed server-side with automatic round progression, ensuring a smooth multiplayer experience entirely within the XMTP ecosystem.

How it's made

Built using XMTP Agent SDK with TypeScript for type safety. The architecture follows a modular pattern: agent setup handles codec registration (ActionsCodec, IntentCodec for XIP-67 inline actions), middleware processes all messages with intent detection fallbacks, and handlers manage game logic. Custom codecs enable interactive buttons for join/vote/kill actions. Game state is managed in-memory via GameManager class with better-sqlite3 for XMTP client persistence. Notable hacks: dual intent detection (contentType check + object structure fallback) due to SDK inconsistencies, direct client access via (agent as any).client for sending ActionsContent with ContentTypeActions, and a custom timer system tracking phase deadlines in game state. The kill command bypasses mention requirements in DMs via middleware early-return, while group commands require @mafia mentions. Player addresses are resolved from conversation members or preferences API, enabling address-based targeting. All phases are time-based with automatic advancement, using setTimeout with cleanup on game end.

From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

Not checked yet.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

Hunters

A Web3 Werewolf game bot powered by Flow's VRF for true randomness in role assignment and OpenAI for immersive storytelling. Winners get FLOW tokens as rewards! Built with MessageKit for XMTP group chats. #GameFi #Web3Gaming

CryptoQuest League

XMTP-powered group chat bot for DeFi-themed riddles. Solve DeFi puzzles, form teams, compete on the global leaderboard and earn on-chain points.