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

# Use Case

> Example: add donations to a game

## The developer: Marcus, CTO at a Web3 gaming studio

Marcus's studio ships a play-to-earn game where players earn tokens for in-game achievements. He wants to let players donate a portion of their earnings to charity directly from the game, without his team having to vet charities, handle custody, or touch any of the crypto-to-USD conversion.

He signs up for Donate.gg API access, gets an API key, and integrates in an afternoon.

***

## Step 1: Browse verified charities

Marcus fetches the charity list to populate a picker in his game UI. Players choose which cause their donations support.

```javascript theme={null}
const res = await fetch('https://www.donate.gg/api/v1/charities?limit=50', {
  headers: { 'donate-api-key': process.env.DONATEGG_API_KEY },
});
const { response: charities } = await res.json();
// charities is an array of verified nonprofits with names, logos, mission, and social links
```

***

## Step 2: Create a config for the player's selection

When a player confirms their charity choices, Marcus's backend creates a config with their selected charities and weights. Creating configs requires the **`partner`** scope.

```javascript theme={null}
const res = await fetch('https://www.donate.gg/api/v1/configs', {
  method: 'POST',
  headers: {
    'donate-api-key': process.env.DONATEGG_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    charityBeneficiaries: [
      { charityId: 'charity_abc', weight: 70 }, // 70% to St. Jude
      { charityId: 'charity_def', weight: 30 }, // 30% to Red Cross
    ],
  }),
});

const config = await res.json();
// config.id is { hex: "0x...", base58: "..." }
// Use config.id.hex as the on-chain configId (bytes32), or config.id.base58 for Solana
```

***

## Step 3: Use the config ID on-chain

Marcus stores the config ID against the player's account. When a player triggers a donation in-game, the client-side transaction references the config ID directly, and Donate.gg routing handles the rest.

```javascript theme={null}
// Store config ID server-side per player
await db.player.update({
  where: { id: playerId },
  data: { donateConfigId: config.id.hex },
});

// Pass to on-chain transaction (use .hex for EVM, .base58 for Solana)
await sendDonationTransaction({
  configId: config.id.hex,
  amount: donationAmount,
  token: selectedToken,
});
```

***

## The outcome

Players donate crypto from their in-game wallets. Donate.gg converts and routes funds to the charities the player selected. Each charity receives USD directly to their bank account.

Marcus's team ships the feature without building any charity verification, custody, or payout infrastructure. In practice that's about three API calls.

<CardGroup cols={2}>
  <Card title="Charities" icon="building-columns" href="/core-api/charities">
    Browse the verified charity network
  </Card>

  <Card title="Configs" icon="sliders" href="/partner-api/donation-configs">
    Create and list donation configs
  </Card>
</CardGroup>
