Skip to main content
A donate button does four things: it knows who the money is for, it knows which contract to call on the donor’s chain, it tells the donor the fee, and it sends one transaction. Donate does the rest. The API calls are on https://api.donate.gg/api/v2.

1. Decide who the money is for

Let the person choose a beneficiary, or choose one yourself. Either way you end with a type and an id. Build a beneficiary picker covers the search. Then create a config for that choice on your server. A config is the thing a donation is made against.
The answer has the config’s id twice: id, the 32 bytes as 0x hex for an EVM chain, and idBase58, the same bytes for Solana. Store both. The same beneficiaries and weights always give the same config, so create it once per choice and reuse the id for every donor: the answer is 201 the first time and 200 after. Configs are permanent, and a donation through a config your project created pays a 20% fee today. See Concepts.

2. Find the contract on the donor’s chain

GET /v2/chains lists the chains a donation can be made on, with the contract or program a donation calls on each.
An example answer, with two of the chains:
This list changes rarely. The answer says so with Cache-Control: private, max-age=300: read it at startup and keep it for minutes, not per request.

3. Tell the donor the fee

A config has no fee on it. Ask for the fee that applies now, for the chain the donor pays on and the address the donation is credited to. The address below is a placeholder nobody holds: send the donor’s wallet.
An example answer:
feeBps is in basis points, so 2000 is 20%. The quote is an estimate and is not locked: ask again just before the donor signs, and if the call fails, say the fee is unavailable. See Fees.

4. Send the transaction

The transaction names the config id and nothing else about the recipients.
  • On Solana, call the Donation Relay program. Instructions, accounts and rent are on the Solana page.
  • On an EVM chain, call donateNative, donateToken or donateTokenWithPermit on the donationRelay.address for that chain. See EVM and Bridged EVM donations.
The credited address is the address the donation is attributed to, usually the donor’s wallet. It is also the creditedAddress you quoted the fee for.

5. Tell the donor what happens next

A confirmed transaction is not a finished donation. The money is converted to USDC, batched and then paid out, which can take a while for a small amount. Keep the transaction hash and show progress; do not ask the donor to send again. Track a donation shows how.

Runnable sequence