ERC-7722 · Draft · ERC · 2024-06-09
ERC-7722: Opaque Token
A privacy-oriented token design where on-chain balances are stored only as salted hashes ("baskets"), with the real amounts kept off-chain and oracles checking that splits and merges preserve value.
What problem does it solve?
Smart contract accounts are useful as reusable on-chain identities: claims and attestations (KYC status, accreditation, etc.) can be attached to them. But an ERC-20 token stores every balance in plain text, so as soon as such an identity holds tokens, anyone can see its holdings. For regulated financial instruments that is often unacceptable.
ERC-7722 trades ERC-20 compatibility for confidentiality. The chain records who owns which hash, not how much they hold.
How it works
Baskets. A position is represented on-chain as
keccak256(abi.encode(salt, tokenId, value))
The random 32-byte salt makes brute-forcing the value impractical. The contract only tracks the owner of each basket hash.
Roles.
- Token operator (typically the issuer or registrar) creates tokens, holds the non-circulating supply baskets, issues baskets to investors, and runs the off-chain basket store.
- Token users hold baskets and can transfer, reorganise or redeem them.
Core functions. createToken, issue, transfer (move whole baskets to a receiver), redeem (return baskets to supply), and reorgHolderBaskets / reorgSupplyBaskets (split or merge baskets).
Reorg oracles. Since the contract cannot see amounts, a reorg must be co-signed by a configurable minimum number of oracles. An oracle's POST reorg endpoint checks that, per tokenId, the input values sum to the output values and that each hash matches its data, then signs keccak256(abi.encode(basketsIn, basketsOut)). Oracles must be stateless and must not keep the data.
Off-chain storage. The operator must offer authenticated PUT baskets / GET baskets REST endpoints and share basket contents only with current or past holders. Holders should keep their own copy too.
Noise. To hide flows, holders are encouraged to re-split received baskets (so the sender cannot follow them) and to send zero-value baskets to random addresses, so observers cannot tell which transfers carry value.
Sample code
Computing a basket hash off-chain (ethers v6):
import { AbiCoder, keccak256, hexlify, randomBytes, id } from "ethers";
const coder = AbiCoder.defaultAbiCoder();
const salt = hexlify(randomBytes(32));
const tokenId = id("BOND-2030"); // any unique bytes32 within the contract
const value = 1_000n;
const basket = keccak256(coder.encode(["bytes32", "bytes32", "uint256"], [salt, tokenId, value]));
// Store {basket, data: {salt, tokenId, value}} via the operator's PUT baskets endpoint,
// then transfer the basket on-chain:
// await token.transfer([basket], receiver, ref);
Interface excerpt (Solidity):
interface IOpaqueToken {
struct SIGNATURE { uint8 v; bytes32 r; bytes32 s; }
function owner(bytes32 basket) external view returns (address);
function transfer(bytes32[] calldata baskets, address receiver, bytes32 ref) external;
function reorgHolderBaskets(
SIGNATURE[] calldata reorgOracleSignatures,
bytes32[] calldata basketsIn,
bytes32[] calldata basketsOut,
bytes32 ref
) external;
function redeem(bytes32[] calldata baskets, bytes32 ref) external;
}
Things to know
- Status: Draft. The Security Considerations (fraudulent oracles, oracles collecting data, data loss) are still TODO.
- Not ERC-20 compatible, by design; standard wallets and DeFi protocols will not understand it.
- Trust is shifted to the operator (data availability and access control) and to the oracle set (correct sums). The spec mentions zero-knowledge proofs as a stronger alternative but chooses oracles for simplicity.
- Observers can still see who interacts with whom; only amounts are hidden, and noise only makes flows harder to read.
- The design targets permissioned, KYC-heavy financial settings rather than open DeFi.