ERC-7837 · Final · ERC · 2024-12-07
ERC-7837: Diffusive Tokens
A fungible token where transfer mints new tokens to the recipient instead of moving the sender's, with a per-token ETH fee paid to the issuer and an owner-set supply cap.
What problem does it solve?
In an ERC-20 token, total supply is redistributed by transfers: if A sends 10 tokens to B, A has 10 fewer. ERC-7837 describes a different economic model, Diffusive Tokens (DIFF), aimed at cases where an issuer wants tokens to spread out on demand rather than be pre-minted and passed around.
The spec's example is a manufacturer issuing tokens for a batch of physical products: each token can later be burned to redeem one item. Holders "pass on" tokens by minting new ones to others, paying the issuer a fee for each, until a maximum supply is reached.
How it works
- Transfer mints.
transfer(to, amount)does not reduce the sender's balance. It mintsamountnew tokens totoand increasestotalSupply. - Native fee. The sender must pay
transferFee * amountin the chain's native currency viamsg.value; otherwise the call reverts. Fees accumulate in the contract. - Supply cap. A transfer that would push
totalSupplyabovemaxSupplyreverts. - Burn. Holders can
burn(amount)to reduce their balance and the total supply, for example to redeem the underlying good. - Owner controls. The owner can
setTransferFee,setMaxSupply(not below current supply) andwithdrawFees(recipient). - Optional approvals.
approve/transferFromexist for compatibility;transferFromconsumes allowance but still mints totowithout debitingfrom.
Events: Transfer, Burn, FeeUpdated, MaxSupplyUpdated.
Because transfer and transferFrom are payable and behave differently, DIFF is ERC-20 compatible only at the interface level, not in behavior.
Sample code
Core logic, condensed from the spec's reference implementation:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
contract DiffusiveToken {
uint256 public totalSupply;
uint256 public maxSupply;
uint256 public transferFee; // wei per token
address public owner;
mapping(address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 amount);
event Burn(address indexed burner, uint256 amount);
constructor(uint256 _maxSupply, uint256 _fee) {
maxSupply = _maxSupply;
transferFee = _fee;
owner = msg.sender;
}
function transfer(address to, uint256 amount) external payable returns (bool) {
require(to != address(0) && amount > 0, "bad args");
require(msg.value >= transferFee * amount, "insufficient fee");
require(totalSupply + amount <= maxSupply, "cap");
balanceOf[to] += amount; // sender keeps their balance
totalSupply += amount;
emit Transfer(msg.sender, to, amount);
return true;
}
function burn(uint256 amount) external {
balanceOf[msg.sender] -= amount; // reverts on underflow
totalSupply -= amount;
emit Burn(msg.sender, amount);
}
function withdrawFees(address payable to) external {
require(msg.sender == owner, "owner");
(bool ok, ) = to.call{value: address(this).balance}("");
require(ok, "withdraw failed");
}
}
Things to know
- Status is Final.
- Anyone can call
transferregardless of their own balance. As written in the spec, holding tokens is not required to mint them to others; the fee and the cap are the only limits. - DEXs, lending protocols and wallets assume ERC-20 transfers conserve supply. Integrating a DIFF token with them can produce wrong prices, accounting or balances, and
payabletransfers will fail in callers that send no value. - The owner can change the fee and raise the cap at any time, which is a significant trust assumption for holders.
- The spec's reference contract has bugs if copied literally (for example it reads
balancesandallowancesmappings it never declares); review and test before using any implementation.