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

# A coin that donates its fees

> Let a creator search for recipients, create the config their coin pays, and show who the coin supports

This guide is for a launchpad or a token platform. The whole integration is three things:

1. **Search** for a recipient while a creator types.
2. **Create a config** for the recipients the creator picked.
3. **Show the recipients** of a coin on its page.

Every call is made from your backend, with your API key, on `https://api.donate.gg/api/v2`.

## Before you start

* **An API key**, kept on your server. See [API keys](https://docs.donate.gg/api-keys.md).
* **A registered donation source.** This is the on-chain address your fee program's donations are
  credited to. Donate registers it to your project so that it can tell which coin and which creator
  each donation is for. Email [support@donate.gg](mailto:support@donate.gg) to register one.
* **The costs.** A donation through a config your project created pays a 20% fee today, a config is
  permanent, and there is no sandbox. See [Before you build](https://docs.donate.gg/index.md#before-you-build).

## The calls you make

| When | Call | Key |
| - | - | - |
| The creator types in the picker | `GET /v2/beneficiaries?term=` | Optional |
| The creator confirms | `POST /v2/configs` | Required |
| You show the fee | `GET /v2/configs/{configId}/fee` | Optional |
| A coin page lists its recipients | `GET /v2/configs/{configId}/beneficiaries` | Optional |
| A person opens one recipient | `GET /v2/charities/{charityId}` or `GET /v2/campaigns/{campaignId}` | Optional |

Send your key on every call, including the ones where it is optional. A keyed call counts against
your organization's [rate limit](https://docs.donate.gg/api/rate-limits.md) instead of the 20 a minute an IP address gets.

## Build it

**1. Search while the creator types**

The picker starts empty. When the creator has typed something, send it as `term`. The answer
lists the charities and campaigns that can be named in a new config, best match first.

```bash theme={null}
curl "https://api.donate.gg/api/v2/beneficiaries?term=make-a-wish%20america&limit=5" \
  -H "donate-api-key: $DONATE_API_KEY"
```

An example answer:

```json theme={null}
{
  "items": [
    {
      "type": "charity",
      "id": "9b4dae4e-d8c1-4322-a594-35a4858296b2",
      "available": true,
      "name": "Make-A-Wish America",
      "imageUrl": "https://docs.candid.org/edoc/11142134",
      "url": "https://www.donate.gg/charities/make-a-wish-america",
      "source": null,
      "eligible": true,
      "receiverCount": 1
    }
  ],
  "nextCursor": null
}
```

Show `imageUrl`, `name` and a badge for `type` on each row. Keep `type` and `id` of every row
the creator picks: the two together are the recipient.
[Build a beneficiary picker](https://docs.donate.gg/guides/beneficiary-picker.md) covers the filters, the fallbacks and
what to do when a charity is not listed.

**2. Create the config**

When the creator confirms, create a config on your server. A config is a permanent split: the
recipients and the weight of each. Several recipients are normal. This one gives a charity
three quarters and a campaign one quarter.

```bash theme={null}
curl -i -X POST "https://api.donate.gg/api/v2/configs" \
  -H "donate-api-key: $DONATE_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "beneficiaries": [
      { "type": "charity", "id": "9b4dae4e-d8c1-4322-a594-35a4858296b2", "weight": 3 },
      { "type": "campaign", "id": "cmr2icrm701xu04jxvybvmgwn", "weight": 1 }
    ]
  }'
```

An example answer. The id illustrates the shape:

```json theme={null}
{
  "id": "0x7ac4174ed42dc6285a4d8a29f33177218a9e99becb64a5c9845725d1ebfe29f3",
  "idBase58": "9GEATUZ8sqNxgiuF3BauoNaUKoA7v1MMrV16UZFkqqpW",
  "beneficiaries": [
    { "type": "charity", "id": "9b4dae4e-d8c1-4322-a594-35a4858296b2", "weight": "3" },
    { "type": "campaign", "id": "cmr2icrm701xu04jxvybvmgwn", "weight": "1" }
  ],
  "createdAt": "2026-11-19T09:12:04.118Z"
}
```

* **The body names recipients and nothing else.** There is no name, logo or fee to send, and
  no wallet address for a charity or a campaign. The config id carries the route.
* **Weights are relative, not percentages.** List one to five beneficiaries. See
  [configs and weights](https://docs.donate.gg/concepts.md#configs-and-weights).
* **The status says what happened.** `201` means this request created the config. `200` means
  your project already had a config with these beneficiaries and weights, and the body is that
  config. Two coins with the same beneficiaries and the same weights share one config. Weights
  are compared as written: `3` and `1` give a different config from `75` and `25`, and both
  are permanent.
* **A retry is safe.** After a timeout, send the same body again. You get the config the first
  attempt created.
* **A config is never edited.** On the rare occasion a creator changes where a live coin's
  rewards go, create a whole new config and point the coin at it.

Store `id` and `idBase58` with the coin. Both are the same 32 bytes.

If the request is refused, branch on `code`:

| Status | `code` | What to do |
| - | - | - |
| `400` | `VALIDATION_ERROR` | Fix the body. `issues` names the field when one field is at fault. It is absent when the recipients together would pay more than five receivers: see [configs and weights](https://docs.donate.gg/concepts.md#configs-and-weights) |
| `422` | `BENEFICIARY_NOT_FOUND` | An `id` does not exist for its `type`, or the recipient is withheld |
| `422` | `BENEFICIARY_NOT_ELIGIBLE` | A recipient is visible and takes no new configs, such as a campaign that has ended |
| `503` | `PROVIDER_UNAVAILABLE` | A campaign's provider could not be read, or a change to a recipient is still being applied. Send the same request again shortly |

Both `422`s say which recipients they are about: `issues` has one entry for each, and its
`path` is the recipient's place in the body, such as `beneficiaries[1]`. Ask the creator to
replace those.

```json theme={null}
{
  "code": "BENEFICIARY_NOT_ELIGIBLE",
  "message": "A beneficiary in the request cannot be named in a new config.",
  "issues": [
    {
      "path": "beneficiaries[1]",
      "code": "invalid",
      "message": "This beneficiary cannot be named in a new config"
    }
  ]
}
```

`issues` is absent when the refusal cannot be tied to one recipient. Then send every
reference of the body to
[`GET /v2/beneficiaries/lookup?ids=`](https://docs.donate.gg/api-reference/beneficiaries/list-by-ids) and look
for `available: false`, or read each recipient in full and look for `eligible: false`.

[Errors](https://docs.donate.gg/api/errors.md) has the body and every other code.

**3. Show the fee**

A config has no fee on it. The fee a donation pays is set by Donate's fee policy when the
donation settles, and this call quotes it. `chainId` is the chain the donation is made on
(`101` is Solana). `creditedAddress` is the address the donation is credited to on-chain,
which for your coins is your registered donation source. Here `$DONATION_SOURCE` holds that
address.

```bash theme={null}
curl "https://api.donate.gg/api/v2/configs/BN5zs4C4zce2XBL3QjqV7LTjE51822i2jX4TPQ8DjM3v/fee?chainId=101&creditedAddress=$DONATION_SOURCE" \
  -H "donate-api-key: $DONATE_API_KEY"
```

An example answer:

```json theme={null}
{ "feeBps": 2000, "evaluatedSlot": "381204455" }
```

`feeBps` is in basis points: `2000` is 20% of each donation. It is an estimate, not a locked
rate. [Fees](https://docs.donate.gg/concepts.md#fees) explains the quote.

**4. Attach the config to the coin on-chain**

Your fee program keeps the config id for each coin and donates to it through the Donation Relay
program.

* On Solana, use `idBase58` as a `Pubkey` with `donate_pubkey_config_id_v1`, or decode `id` to
  32 bytes for `donate_v1`. Accounts and arguments are on the
  [Solana page](https://docs.donate.gg/blockchain/solana-svm.md). On an EVM chain, `id` is the `bytes32` the
  [contract](https://docs.donate.gg/blockchain/evm.md) takes.
* Set `credited_to` to your registered donation source address.
* Set `message` to the coin's mint and the creator's wallet, separated by a comma:
  `<mint>,<creator>`. Both must be valid addresses. The message can be at most 255 bytes.

Donate reads those two values to count the donation for that coin and that creator. A donation
from your source with any other message is still paid to the config, and it is not counted for
a coin.

**5. Show who the coin supports**

Use the coin’s config id to get each recipient’s name, logo, website, socials and weight.
A campaign includes the charities it supports. It stays on the coin page when it completes.
Keep sending fees to the same config. If a Tiltify campaign closes, Donate works with Tiltify
to credit the fees that arrive afterward.

```bash theme={null}
curl "https://api.donate.gg/api/v2/configs/$CONFIG_ID/beneficiaries" \
  -H "donate-api-key: $DONATE_API_KEY"
```

Start from the config you stored, not from the coin read:
[`GET /v2/coins/{chainId}/{address}`](https://docs.donate.gg/api-reference/coins/get) finds the config a coin pays
for the coins of one launchpad only. See
[Coins and donation sources](https://docs.donate.gg/concepts.md#coins-and-donation-sources).

[Show what a coin donates to](https://docs.donate.gg/guides/coin-page.md) has the whole page: the rows, the details view
that opens when a row is clicked, and what to cache.

## Totals

You know what each of your coins has donated, so show your own numbers. Donate's totals are there
when you want them: `stats` on [`GET /v2/coins/{chainId}/{address}`](https://docs.donate.gg/api-reference/coins/get) is
everything a coin has donated, and
[`GET /v2/donation-sources/{chainId}/{address}/coins`](https://docs.donate.gg/api-reference/coins/donation-sources/list-coins)
ranks the coins of your own donation source. [Leaderboards and stats](https://docs.donate.gg/guides/leaderboards-and-stats.md)
covers them.

## What to cache

* **A config.** It never changes. Keep `id`, `idBase58` and `beneficiaries` for as long as you
  like.
* **A search answer and a recipient's name and image.** These change rarely. Keeping them for
  hours is fine. A recipient can become unavailable later, so do not keep them forever.
* **The fee quote.** It can change with the fee policy. Ask again when you show it.

## What to tell creators

* A config is permanent. Choosing other recipients later means a new config for the coin.
* A coin's donated total moves when its fees are claimed and donated, which happens in batches. It
  does not move with every trade.
* A donation is not final the moment it is sent. See [Track a donation](https://docs.donate.gg/guides/track-a-donation.md).
* If a charity later opts out or is removed, the coin keeps paying its config and the charity is
  shown as a [stand-in](https://docs.donate.gg/api/pagination-and-formats.md#a-recipient-that-is-withheld).

## Runnable sequence

```bash theme={null}
# Needs curl and jq.
export DONATE_API_KEY="your key"
export DONATION_SOURCE="your registered donation source address"

# 1. The creator types: search
curl "https://api.donate.gg/api/v2/beneficiaries?term=make-a-wish%20america&limit=5" \
  -H "donate-api-key: $DONATE_API_KEY"

# 2. The creator confirms: create the config (permanent) and keep both spellings of its id
CONFIG=$(curl -s -X POST "https://api.donate.gg/api/v2/configs" \
  -H "donate-api-key: $DONATE_API_KEY" \
  -H "content-type: application/json" \
  -d '{"beneficiaries":[{"type":"charity","id":"9b4dae4e-d8c1-4322-a594-35a4858296b2","weight":3},{"type":"campaign","id":"cmr2icrm701xu04jxvybvmgwn","weight":1}]}')
CONFIG_ID=$(echo "$CONFIG" | jq -r '.id')
CONFIG_ID_BASE58=$(echo "$CONFIG" | jq -r '.idBase58')

# 3. Quote the fee for a donation credited to your donation source
curl "https://api.donate.gg/api/v2/configs/$CONFIG_ID_BASE58/fee?chainId=101&creditedAddress=$DONATION_SOURCE" \
  -H "donate-api-key: $DONATE_API_KEY"

# 4. Your fee program donates to $CONFIG_ID_BASE58 on-chain.

# 5. The coin page: the config's recipients as rows, in one call
curl "https://api.donate.gg/api/v2/configs/$CONFIG_ID_BASE58/beneficiaries" \
  -H "donate-api-key: $DONATE_API_KEY"
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.