EIPs Explained

ERC-6353 · Stagnant · ERC · 2022-05-13

ERC-6353: Charity token

An ERC-20 extension that lets each holder opt in to automatically donating an extra percentage of every transfer to a charity address whitelisted by the token owner.

What problem does it solve?

Charities increasingly have on-chain addresses, and some token holders want to give a little every time they move tokens. Without a standard, each project builds its own donation logic, and wallets or dApps cannot discover which charities a token supports or at what rate.

ERC-6353 defines a common ERC-20 extension so that donation settings can be queried and set the same way on any compliant token. The same mechanism could also drive automated savings.

How it works

  • Owner side: the token owner reviews and whitelists charity addresses, each with a non-zero rate, and sets a global default (minimum) rate. Events such as AddedToWhitelist and ModifiedCharityRate record changes.
  • Holder side: a holder picks a default charity with setSpecificDefaultAddress, or setSpecificDefaultAddressAndRate to give more than the minimum. deleteDefaultAddress turns donations off.
  • On transfer: when donations are active, transfer / transferFrom move the requested amount to the recipient and an additional donation amount to the charity, emitting two Transfer events. If the sender can't cover both, the whole transfer reverts.
  • Discovery: charityInfo(addr) returns whether an address is whitelisted and its rate; specificDefaultAddress() and getRate() show the caller's current setting.
  • The interface extends ERC-165 with id 0x557512b6.

Donations are percentage-based in the reference design, but the spec lets implementers compute them differently, or accumulate them for the charity to claim later.

Sample code

Opting in as a holder (ethers v6):

import { Contract, Wallet, JsonRpcProvider, parseUnits } from "ethers";

const abi = [
  "function charityInfo(address) view returns (bool whitelisted, uint256 defaultRate)",
  "function setSpecificDefaultAddress(address)",
  "function specificDefaultAddress() view returns (address)",
  "function getRate() view returns (uint256)",
  "function transfer(address,uint256) returns (bool)",
];
const signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));
const token = new Contract(tokenAddress, abi, signer);

const [ok, rate] = await token.charityInfo(charity);
if (!ok) throw new Error("charity not whitelisted");
await (await token.setSpecificDefaultAddress(charity)).wait();

// From now on, each transfer also sends a donation to `charity`.
await token.transfer(friend, parseUnits("100", 18));

Things to know

  • Status is Stagnant; it is not a widely adopted standard.
  • The spec does not fix the units or precision of rate; check the implementation before computing expected donations.
  • A transfer of X costs the sender more than X when donations are on. Contracts and integrations that assume balanceBefore - X == balanceAfter can break, which is the backwards-compatibility caveat the authors note.
  • The token owner controls the charity whitelist and minimum rate, so holders are trusting that owner's choices.

#token #erc20 #donation #extension

Details

Authors
Aubay <[email protected]>, BOCA Jeabby (@bjeabby1507), EL MERSHATI Laith (@lth-elm), KEMP Elia (@eliakemp)
Status
Stagnant
Type
Standards Track / ERC
Created
2022-05-13
Requires

Machine-readable: Markdown · JSON