Skip to main content

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.
const res = await fetch('https://www.donate.gg/api/v1/developer/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, and wallet addresses

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.
const res = await fetch('https://www.donate.gg/api/v1/developer/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 a bytes32 hex string; store this per player

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.
// Store config ID server-side per player
await db.player.update({
  where: { id: playerId },
  data: { donateConfigId: config.id },
});

// Pass to on-chain transaction
await sendDonationTransaction({
  configId: config.id,
  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. The entire integration is three API calls.

Charities

Browse the verified charity network

Configs

Create and manage donation configs