Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC-7580, which proposes an advertising client interface for tracking user actions and distributing rewards in proportion to those actions.

This article translates, summarizes, and supplements the material linked below.

I have also covered other EIPs.

Overview

The standard proposes a common interface through which advertising clients can track user actions in contracts and determine rewards from advertising protocols. Contracts implementing the interface use events to track information about user activity.

DApps can implement the interface to participate in advertising protocols, allowing users to receive funds from projects for performing specific actions. Participating DApps can also receive proportional rewards.

Motivation

As DApps become more widespread, demand for on-chain advertising is expected to increase. Compared with Web2 advertising, Web3 advertising offers several potential advantages.

  • Traceability
    • On-chain actions can be tracked.
  • Transparency
    • Public transaction records make activity independently inspectable.
  • Direct incentives
    • Users can receive bonuses or airdrops directly.

The proposed interface standardizes tracking user actions and distributing advertising rewards. The workflow is as follows.

  1. The project obtains a seed ID (hash) from the promotion provider.

    • The project obtains the seed ID when an advertising campaign begins.
  2. Notify the promotion provider before the promoted action starts.

    • The project's smart contract calls the onTrackStart interface with the ID, contract address, and function hash.
    js
    function onTrackStart(bytes32 id, address contract_address, bytes4 function_hash) external;
  3. Notify the promotion provider after the promoted action ends.

    • The project's smart contract calls the onTrackEnd interface with the same ID, contract address, and function hash.
    js
    function onTrackEnd(bytes32 id, address contract_address, bytes4 function_hash) external;
  4. The promotion contract collects action data and distributes rewards.

    • Once the campaign ends, the promotion contract distributes rewards based on the collected data.

Consider the following scenario.

  • Contract A
    • Runs an advertising campaign offering bonuses or airdrops to users.
  • Contract B
    • Provides incentives for users who perform particular actions.
  1. A user performs a specific action in Contract B.
    • Contract B calls onTrackStart and onTrackEnd to track the action.
  2. Contract A rewards the user.
    • Contract A distributes rewards based on the tracking information received from Contract B.

This tracking mechanism makes it possible to measure advertising campaign performance and offer appropriate incentives.

Specification

Interface

The protocol standardizes action tracking across applications and defines two principal methods, onTrackStart and onTrackEnd.

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

interface IERCXXX {
    // Events

    /// @dev Emits when track starts.
    /// @param track_id track id
    /// @param contract_address the address of tracking contract
    /// @param function_hash the hash of tracking function with params
    event onTrackStartRecorded(uint256 track_id, address contract_address, bytes32 function_hash);

    /// @dev Emits when track starts.
    /// @param track_id track id
    /// @param contract_address the address of tracking contract
    /// @param function_hash the hash of tracking function with params
    event onTrackEndRecorded(uint256 track_id, address contract_address, bytes32 function_hash);

    // Functions

    /// @dev Track a specified contract function start move.
    /// @param track_id track id
    /// @param contract_address the address of tracking contract
    /// @param function_hash the hash of tracking function with params
    function onTrackStart(uint256 track_id, address contract_address, bytes32 function_hash) external;

    /// @dev Track a specified contract function end move.
    /// @param track_id track id
    /// @param contract_address the address of tracking contract
    /// @param function_hash the hash of tracking function with params
    function onTrackEnd(uint256 track_id, address contract_address, bytes32 function_hash);
}

Note that the illustrative workflow above uses different parameter types from the interface reproduced here. When implementing the proposal, consult the specification for the applicable signatures.

Events

onTrackStartRecorded

Emitted when tracking begins.

  • track_id
    • Unique tracking identifier.
  • contract_address
    • Address of the contract being tracked.
  • function_hash
    • Hash of the tracked function and its parameters.
onTrackEndRecorded

Emitted when tracking ends.

  • track_id
    • Unique tracking identifier.
  • contract_address
    • Address of the contract being tracked.
  • function_hash
    • Hash of the tracked function and its parameters.

Functions

onTrackStart

Records the beginning of tracking.

  • track_id
    • Tracking identifier.
  • contract_address
    • Address of the contract being tracked.
  • function_hash
    • Hash of the tracked function and its parameters.
onTrackEnd

Records the end of tracking.

  • track_id
    • Tracking identifier.
  • contract_address
    • Address of the contract being tracked.
  • function_hash
    • Hash of the tracked function and its parameters.

Additional Notes

The proposal's core mechanism is a tracking interface shared by multiple DApps, enabling efficient tracking of actions across applications.

Projects need not build separate tracking systems from scratch, saving development time and costs. Collected tracking data can be analyzed to measure advertising and promotional campaigns, and rewards can be allocated to users and projects accordingly.

The proposed interface provides basic tracking functionality and can be extended if more sophisticated tracking is required in the future.

Compatibility

The proposal does not introduce compatibility issues.

Citation

wart (@wartstone), "ERC-7580: Advertisement Tracking Interface [DRAFT]," Ethereum Improvement Proposals, no. 7580, December 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7580.

Conclusion

ERC-7580 proposes an advertising client interface for tracking user actions and distributing rewards in proportion to those actions.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

I also publish articles on the following platforms.

https://chaldene.net/