ERC-6662 · Draft · ERC · 2023-03-09
ERC-6662: AA Account Metadata For Authentication
Draft ERC-4337 extension where a smart account publishes on-chain where its authenticator lives and what request format it accepts, so dApps can ask it to sign without a pre-connected wallet.
What problem does it solve?
Today a dApp only learns about your account after you "connect wallet": the wallet pushes your address to the site, and every signing request goes back through that live connection. With smart contract accounts (ERC-4337), the thing that actually authorizes operations could be anything: a phone app, a cloud signer, a hardware device. A dApp has no standard way to discover it.
ERC-6662 lets an account publish its authentication details once, on-chain. Given only your account address, a dApp can look up where to send a signing request and in what format.
How it works
There are three roles:
- Authenticator: whatever holds the key that signs your user operations (mobile app, online service, …).
- Relay: an online service that forwards requests from dApps to the authenticator. An online authenticator can be its own relay.
- dApp: reads the account's metadata and sends an
AuthenticationRequestto a relay.
The smart account implements IAccountMetadata alongside ERC-4337's IAccount:
getAuthenticationInfo()returns a list ofAuthenticatorInfo { string[] relayURI; string schema; }.relayURIlists relay endpoints; the dApp tries them in order and uses the first that works.schemais a JSON Schema (inline, or a URI, using ERC-4804web3://if stored on-chain) describing theAuthenticationRequest. A typical request carries the entry point address, chain ID, and an unsignedUserOperation.
Several AuthenticatorInfo entries can enable multisig: each authenticator signs independently and an ERC-4337 aggregator combines the signatures.
Sample code
The interface and a dApp-side lookup (ethers v6):
interface IAccountMetadata {
struct AuthenticatorInfo {
string[] relayURI; // where to send requests
string schema; // JSON schema or URI for AuthenticationRequest
}
function getAuthenticationInfo() external view returns (AuthenticatorInfo[] memory);
}
import { Contract } from "ethers";
const account = new Contract(smartAccountAddr, [
"function getAuthenticationInfo() view returns ((string[] relayURI, string schema)[])",
], provider);
const [first] = await account.getAuthenticationInfo();
const request = {
entrypoint: ENTRYPOINT_ADDRESS,
chainId: "0x1",
userOp: unsignedUserOp, // ERC-4337 UserOperation without signature
};
for (const uri of first.relayURI) {
const res = await fetch(uri, { method: "POST", body: JSON.stringify(request) });
if (res.ok) break; // first working relay wins
}
Things to know
- Status: Draft. No relay protocol, transport or authentication of the dApp itself is standardized; the schema is account-defined.
- Relays can see requests. The spec recommends end-to-end encryption, e.g. JWE, with the content key encrypted to the signer, so relays cannot read or front-run them.
- On-chain metadata is public: publishing relay URIs reveals which services back your account.
- The sample's request fields follow the example schema in the spec; real accounts may require different fields.