> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inkyswap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Referrals (for creators)

> How referral codes attach to trades on V2 tokens at the contract level.

<Note>
  This page covers referrals from a token creator's perspective. For how to share your own referral link and earn from it, see [Rewards & Referrals](/rewards/referral).
</Note>

## What gets recorded on chain

When a buyer or seller passes a referral code with their trade, the V2 hook emits a separate `Referral` event:

```solidity theme={null}
event Referral(
    uint256 indexed launchId,
    address indexed trader,
    string referralCode
);
```

The event is emitted from three entry points:

* `createLaunchWithReferral` (referral code recorded at launch creation)
* `buyWithReferral` (referral code recorded on a buy)
* `sellWithReferral` (referral code recorded on a sell)

The plain `createLaunch`, `buy`, and `sell` functions do not emit `Referral`. The UI calls the `*WithReferral` variant only when a referral code is present in the user's browser.

## What does not happen on chain

* No fee discount. The 2 percent fee is the same with or without a referral code
* No on chain rewards. The contract only records the code in the event log
* No validation of the code. The contract accepts any string as the referral code

Attribution and rewards are handled off chain by InkyPump backend services that index the `Referral` events.

## What this means for your token

If you launch a token on V2, trades against your token can carry referral codes. Those codes show up in the indexer alongside the trade. You do not have to do anything to enable this. It is on by default for every V2 launch.

If you want to track which referrers bring volume to your token, the InkyPump indexer captures referral attribution per trade and exposes it through the InkyPump API. See [Referral API](/api-reference/inkypump/referral) for the available endpoints.

## How users get a referral code attached

When a user opens any inkypump.com URL with `?ref=<code>` or visits `/join/<code>`, the site stores the code in browser local storage. From that point on, every trade and every launch by that user uses the `*WithReferral` variant of the contract call and emits the `Referral` event.

The user does not see any difference in the UI. Referrals are invisible to the trader.

## Reading referral events directly

If you index the chain yourself, the topic hash for the `Referral` event is:

```
keccak256("Referral(uint256,address,string)")
  = 0x796dfbc4bdc1de15340f520a4b17fb287a10b2f6c50e702ee8dc9fa2c714dfc5
```

Listen for this topic on the V2 hook at `0x4cC8F6d5B7cE150CCC0A9B7664532B1283b96AC4`. Join it to the `Trade` event by `(launchId, trader)` and the block number to attribute the trade.
