---
eip: 7580
label: ERC-7580
title: Advertisement Tracking Interface
status: Draft
type: Standards Track
category: ERC
created: 2023-12-13
official: https://eips.ethereum.org/EIPS/eip-7580
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7580.md
canonical: https://eips.huatuo.xyz/eip-7580/
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]
---

# ERC-7580: Advertisement Tracking Interface

> Interfaces for advertisement clients tracking user actions and checking proportional rewards.

**TL;DR:** 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.

## What problem does it solve?

Projects 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.

Without 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.

## How it works

The interface defines two functions and two matching events:

- `onTrackStart(track_id, contract_address, function_hash)` is called just before the promoted action begins, and emits `onTrackStartRecorded`.
- `onTrackEnd(track_id, contract_address, function_hash)` is called after the action finishes, and emits `onTrackEndRecorded`.

`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.

The intended flow from the spec:

1. A project receives a seed id from the promotion side.
2. Its contract calls `onTrackStart` before the target action.
3. It calls `onTrackEnd` after the action.
4. The promotion contract collects the recorded actions and distributes rewards back to users and the project.

Reward logic is intentionally left out of the standard, to give advertising protocols room to innovate.

## Sample code

A dapp wrapping a promoted function with the tracking hooks:

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.10;

interface IERC7580 {
    event onTrackStartRecorded(uint256 track_id, address contract_address, bytes32 function_hash);
    event onTrackEndRecorded(uint256 track_id, address contract_address, bytes32 function_hash);
    function onTrackStart(uint256 track_id, address contract_address, bytes32 function_hash) external;
    function onTrackEnd(uint256 track_id, address contract_address, bytes32 function_hash) external;
}

contract PromotedDapp is IERC7580 {
    uint256 public immutable campaignId;

    constructor(uint256 id) { campaignId = id; }

    function onTrackStart(uint256 id, address c, bytes32 h) public {
        emit onTrackStartRecorded(id, c, h);
    }

    function onTrackEnd(uint256 id, address c, bytes32 h) public {
        emit onTrackEndRecorded(id, c, h);
    }

    function mint(uint256 amount) external {
        bytes32 h = keccak256(abi.encode(this.mint.selector, msg.sender, amount));
        onTrackStart(campaignId, address(this), h);
        // ... the promoted action ...
        onTrackEnd(campaignId, address(this), h);
    }
}
```

## Things to know

- Status is **Draft**. The interface may change, and the spec says more functions may be added later.
- 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.
- 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.
- How `function_hash` is computed is not pinned down, so tracker and promoter must agree on the encoding.


---

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