EIPs Explained

ERC-7795 · Draft · ERC · 2024-10-22

ERC-7795: Wallet Call Token Capabilities

Adds EIP-5792 capabilities that let a dapp state token prerequisites (a minimum ERC-20 balance, an allowance, NFT ownership) so the wallet can bridge, swap or approve first and then run the call.

What problem does it solve?

A dapp usually lives on one chain and expects one token. Users hold funds spread across many chains and assets. Today the dapp can only send the final transaction ("buy this NFT for 1,000 USDC on chain A"), and it is up to the user to figure out the steps before it: bridge, swap, approve. As the number of chains grows, this mismatch gets worse.

ERC-7795 lets the dapp describe what must be true before its call runs. The wallet, which knows the user's balances everywhere, works out how to make it true.

How it works

It defines six new EIP-5792 capabilities, each discoverable through wallet_getCapabilities ({ supported, versions }) and used in wallet_sendCalls:

Capability Requirement on owner
erc20MinBalance holds at least minAmount of token
erc20MinAllowance has approved operator for at least minAmount
erc721Ownership owns tokenId of token
erc721Approval has approved operator for tokenId
erc1155MinBalance holds at least minAmount of tokenId
erc1155MinAllowance has approved operator for minAmount of tokenId

Every requirement also carries version (currently "1.0") and the chainId it applies to. Amounts and IDs are hex strings.

The wallet should compute a way to meet the requirement and must ensure it is met before executing the main calls. An EOA wallet might prompt the user to sign a bridge transaction first; a smart contract wallet might have the user sign everything at once and hand the pieces to bundlers. Dapps can track progress with the usual wallet_getCallsStatus.

Splitting each token type into its own capability lets wallets support only what they can handle and version each requirement independently.

Sample code

Ask the wallet to ensure 1 USDC (6 decimals, 0x0f4240) on Ethereum mainnet before calling a contract:

const caps = await provider.request({ method: "wallet_getCapabilities", params: [account] });

if (caps["0x1"]?.erc20MinBalance?.supported) {
  await provider.request({
    method: "wallet_sendCalls",
    params: [{
      version: "1.0",
      from: account,
      calls: [{ to: shop, value: "0x0", data: buyCalldata, chainId: "0x1" }],
      capabilities: {
        erc20MinBalance: {
          version: "1.0",
          chainId: "0x1",
          owner: account,
          token: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
          minAmount: "0x0f4240",
        },
      },
    }],
  });
}

Things to know

  • Status is Draft. Capability names and parameter shapes may change, and wallet support is not guaranteed; always check wallet_getCapabilities first.
  • The spec leaves how the wallet satisfies a requirement (which bridge, which swap route) entirely to the wallet.
  • The allowance and approval capabilities do not imply the owner actually holds the tokens; combine with a balance capability if you need both.
  • Dapps may skip these capabilities and handle prerequisites themselves.
  • It composes with other EIP-5792 capabilities, for example ERC-7677 paymaster sponsorship.

#wallet #capabilities #cross-chain #token #intents

Details

Authors
Agustín Aguilar (@agusx1211), Michael Standen (@ScreamingHawk), Peter Kieltyka (@pkieltyka), William Hua (@attente), Philippe Castonguay (@PhABC)
Status
Draft
Type
Standards Track / ERC
Created
2024-10-22
Requires

Machine-readable: Markdown · JSON