{"eip":5050,"title":"Interactive NFTs with Modular Environments","description":"Action messaging and discovery protocol for interactions on and between NFTs","authors":["Alexi (@alexi)"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2021-04-18","requires":[165,173,721,1155,1820,4906],"discussionsTo":"https://ethereum-magicians.org/t/eip-5050-nft-interaction-standard/9922","repo":"ERCs","label":"ERC-5050","officialUrl":"https://eips.ethereum.org/EIPS/eip-5050","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5050.md","url":"https://eips.huatuo.xyz/eip-5050/","tldr":{"en":"A messaging protocol that lets NFTs send typed 'actions' to each other (attack, cast, feed…), optionally settled by a shared state contract, so games and apps can build interoperable 'digital physics' on top of tokens.","ja":"NFT どうしが型付きの「アクション」（攻撃、詠唱、餌やりなど）を送り合えるメッセージングプロトコル。共有のステートコントラクトで決着させることもでき、ゲームやアプリがトークンの上に相互運用可能な「デジタル物理学」を構築できる。","ko":"NFT끼리 타입이 있는 \"액션\"(공격, 시전, 먹이 주기 등)을 주고받게 하는 메시징 프로토콜로, 공유 상태 컨트랙트로 정산할 수도 있어 게임과 앱이 토큰 위에 상호 운용 가능한 \"디지털 물리 법칙\"을 만들 수 있다.","zh":"一种让 NFT 之间互相发送带类型的\"动作\"（攻击、施法、喂养……）的消息协议，可选由共享的状态合约来结算，使游戏和应用可以在代币之上构建可互操作的\"数字物理\"。"},"tags":["nft","gaming","interoperability","erc721","erc1155"],"explainers":{"en":{"lang":"en","tldr":"A messaging protocol that lets NFTs send typed 'actions' to each other (attack, cast, feed…), optionally settled by a shared state contract, so games and apps can build interoperable 'digital physics' on top of tokens.","tags":["nft","gaming","interoperability","erc721","erc1155"],"related":[721,1155,165,4906,1820],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5050/","markdown":"## What problem does it solve?\n\n[ERC-721](/eip-721/) and [ERC-1155](/eip-1155/) define what an item *is*, not what it can *do*. Projects that want NFTs to interact, such as a sword hitting a monster or a spell cast on a character, each build bespoke contracts, so items from different projects cannot interact, and off-chain apps cannot discover what is possible.\n\nERC-5050 standardises how one token sends an action to another, how contracts advertise the actions they support, and how a shared \"environment\" contract can hold the resulting game state.\n\n## How it works\n\n- **Action struct.** An action has a `selector` (`bytes4(keccak256(\"namespace.action\"))`), the `user`, a `from` object and a `to` object (each `address + tokenId`), an optional `state` contract and free-form `data`.\n- **Sender interface** (`IERC5050Sender`, ID `0xc8c6c9f3`): `sendAction(action)`, `isValid(hash, nonce)`, `sendableActions()` (human-readable list), plus per-action approvals (`approveForAction`, `setApprovalForAllActions`).\n- **Receiver interface** (`IERC5050Receiver`, ID `0x1a3f02f4`): `onActionReceived(action, nonce)` and `receivableActions()`.\n- **Flow.** The sending contract stores a nonced hash of the action and calls the receiver, which may forward it to the state contract. The state contract calls back `isValid` on the sender to confirm the action is authentic, then finalises it. Without a state contract, sender and receiver manage their own state.\n- **State contracts** are swappable environments (e.g. a `FightGame` that stores HP and strength). The same NFTs can play in different environments.\n- **Naming conventions:** dot for namespaces (`spells.cast`), `\u003e` for required sequence (`settle\u003ebuild`).\n- **Extensions:** `interfaceURI(action)` for custom UIs, action proxies via a modified [ERC-1820](/eip-1820/) registry for legacy contracts, trusted *controllers* for bridging, and [ERC-4906](/eip-4906/) events for metadata refresh.\n\n## Sample code\n\nSending an action from TypeScript (ethers v6):\n\n```ts\nimport { Contract, id } from \"ethers\";\n\nconst sender = new Contract(fightersAddr, [\n  \"function sendAction((bytes4 selector,address user,(address _address,uint256 _tokenId) from,(address _address,uint256 _tokenId) to,address state,bytes data) action) payable\",\n  \"function sendableActions() view returns (string[])\",\n], signer);\n\nconsole.log(await sender.sendableActions()); // e.g. [\"fight.attack\"]\n\nawait sender.sendAction({\n  selector: id(\"fight.attack\").slice(0, 10),        // bytes4 of keccak256\n  user: await signer.getAddress(),\n  from: { _address: fightersAddr, _tokenId: 1n },\n  to:   { _address: monstersAddr, _tokenId: 7n },\n  state: fightGameAddr,                              // or ZeroAddress\n  data: \"0x\",\n});\n```\n\n## Things to know\n\n- Status: **Stagnant**; it was never finalised.\n- Validation proves the action came from the *initiating contract*, not that the `user` field is honest. The protocol deliberately treats the sending contract as the \"prime mover\", so only interact with trusted sender contracts.\n- Action chains (sender → receiver → state) can run out of gas; handlers should be minimal and avoid loops.\n- Existing non-upgradeable NFT contracts need a proxy registry to participate.\n"},"ja":{"lang":"ja","tldr":"NFT どうしが型付きの「アクション」（攻撃、詠唱、餌やりなど）を送り合えるメッセージングプロトコル。共有のステートコントラクトで決着させることもでき、ゲームやアプリがトークンの上に相互運用可能な「デジタル物理学」を構築できる。","tags":["nft","gaming","interoperability","erc721","erc1155"],"related":[721,1155,165,4906,1820],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5050/","markdown":"## 何を解決するのか\n\n[ERC-721](/eip-721/) と [ERC-1155](/eip-1155/) が定義するのはアイテムが*何であるか*であり、*何ができるか*ではありません。剣がモンスターを攻撃する、呪文がキャラクターにかけられるといった、NFT どうしを作用させたいプロジェクトはそれぞれ独自のコントラクトを作るため、異なるプロジェクトのアイテムどうしは作用できず、オフチェーンのアプリも何が可能かを発見できません。\n\nERC-5050 は、あるトークンが別のトークンにアクションを送る方法、コントラクトが対応するアクションを公開する方法、共有の「環境」コントラクトが結果のゲーム状態を保持する方法を標準化します。\n\n## 仕組み\n\n- **Action 構造体。** アクションは、`selector`（`bytes4(keccak256(\"namespace.action\"))`）、`user`、`from` オブジェクトと `to` オブジェクト（それぞれ `address + tokenId`）、任意の `state` コントラクト、自由形式の `data` を持ちます。\n- **送信側インターフェース**（`IERC5050Sender`、ID `0xc8c6c9f3`）: `sendAction(action)`、`isValid(hash, nonce)`、`sendableActions()`（人が読めるリスト）、およびアクションごとの承認（`approveForAction`、`setApprovalForAllActions`）。\n- **受信側インターフェース**（`IERC5050Receiver`、ID `0x1a3f02f4`）: `onActionReceived(action, nonce)` と `receivableActions()`。\n- **フロー。** 送信側コントラクトはアクションの nonce 付きハッシュを保存して受信側を呼び出し、受信側はそれをステートコントラクトに転送することがあります。ステートコントラクトは送信側の `isValid` を呼び返してアクションが本物であることを確認し、確定させます。ステートコントラクトがない場合、送信側と受信側がそれぞれ自分の状態を管理します。\n- **ステートコントラクト**は入れ替え可能な環境です（例: HP と強さを保存する `FightGame`）。同じ NFT がさまざまな環境でプレイできます。\n- **命名規則:** 名前空間にはドット（`spells.cast`）、必須の順序には `\u003e`（`settle\u003ebuild`）を使います。\n- **拡張:** カスタム UI のための `interfaceURI(action)`、レガシーコントラクト向けの、変更した [ERC-1820](/eip-1820/) レジストリ経由のアクションプロキシ、ブリッジ用の信頼できる*コントローラー*、メタデータ更新のための [ERC-4906](/eip-4906/) イベント。\n\n## サンプルコード\n\nTypeScript（ethers v6）からアクションを送信する例:\n\n```ts\nimport { Contract, id } from \"ethers\";\n\nconst sender = new Contract(fightersAddr, [\n  \"function sendAction((bytes4 selector,address user,(address _address,uint256 _tokenId) from,(address _address,uint256 _tokenId) to,address state,bytes data) action) payable\",\n  \"function sendableActions() view returns (string[])\",\n], signer);\n\nconsole.log(await sender.sendableActions()); // e.g. [\"fight.attack\"]\n\nawait sender.sendAction({\n  selector: id(\"fight.attack\").slice(0, 10),        // bytes4 of keccak256\n  user: await signer.getAddress(),\n  from: { _address: fightersAddr, _tokenId: 1n },\n  to:   { _address: monstersAddr, _tokenId: 7n },\n  state: fightGameAddr,                              // or ZeroAddress\n  data: \"0x\",\n});\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。最終化されたことはありません。\n- 検証が証明するのはアクションが*開始側のコントラクト*から来たことであり、`user` フィールドが正直であることではありません。このプロトコルは意図的に送信側コントラクトを「第一動者」として扱うため、信頼できる送信側コントラクトとのみやり取りしてください。\n- アクションの連鎖（送信側 → 受信側 → ステート）はガスが尽きることがあります。ハンドラーは最小限にし、ループを避けてください。\n- アップグレード不可能な既存の NFT コントラクトが参加するには、プロキシレジストリが必要です。\n"},"ko":{"lang":"ko","tldr":"NFT끼리 타입이 있는 \"액션\"(공격, 시전, 먹이 주기 등)을 주고받게 하는 메시징 프로토콜로, 공유 상태 컨트랙트로 정산할 수도 있어 게임과 앱이 토큰 위에 상호 운용 가능한 \"디지털 물리 법칙\"을 만들 수 있다.","tags":["nft","gaming","interoperability","erc721","erc1155"],"related":[721,1155,165,4906,1820],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5050/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-721](/eip-721/)과 [ERC-1155](/eip-1155/)는 아이템이 *무엇인지*를 정의할 뿐 *무엇을 할 수 있는지*는 정의하지 않습니다. 검이 몬스터를 치거나 캐릭터에 주문을 거는 것처럼 NFT끼리 상호작용하게 하려는 프로젝트는 저마다 맞춤 컨트랙트를 만들기 때문에, 서로 다른 프로젝트의 아이템은 상호작용할 수 없고 오프체인 앱도 무엇이 가능한지 알아낼 수 없습니다.\n\nERC-5050은 한 토큰이 다른 토큰에 액션을 보내는 방법, 컨트랙트가 지원하는 액션을 알리는 방법, 공유 \"환경\" 컨트랙트가 그 결과 게임 상태를 보관하는 방법을 표준화합니다.\n\n## 어떻게 동작하나요?\n\n- **Action 구조체.** 액션은 `selector`(`bytes4(keccak256(\"namespace.action\"))`), `user`, `from` 객체와 `to` 객체(각각 `address + tokenId`), 선택적 `state` 컨트랙트, 자유 형식의 `data`로 이루어집니다.\n- **송신자 인터페이스**(`IERC5050Sender`, ID `0xc8c6c9f3`): `sendAction(action)`, `isValid(hash, nonce)`, `sendableActions()`(사람이 읽을 수 있는 목록), 그리고 액션별 승인(`approveForAction`, `setApprovalForAllActions`).\n- **수신자 인터페이스**(`IERC5050Receiver`, ID `0x1a3f02f4`): `onActionReceived(action, nonce)`와 `receivableActions()`.\n- **흐름.** 송신 컨트랙트는 액션의 nonce가 붙은 해시를 저장하고 수신자를 호출하며, 수신자는 이를 상태 컨트랙트로 전달할 수 있습니다. 상태 컨트랙트는 송신자의 `isValid`를 다시 호출해 액션이 진짜인지 확인한 뒤 확정합니다. 상태 컨트랙트가 없으면 송신자와 수신자가 각자 상태를 관리합니다.\n- **상태 컨트랙트**는 교체 가능한 환경입니다(예: HP와 힘을 저장하는 `FightGame`). 같은 NFT가 서로 다른 환경에서 플레이할 수 있습니다.\n- **명명 규칙:** 네임스페이스에는 점(`spells.cast`), 필수 순서에는 `\u003e`(`settle\u003ebuild`)를 씁니다.\n- **확장:** 커스텀 UI를 위한 `interfaceURI(action)`, 레거시 컨트랙트를 위해 수정된 [ERC-1820](/eip-1820/) 레지스트리를 통한 액션 프록시, 브리징을 위한 신뢰할 수 있는 *컨트롤러*, 메타데이터 새로고침을 위한 [ERC-4906](/eip-4906/) 이벤트.\n\n## 샘플 코드\n\nTypeScript(ethers v6)에서 액션 보내기:\n\n```ts\nimport { Contract, id } from \"ethers\";\n\nconst sender = new Contract(fightersAddr, [\n  \"function sendAction((bytes4 selector,address user,(address _address,uint256 _tokenId) from,(address _address,uint256 _tokenId) to,address state,bytes data) action) payable\",\n  \"function sendableActions() view returns (string[])\",\n], signer);\n\nconsole.log(await sender.sendableActions()); // e.g. [\"fight.attack\"]\n\nawait sender.sendAction({\n  selector: id(\"fight.attack\").slice(0, 10),        // bytes4 of keccak256\n  user: await signer.getAddress(),\n  from: { _address: fightersAddr, _tokenId: 1n },\n  to:   { _address: monstersAddr, _tokenId: 7n },\n  state: fightGameAddr,                              // or ZeroAddress\n  data: \"0x\",\n});\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 최종 확정된 적이 없습니다.\n- 검증이 증명하는 것은 액션이 *개시한 컨트랙트*에서 왔다는 점이지 `user` 필드가 정직하다는 점이 아닙니다. 이 프로토콜은 의도적으로 송신 컨트랙트를 \"최초의 동력원\"으로 취급하므로, 신뢰할 수 있는 송신 컨트랙트하고만 상호작용하세요.\n- 액션 체인(송신자 → 수신자 → 상태)은 가스가 바닥날 수 있습니다. 핸들러는 최소한으로 유지하고 루프를 피해야 합니다.\n- 업그레이드할 수 없는 기존 NFT 컨트랙트가 참여하려면 프록시 레지스트리가 필요합니다.\n"},"zh":{"lang":"zh","tldr":"一种让 NFT 之间互相发送带类型的\"动作\"（攻击、施法、喂养……）的消息协议，可选由共享的状态合约来结算，使游戏和应用可以在代币之上构建可互操作的\"数字物理\"。","tags":["nft","gaming","interoperability","erc721","erc1155"],"related":[721,1155,165,4906,1820],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5050/","markdown":"## 它解决什么问题？\n\n[ERC-721](/eip-721/) 和 [ERC-1155](/eip-1155/) 定义的是物品*是什么*，而不是它*能做什么*。想让 NFT 互相作用的项目（例如剑击中怪物、法术施放到角色身上）各自构建定制合约，因此不同项目的物品无法互动，链下应用也无法发现有哪些可能的操作。\n\nERC-5050 规范了一个代币如何向另一个代币发送动作、合约如何公布自己支持的动作，以及共享的\"环境\"合约如何保存由此产生的游戏状态。\n\n## 它如何运作\n\n- **Action 结构体。** 一个动作包含 `selector`（`bytes4(keccak256(\"namespace.action\"))`）、`user`、`from` 对象和 `to` 对象（各为 `address + tokenId`）、可选的 `state` 合约以及自由格式的 `data`。\n- **发送方接口**（`IERC5050Sender`，ID `0xc8c6c9f3`）：`sendAction(action)`、`isValid(hash, nonce)`、`sendableActions()`（人类可读的列表），以及按动作授权（`approveForAction`、`setApprovalForAllActions`）。\n- **接收方接口**（`IERC5050Receiver`，ID `0x1a3f02f4`）：`onActionReceived(action, nonce)` 和 `receivableActions()`。\n- **流程。** 发送合约保存带 nonce 的动作哈希并调用接收方，接收方可以把它转发给状态合约。状态合约回调发送方的 `isValid` 以确认动作真实可信，然后将其最终确定。没有状态合约时，发送方和接收方各自管理自己的状态。\n- **状态合约**是可替换的环境（例如保存 HP 和力量的 `FightGame`）。同一批 NFT 可以在不同环境中玩。\n- **命名约定：** 命名空间用点号（`spells.cast`），必需的先后顺序用 `\u003e`（`settle\u003ebuild`）。\n- **扩展：** 用于自定义 UI 的 `interfaceURI(action)`，通过修改版 [ERC-1820](/eip-1820/) 注册表为旧合约提供的动作代理，用于跨链桥接的受信任*控制器*，以及用于刷新元数据的 [ERC-4906](/eip-4906/) 事件。\n\n## 示例代码\n\n用 TypeScript（ethers v6）发送动作：\n\n```ts\nimport { Contract, id } from \"ethers\";\n\nconst sender = new Contract(fightersAddr, [\n  \"function sendAction((bytes4 selector,address user,(address _address,uint256 _tokenId) from,(address _address,uint256 _tokenId) to,address state,bytes data) action) payable\",\n  \"function sendableActions() view returns (string[])\",\n], signer);\n\nconsole.log(await sender.sendableActions()); // e.g. [\"fight.attack\"]\n\nawait sender.sendAction({\n  selector: id(\"fight.attack\").slice(0, 10),        // bytes4 of keccak256\n  user: await signer.getAddress(),\n  from: { _address: fightersAddr, _tokenId: 1n },\n  to:   { _address: monstersAddr, _tokenId: 7n },\n  state: fightGameAddr,                              // or ZeroAddress\n  data: \"0x\",\n});\n```\n\n## 需要注意\n\n- 状态：**Stagnant**；从未最终定稿。\n- 验证只能证明动作来自*发起合约*，并不能证明 `user` 字段是真实的。该协议有意把发送合约视为\"原动者\"，因此只应与受信任的发送合约交互。\n- 动作链（发送方 → 接收方 → 状态）可能耗尽 gas；处理程序应尽量精简并避免循环。\n- 现有不可升级的 NFT 合约需要代理注册表才能参与。\n"}}}
