Ethereum Referral Protocol
Guides

Using Hooks

Referral programs are made up of hooks, which are smart contracts that get called every time the referral program is interacted with.

Inheriting the hook interface

interface IERPHook {
    function beforeReferral(
        bytes32 programId,
        address referral,
        address referrer
    ) external;
    
    function afterReferral(
        bytes32 programId,
        address referral,
        address referrer
    ) external;
}

In order to make your hook smart contracts compatible with ERP, they must inherit the IERPHook interface.

Overriding hook functions

The hook interface has two functions, beforeReferral and afterReferral. These functions are called before and after a referral respectively. You can override these functions to develop your own custom logic which is run atomically on new referrals.

On this page