EIPs Explained

ERC-6809 · Final · ERC · 2023-03-31

ERC-6809: Non-Fungible Key Bound Token

An ERC-721 variant where the holder can bind two 'key wallets' that must approve each transfer or approval and can rescue the NFTs if the holding wallet is compromised.

What problem does it solve?

With self-custody, if your private key or seed phrase leaks, an attacker can move your NFTs immediately and nobody can reverse it. Most protection lives in the wallet (hardware devices, multisigs), not in the asset itself.

ERC-6809, the Non-Fungible Key Bound Token (NFKBT), builds optional protection into the token contract. The holder can bind two extra wallets ("key wallets"). After that, the holding wallet cannot move or approve its NFTs unless a key wallet has allowed it first. If the holding wallet is stolen, a key wallet can move everything to safety. If the holder never turns this on, the token behaves like a normal ERC-721. Its fungible counterpart is ERC-6808.

How it works

Three wallets once security is active: the holding wallet (owns the NFTs) and key wallets 1 and 2.

  • addBindings(keyWallet1, keyWallet2), called by the holder, activates protection. It should revert if the wallets are equal, zero, the same as the holder, or already bound to another holder.
  • allowTransfer(tokenId, time, to, anyToken), called by a key wallet, unlocks a transfer. 0 for tokenId, time or to means "no restriction" on that field; anyToken = true allows any token to anyone. Then the holder calls the usual transferFrom / safeTransferFrom.
  • allowApproval(time, numberOfTransfers), called by a key wallet, opens a window in which the holder may call approve / setApprovalForAll. It also limits how many transfers the spender may make (0 = unlimited); when the count is used up, the approval is revoked.
  • safeFallback(), called by a key wallet, moves all of the holder's tokens to the other key wallet. Use it when the holding wallet is compromised.
  • resetBindings(), called by a key wallet, removes the bindings so the holder can set new key wallets. Use it when a key wallet is compromised.
  • Views: getBindings, getTransferableFunds, getApprovalConditions, isSecureWallet, isSecureToken.

Sample code

Activating protection and making a guarded transfer (ethers v6):

const abi = [
  "function addBindings(address keyWallet1, address keyWallet2) returns (bool)",
  "function allowTransfer(uint256 tokenId, uint256 time, address to, bool anyToken) returns (bool)",
  "function safeFallback() returns (bool)",
  "function transferFrom(address from, address to, uint256 tokenId)",
];
const asHolder = new Contract(NFKBT, abi, holder);
const asKey1 = new Contract(NFKBT, abi, keyWallet1);

// 1. Holder binds two key wallets (do this from a clean wallet)
await (await asHolder.addBindings(keyWallet1.address, keyWallet2.address)).wait();

// 2. Key wallet allows token #7 to go to `buyer` (no time limit)
await (await asKey1.allowTransfer(7n, 0n, buyer, false)).wait();

// 3. Holder can now transfer it; any other transfer reverts
await (await asHolder.transferFrom(holder.address, buyer, 7n)).wait();

// Emergency: holder key leaked -> move everything to key wallet 2
await (await asKey1.safeFallback()).wait();

Things to know

  • Status: Final.
  • Security depends on keeping the three wallets independent. If an attacker controls the holder and one key wallet, protection is gone. If they control one key wallet alone, they can call safeFallback (sending tokens to the other key wallet, by design) or resetBindings.
  • Protection only covers NFTs held directly by the secured holder in this contract. It does nothing for other tokens in the same wallet.
  • The spec has some internal inconsistencies (for example allowApproval is shown with one parameter in one place and two in another, and event parameter names vary). Check the reference implementation in the EIP assets before integrating.
  • Marketplaces that rely on standing setApprovalForAll approvals may not work smoothly with secured accounts, because approvals are time-boxed and transfer-limited.

#nft #security #erc721 #wallet #recovery

Details

Authors
Mihai Onila (@MihaiORO), Nick Zeman (@NickZCZ), Narcis Cotaie (@NarcisCRO)
Status
Final
Type
Standards Track / ERC
Created
2023-03-31
Requires

Machine-readable: Markdown · JSON