EIPs Explained

ERC-6604 · Draft · ERC · 2023-03-03

ERC-6604: Abstract Token

A draft standard for tokens that live off-chain as signed or proven messages and are "reified" on-chain only when needed, making large airdrops and credentials free to mint.

What problem does it solve?

Minting costs gas. For high-volume, low-value distributions such as airdrops, POAP-style receipts or access credentials, paying to mint every token up front is wasteful, especially since many recipients never use them.

Projects already work around this with Merkle-tree claims, but each claim contract has its own proof format and UI, and a wallet cannot tell a user "you have these tokens waiting" without bespoke integration.

ERC-6604 defines abstract tokens: a token can exist as an off-chain message that anyone can inspect, and becomes a normal on-chain ERC-20, ERC-721 or ERC-1155 balance only when someone submits it.

How it works

Token message. The off-chain form of a token:

struct AbstractTokenMessage {
  uint256 chainId;        // where it can be reified
  address implementation; // which contract
  address owner;          // who receives it
  bytes   meta;           // implementation-specific: id, amount, uri…
  uint256 nonce;          // distinguishes otherwise-identical messages
  bytes   proof;          // Merkle proof, signature, etc.
}

Core methods on the token contract:

  • reify(message): validates the proof and mints the tokens on-chain. Each message can be used at most once; emits Reify.
  • status(message): returns invalid, valid or used, so a wallet can show pending tokens before anything is minted.
  • dereify(message) (optional): burns on-chain tokens and turns them back into a message for another contract or chain; emits Dereify.
  • id, amount, uri (optional): read what a message represents without parsing meta.

The contract must support ERC-165. Abstract versions of ERC-20/721/1155 add overloaded transfer functions that take a message as an extra argument, so a recipient can reify and transfer in a single call.

meta and proof are plain bytes on purpose, so any eligibility scheme (Merkle trees, issuer signatures, something new) fits.

Sample code

A wallet checking and claiming an abstract airdrop (ethers v6):

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

const abi = [
  "function status((uint256 chainId,address implementation,address owner,bytes meta,uint256 nonce,bytes proof)) view returns (uint8)",
  "function amount((uint256,address,address,bytes,uint256,bytes)) view returns (uint256)",
  "function reify((uint256,address,address,bytes,uint256,bytes))",
];
const provider = new JsonRpcProvider(process.env.RPC_URL);
const token = new Contract(tokenAddress, abi, new Wallet(process.env.PRIVATE_KEY!, provider));

// `msg` was handed to the user off-chain, e.g. by the project's API
const msg = [chainId, tokenAddress, owner, meta, nonce, proof];
const s = await token.status(msg);            // 0 invalid, 1 valid, 2 used
if (s === 1n) {
  console.log("claimable:", await token.amount(msg));
  await (await token.reify(msg)).wait();
}

Things to know

  • Status is Draft; names and signatures may change.
  • Message loss = token loss. Until reified, the token is only a message. Issuers should store messages for users, and ideally wallets would hold them.
  • If the contract reverts on an already-used message, anyone holding a copy can front-run and grief the owner's own reify call; the spec therefore allows a used message to succeed as a no-op instead of reverting.
  • Using dereify/reify as a bridge is unsafe on its own: chain B cannot know whether the message was dereified on chain A, so an oracle is needed to prevent double spending.
  • The proof scheme is out of scope; whether total supply is auditable depends entirely on the implementation's choice.

#token #airdrop #minting #off-chain #draft

Details

Authors
Chris Walker (@cr-walker) <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2023-03-03
Requires

Machine-readable: Markdown · JSON