ERC-7962 · Review · ERC · 2025-05-16
ERC-7962: Key Hash Based Tokens
Token interfaces (KeyHash20 and KeyHash721) where owners are identified by keccak256 of a public key instead of an address, so holdings are not tied to a visible address and anyone can relay and pay gas for a signed transfer.
What problem does it solve?
In ERC-20 and ERC-721, the owner is an address. Addresses are public, reused, and easy to link to identities across apps and chains. The address that owns tokens also has to send the transaction and pay gas.
ERC-7962 replaces the owner address with a keyHash: keccak256(key), where key is a 65-byte uncompressed secp256k1 public key. No address is stored onchain. The owner proves control by revealing the key and an EIP-712 signature from the matching private key, and any account can submit that transfer, so a relayer or sponsor can pay the gas. The idea follows the privacy direction of stealth addresses (ERC-5564).
How it works
KeyHash721 (NFTs). ownerOf(tokenId) returns a bytes32 keyHash. transfer(tokenId, toKeyHash, key, signature, deadline) checks that keccak256(key) equals the current owner hash, that the signature comes from the address derived from key, and that the deadline has not passed.
KeyHash20 (fungible). balanceOf(bytes32 keyHash). Transfers work like a Bitcoin UTXO: transfer(fromKeyHash, toKeyHash, amount, key, signature, deadline, leftKeyHash) empties fromKeyHash, sends amount to the recipient and the remainder ("change") to leftKeyHash. The change hash must differ from both from and to, so any balance always sits under a key whose public key has not been revealed yet.
Common rules:
- Signatures use EIP-712 with per-keyHash
nonces(bytes32)and adeadline; contracts must expose the domain via ERC-5267eip712Domain(). - Signatures must be non-malleable (low
s,vof 27 or 28). - There is no
approve: keys are meant to be used once. - Every balance or ownership change must emit
KeyHashTransfer721/KeyHashTransfer20, so a wallet can rebuild holdings by filtering logs on keyHashes it controls.mint/destroyare optional and implementation-specific.
Sample code
Signing a KeyHash20 transfer for a relayer (ethers v6):
import { Wallet, keccak256 } from "ethers";
// assumes: token (Contract), relayer (Signer), toKeyHash, leftKeyHash, amount, deadline
const owner = new Wallet(process.env.OWNER_KEY!); // controls fromKeyHash
const key = owner.signingKey.publicKey; // uncompressed 0x04||X||Y (65 bytes)
const fromKeyHash = keccak256(key);
const domain = await token.eip712Domain().then(([, name, version, chainId, verifyingContract]) =>
({ name, version, chainId, verifyingContract }));
const types = { Transfer: [
{ name: "fromKeyHash", type: "bytes32" }, { name: "toKeyHash", type: "bytes32" },
{ name: "amount", type: "uint256" }, { name: "nonce", type: "uint256" },
{ name: "deadline", type: "uint256" }, { name: "leftKeyHash", type: "bytes32" },
]};
const msg = { fromKeyHash, toKeyHash, amount, nonce: await token.nonces(fromKeyHash),
deadline, leftKeyHash /* fresh key you control */ };
const signature = await owner.signTypedData(domain, types, msg);
// Any relayer can now submit and pay gas:
await token.connect(relayer).transfer(fromKeyHash, toKeyHash, amount, key, signature, deadline, leftKeyHash);
Things to know
- Status: Review. Function signatures and events may still change.
- Not compatible with ERC-20/721 tooling: balances and owners are
bytes32, not addresses, so existing wallets, DEXs and marketplaces need adapters. - Privacy is limited. The spec states that from/to/change hashes and amounts are all visible in calldata, so the transaction graph inside the contract is fully traceable, and once a key is revealed its address can be derived. It only avoids linking holdings to the wider address graph; amount or graph privacy needs extra tools such as zero-knowledge proofs.
- Losing the private key behind a keyHash means losing the tokens; generate and back up a fresh key for every change output.