{"eip":7580,"title":"Advertisement Tracking Interface","description":"Interfaces for advertisement clients tracking user actions and checking proportional rewards.","authors":["wart (@wartstone)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-12-13","discussionsTo":"https://ethereum-magicians.org/t/erc-7580-inter-dapp-tracking-inferface/17653","repo":"ERCs","label":"ERC-7580","officialUrl":"https://eips.ethereum.org/EIPS/eip-7580","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7580.md","url":"https://eips.huatuo.xyz/eip-7580/","tldr":{"en":"A draft interface that lets a dapp mark the start and end of a user action with events, so an on-chain advertising or airdrop protocol can track it and reward both users and the dapp.","ja":"dapp がユーザーのアクションの開始と終了をイベントで示せるようにするドラフトのインターフェース。オンチェーンの広告やエアドロップのプロトコルがそれを追跡し、ユーザーと dapp の双方に報酬を与えられる。","ko":"dapp이 사용자 행동의 시작과 끝을 이벤트로 표시할 수 있게 하는 초안 인터페이스. 온체인 광고나 에어드롭 프로토콜이 이를 추적해 사용자와 dapp 모두에게 보상할 수 있다.","zh":"一个草案接口，让 dapp 可以用事件标记用户操作的开始和结束，使链上广告或空投协议能够追踪它，并同时奖励用户和 dapp。"},"tags":["advertising","tracking","airdrop","interface"],"explainers":{"en":{"lang":"en","tldr":"A draft interface that lets a dapp mark the start and end of a user action with events, so an on-chain advertising or airdrop protocol can track it and reward both users and the dapp.","tags":["advertising","tracking","airdrop","interface"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7580/","markdown":"## What problem does it solve?\n\nProjects often want to reward users for doing something in *another* project's contract: \"swap on dapp B and get an airdrop from project A\". To pay out fairly, A needs a reliable signal that a given user performed that exact action in B, and B wants a share of the reward for sending the traffic.\n\nWithout a common interface, every campaign needs custom integration and ad-hoc log parsing. ERC-7580 proposes a minimal, shared tracking hook so dapps can join advertising protocols and those protocols can attribute actions in a uniform way.\n\n## How it works\n\nThe interface defines two functions and two matching events:\n\n- `onTrackStart(track_id, contract_address, function_hash)` is called just before the promoted action begins, and emits `onTrackStartRecorded`.\n- `onTrackEnd(track_id, contract_address, function_hash)` is called after the action finishes, and emits `onTrackEndRecorded`.\n\n`track_id` identifies the campaign, `contract_address` the contract being tracked, and `function_hash` a hash of the tracked function together with its parameters. The pair of events marks a \"region of interest\" inside a transaction.\n\nThe intended flow from the spec:\n\n1. A project receives a seed id from the promotion side.\n2. Its contract calls `onTrackStart` before the target action.\n3. It calls `onTrackEnd` after the action.\n4. The promotion contract collects the recorded actions and distributes rewards back to users and the project.\n\nReward logic is intentionally left out of the standard, to give advertising protocols room to innovate.\n\n## Sample code\n\nA dapp wrapping a promoted function with the tracking hooks:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.10;\n\ninterface IERC7580 {\n    event onTrackStartRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    event onTrackEndRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    function onTrackStart(uint256 track_id, address contract_address, bytes32 function_hash) external;\n    function onTrackEnd(uint256 track_id, address contract_address, bytes32 function_hash) external;\n}\n\ncontract PromotedDapp is IERC7580 {\n    uint256 public immutable campaignId;\n\n    constructor(uint256 id) { campaignId = id; }\n\n    function onTrackStart(uint256 id, address c, bytes32 h) public {\n        emit onTrackStartRecorded(id, c, h);\n    }\n\n    function onTrackEnd(uint256 id, address c, bytes32 h) public {\n        emit onTrackEndRecorded(id, c, h);\n    }\n\n    function mint(uint256 amount) external {\n        bytes32 h = keccak256(abi.encode(this.mint.selector, msg.sender, amount));\n        onTrackStart(campaignId, address(this), h);\n        // ... the promoted action ...\n        onTrackEnd(campaignId, address(this), h);\n    }\n}\n```\n\n## Things to know\n\n- Status is **Draft**. The interface may change, and the spec says more functions may be added later.\n- As written, the spec's interface omits `external` on `onTrackEnd` and still uses the placeholder name `IERCXXX`; the sample above adds `external` so it compiles.\n- The Security Considerations section is still a TODO. In particular, nothing stops anyone from calling the public hooks or emitting fake start/end events, so a reward protocol must decide which contracts and callers it trusts.\n- How `function_hash` is computed is not pinned down, so tracker and promoter must agree on the encoding.\n"},"ja":{"lang":"ja","tldr":"dapp がユーザーのアクションの開始と終了をイベントで示せるようにするドラフトのインターフェース。オンチェーンの広告やエアドロップのプロトコルがそれを追跡し、ユーザーと dapp の双方に報酬を与えられる。","tags":["advertising","tracking","airdrop","interface"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7580/","markdown":"## 何を解決するのか\n\nプロジェクトは、*別の*プロジェクトのコントラクトで何かをしたユーザーに報酬を与えたい場合がよくあります。「dapp B でスワップすればプロジェクト A からエアドロップがもらえる」といった具合です。公平に支払うには、A はあるユーザーが B でまさにそのアクションを行ったという信頼できるシグナルを必要とし、B はトラフィックを送ったことに対する報酬の分け前を求めます。\n\n共通のインターフェースがなければ、キャンペーンごとに個別の連携と場当たり的なログ解析が必要になります。ERC-7580 は、dapp が広告プロトコルに参加でき、プロトコル側もアクションを統一的に帰属させられるよう、最小限で共有のトラッキングフックを提案します。\n\n## 仕組み\n\nこのインターフェースは 2 つの関数と、それに対応する 2 つのイベントを定義します。\n\n- `onTrackStart(track_id, contract_address, function_hash)` は、プロモーション対象のアクションが始まる直前に呼び出され、`onTrackStartRecorded` を emit します。\n- `onTrackEnd(track_id, contract_address, function_hash)` は、アクションが終わった後に呼び出され、`onTrackEndRecorded` を emit します。\n\n`track_id` はキャンペーンを、`contract_address` は追跡されるコントラクトを、`function_hash` は追跡される関数とそのパラメーターのハッシュを識別します。この 2 つのイベントの組が、トランザクション内の「注目領域」を示します。\n\n仕様が想定するフロー:\n\n1. プロジェクトは、プロモーション側からシード ID を受け取ります。\n2. そのコントラクトは、対象のアクションの前に `onTrackStart` を呼び出します。\n3. アクションの後に `onTrackEnd` を呼び出します。\n4. プロモーションのコントラクトは、記録されたアクションを集め、ユーザーとプロジェクトに報酬を分配します。\n\n報酬のロジックは、広告プロトコルが自由に革新できるよう、意図的に標準には含まれていません。\n\n## サンプルコード\n\nプロモーション対象の関数をトラッキングフックで包んだ dapp:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.10;\n\ninterface IERC7580 {\n    event onTrackStartRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    event onTrackEndRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    function onTrackStart(uint256 track_id, address contract_address, bytes32 function_hash) external;\n    function onTrackEnd(uint256 track_id, address contract_address, bytes32 function_hash) external;\n}\n\ncontract PromotedDapp is IERC7580 {\n    uint256 public immutable campaignId;\n\n    constructor(uint256 id) { campaignId = id; }\n\n    function onTrackStart(uint256 id, address c, bytes32 h) public {\n        emit onTrackStartRecorded(id, c, h);\n    }\n\n    function onTrackEnd(uint256 id, address c, bytes32 h) public {\n        emit onTrackEndRecorded(id, c, h);\n    }\n\n    function mint(uint256 amount) external {\n        bytes32 h = keccak256(abi.encode(this.mint.selector, msg.sender, amount));\n        onTrackStart(campaignId, address(this), h);\n        // ... the promoted action ...\n        onTrackEnd(campaignId, address(this), h);\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。インターフェースは変わる可能性があり、仕様では今後さらに関数が追加されるかもしれないとされています。\n- 仕様のインターフェースは、記載されているとおりだと `onTrackEnd` に `external` がなく、プレースホルダーの名前 `IERCXXX` がまだ使われています。上のサンプルはコンパイルできるよう `external` を追加しています。\n- Security Considerations セクションはまだ TODO です。特に、公開されたフックを誰でも呼び出せることや、偽の開始／終了イベントを emit できることを防ぐ手段はないため、報酬プロトコルはどのコントラクトと呼び出し元を信頼するかを決める必要があります。\n- `function_hash` の計算方法は固定されていないため、トラッキングする側とプロモーションする側でエンコーディングに合意する必要があります。\n"},"ko":{"lang":"ko","tldr":"dapp이 사용자 행동의 시작과 끝을 이벤트로 표시할 수 있게 하는 초안 인터페이스. 온체인 광고나 에어드롭 프로토콜이 이를 추적해 사용자와 dapp 모두에게 보상할 수 있다.","tags":["advertising","tracking","airdrop","interface"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7580/","markdown":"## 어떤 문제를 해결하나요?\n\n프로젝트는 *다른* 프로젝트의 컨트랙트에서 무언가를 한 사용자에게 보상하고 싶을 때가 많습니다. \"dapp B에서 스왑하면 프로젝트 A에서 에어드롭을 받는다\" 같은 경우입니다. 공정하게 지급하려면 A는 특정 사용자가 B에서 바로 그 행동을 했다는 믿을 만한 신호가 필요하고, B는 트래픽을 보낸 대가로 보상의 일부를 원합니다.\n\n공통 인터페이스가 없으면 캠페인마다 맞춤 연동과 임시방편의 로그 파싱이 필요합니다. ERC-7580은 dapp이 광고 프로토콜에 참여할 수 있고 그 프로토콜들이 행동을 일관된 방식으로 귀속시킬 수 있도록, 최소한의 공유 추적 훅을 제안합니다.\n\n## 어떻게 동작하나요?\n\n이 인터페이스는 두 개의 함수와 이에 대응하는 두 개의 이벤트를 정의합니다.\n\n- `onTrackStart(track_id, contract_address, function_hash)`는 홍보 대상 행동이 시작되기 직전에 호출되며 `onTrackStartRecorded`를 emit합니다.\n- `onTrackEnd(track_id, contract_address, function_hash)`는 행동이 끝난 뒤에 호출되며 `onTrackEndRecorded`를 emit합니다.\n\n`track_id`는 캠페인을, `contract_address`는 추적 대상 컨트랙트를, `function_hash`는 추적 대상 함수와 그 파라미터의 해시를 식별합니다. 이 한 쌍의 이벤트가 트랜잭션 안에서 \"관심 구간\"을 표시합니다.\n\n명세가 의도한 흐름:\n\n1. 프로젝트가 홍보 측으로부터 시드 id를 받습니다.\n2. 컨트랙트가 대상 행동 전에 `onTrackStart`를 호출합니다.\n3. 행동 후에 `onTrackEnd`를 호출합니다.\n4. 홍보 컨트랙트가 기록된 행동을 수집해 사용자와 프로젝트에게 보상을 분배합니다.\n\n보상 로직은 광고 프로토콜이 자유롭게 혁신할 수 있도록 의도적으로 표준에서 제외되었습니다.\n\n## 샘플 코드\n\n홍보 대상 함수를 추적 훅으로 감싼 dapp:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.10;\n\ninterface IERC7580 {\n    event onTrackStartRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    event onTrackEndRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    function onTrackStart(uint256 track_id, address contract_address, bytes32 function_hash) external;\n    function onTrackEnd(uint256 track_id, address contract_address, bytes32 function_hash) external;\n}\n\ncontract PromotedDapp is IERC7580 {\n    uint256 public immutable campaignId;\n\n    constructor(uint256 id) { campaignId = id; }\n\n    function onTrackStart(uint256 id, address c, bytes32 h) public {\n        emit onTrackStartRecorded(id, c, h);\n    }\n\n    function onTrackEnd(uint256 id, address c, bytes32 h) public {\n        emit onTrackEndRecorded(id, c, h);\n    }\n\n    function mint(uint256 amount) external {\n        bytes32 h = keccak256(abi.encode(this.mint.selector, msg.sender, amount));\n        onTrackStart(campaignId, address(this), h);\n        // ... the promoted action ...\n        onTrackEnd(campaignId, address(this), h);\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 인터페이스가 바뀔 수 있으며, 명세는 나중에 함수가 더 추가될 수 있다고 말합니다.\n- 명세에 적힌 그대로의 인터페이스는 `onTrackEnd`에 `external`이 빠져 있고 자리 표시용 이름 `IERCXXX`를 아직 사용합니다. 위 샘플은 컴파일되도록 `external`을 추가했습니다.\n- Security Considerations 섹션은 아직 TODO입니다. 특히 누구나 공개된 훅을 호출하거나 가짜 시작/종료 이벤트를 emit하는 것을 막는 장치가 없으므로, 보상 프로토콜은 어떤 컨트랙트와 호출자를 신뢰할지 스스로 정해야 합니다.\n- `function_hash`를 계산하는 방법은 고정되어 있지 않으므로, 추적하는 쪽과 홍보하는 쪽이 인코딩에 합의해야 합니다.\n"},"zh":{"lang":"zh","tldr":"一个草案接口，让 dapp 可以用事件标记用户操作的开始和结束，使链上广告或空投协议能够追踪它，并同时奖励用户和 dapp。","tags":["advertising","tracking","airdrop","interface"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7580/","markdown":"## 它解决什么问题？\n\n项目常常想奖励那些在*另一个*项目的合约中完成某件事的用户：\"在 dapp B 上兑换，就能从项目 A 获得空投\"。为了公平发放，A 需要一个可靠的信号，证明某个用户确实在 B 中执行了那个确切的操作，而 B 则希望因为导入流量而分到一部分奖励。\n\n没有通用接口的话，每个活动都需要定制集成和临时的日志解析。ERC-7580 提出了一个最小的、共享的追踪钩子，使 dapp 可以加入广告协议，而这些协议也能以统一的方式归因操作。\n\n## 它如何运作\n\n该接口定义了两个函数和两个对应的事件：\n\n- `onTrackStart(track_id, contract_address, function_hash)` 在被推广的操作开始之前调用，并触发 `onTrackStartRecorded`。\n- `onTrackEnd(track_id, contract_address, function_hash)` 在操作结束之后调用，并触发 `onTrackEndRecorded`。\n\n`track_id` 标识活动，`contract_address` 标识被追踪的合约，`function_hash` 是被追踪函数连同其参数的哈希。这一对事件在交易内部标记出一个\"关注区域\"。\n\n规范设想的流程：\n\n1. 项目从推广方收到一个种子 id。\n2. 其合约在目标操作之前调用 `onTrackStart`。\n3. 在操作之后调用 `onTrackEnd`。\n4. 推广合约收集被记录的操作，并把奖励分发回用户和项目。\n\n奖励逻辑被有意排除在标准之外，给广告协议留出创新空间。\n\n## 示例代码\n\n一个用追踪钩子包裹被推广函数的 dapp：\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.10;\n\ninterface IERC7580 {\n    event onTrackStartRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    event onTrackEndRecorded(uint256 track_id, address contract_address, bytes32 function_hash);\n    function onTrackStart(uint256 track_id, address contract_address, bytes32 function_hash) external;\n    function onTrackEnd(uint256 track_id, address contract_address, bytes32 function_hash) external;\n}\n\ncontract PromotedDapp is IERC7580 {\n    uint256 public immutable campaignId;\n\n    constructor(uint256 id) { campaignId = id; }\n\n    function onTrackStart(uint256 id, address c, bytes32 h) public {\n        emit onTrackStartRecorded(id, c, h);\n    }\n\n    function onTrackEnd(uint256 id, address c, bytes32 h) public {\n        emit onTrackEndRecorded(id, c, h);\n    }\n\n    function mint(uint256 amount) external {\n        bytes32 h = keccak256(abi.encode(this.mint.selector, msg.sender, amount));\n        onTrackStart(campaignId, address(this), h);\n        // ... the promoted action ...\n        onTrackEnd(campaignId, address(this), h);\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**。接口可能会变化，规范中说以后可能会增加更多函数。\n- 按照原文，规范中的接口在 `onTrackEnd` 上漏写了 `external`，并且仍在使用占位名称 `IERCXXX`；上面的示例加上了 `external` 以便能够编译。\n- Security Considerations 一节仍然是 TODO。尤其是，没有任何机制阻止任何人调用这些公开的钩子或触发伪造的开始/结束事件，所以奖励协议必须自行决定信任哪些合约和调用者。\n- `function_hash` 的计算方式没有被固定，因此追踪方和推广方必须就编码方式达成一致。\n"}}}
