---
eip: 7566
label: ERC-7566
title: Multiplayer Game Communication
status: Draft
type: Standards Track
category: ERC
created: 2023-11-28
official: https://eips.ethereum.org/EIPS/eip-7566
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7566.md
canonical: https://eips.huatuo.xyz/eip-7566/
lang: en
tldr: A draft interface for fully on-chain multiplayer games built from two primitives, rooms that group players and messages that carry their moves, so game state and fairness are verifiable.
tags: [gaming, onchain-games, multiplayer, interface]
---

# ERC-7566: Multiplayer Game Communication

> A communication channel that facilitates interaction between players in on-chain games.

**TL;DR:** A draft interface for fully on-chain multiplayer games built from two primitives, rooms that group players and messages that carry their moves, so game state and fairness are verifiable.

## What problem does it solve?

Most multiplayer games run on a central server. Players cannot see whether the server forged data, rigged matchmaking, changed scores or simply shut down. If every action instead happens on-chain, each transaction is a signed, public record of what a player did.

Building such games from scratch means reinventing matchmaking, player IDs and move handling every time, and every game exposes its data differently. ERC-7566 (Multiplayer Game Communication, or MGC) proposes one common interface for these basics so developers can focus on game rules, and anyone can build explorers or verifiers that work across games.

## How it works

The standard is built around two concepts:

- **Room**: a container that groups players. `createRoom()` returns a new room ID; `joinRoom(roomId)` adds the caller and gives them a **member ID that is unique within that room**. A room can stand for a match, a quest or an event. Players can be in many rooms (`getRoomIds`).
- **Message**: a player's action. `sendMessage(roomId, to[], message, messageTypes[])` sends ABI-encoded content to one or more member IDs, along with a list of types describing the encoding. Each message gets an ID. The game's logic lives in `sendMessage`: it reads the message and updates players' state.

Read functions let anyone inspect the game: `getRoomCount`, `getMemberCount`, `getMemberId`, `hasMember`, `getMessageIds(roomId, memberId)` and `getMessage(roomId, messageId)`, which returns the content, its types, the sender and the receivers.

The rationale suggests initialising player data in `createRoom` or `joinRoom`, and handling idle players by recording the time of each member's last message and adding a message type that lets others report and penalise inactive players.

## Sample code

Sending a move with ethers v6 (the `Types.Type` enum comes from the spec's `Types.sol` library, so its numeric values are illustrative here):

```ts
import { Contract, AbiCoder } from "ethers";

const mog = new Contract(gameAddress, [
  "function joinRoom(uint256) returns (uint256)",
  "function sendMessage(uint256,uint256[],bytes,uint8[]) returns (uint256)",
  "function getMemberId(uint256,address) view returns (uint256)",
], signer);

await (await mog.joinRoom(roomId)).wait();

// Move: piece 3 to square 42, sent to opponent member #2
const payload = AbiCoder.defaultAbiCoder().encode(["uint8", "uint16"], [3, 42]);
const UINT8 = 0, UINT16 = 1; // must match the order in Types.sol
await (await mog.sendMessage(roomId, [2], payload, [UINT8, UINT16])).wait();
```

## Things to know

- Status is **Draft**. The interface and its type library may change.
- The Security Considerations section is still a TODO. Implementers must add their own checks, for example that only room members can send messages and that move content is validated.
- Everything on-chain is public, so games with hidden information (card hands, fog of war) need extra techniques such as commit-reveal.
- The authors note it suits turn-based, strategy, card and board games better than real-time play; how fast it feels depends on the chain's block time.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7566
