EIPs Explained

ERC-1328 · Final · ERC · 2018-08-15

ERC-1328: WalletConnect URI Format

Defines the wc: URI that a dapp shows as a QR code or link so a wallet can open an encrypted WalletConnect session with it.

What problem does it solve?

A dapp running in a desktop browser often needs to talk to a wallet on a phone, or to a separate wallet app on the same device. The two sides need a way to find each other and agree on an encryption key before any requests can flow.

WalletConnect solves this by having the dapp display a short URI, usually as a QR code or a deep link. The wallet scans or opens it, joins the same channel, and from then on both sides exchange encrypted messages. ERC-1328 standardizes the format of that URI so any wallet can parse it.

An earlier alpha version of WalletConnect put JSON in the QR code. Moving to a URI made parsing simpler and lets mobile operating systems route the link to the right app (for example via Android intents).

How it works

The syntax is:

wc:<topic>[@<version>][?<key>=<value>&...]
  • topic: identifies the channel both sides will use.
  • version: the WalletConnect protocol version. Versioning is part of the format so the protocol can evolve.
  • Parameters depend on the version.

Version 1:

Parameter Meaning
key Symmetric key used for encryption
bridge URL of the bridge server that relays messages

Version 2:

Parameter Meaning
symKey Symmetric key for encrypting messages over the relay
methods JSON-RPC methods supported for the pairing topic
relay-protocol Transport protocol for relaying messages
relay-data Optional transport data
expiryTimestamp Optional Unix time (seconds) when the pairing expires

Sample code

Shape of a v2 URI (placeholder values):

wc:<64-hex-topic>@2?relay-protocol=irn&symKey=<64-hex-key>&expiryTimestamp=1705934757

Parsing one in TypeScript:

function parseWcUri(uri: string) {
  const m = uri.match(/^wc:([^@?]+)(?:@(\d+))?(?:\?(.*))?$/);
  if (!m) throw new Error("not a WalletConnect URI");
  const [, topic, version, query = ""] = m;
  const params = Object.fromEntries(new URLSearchParams(query));
  return { topic, version: version ? Number(version) : undefined, params };
}

const { topic, version, params } = parseWcUri(scannedText);
if (version === 2) {
  console.log(topic, params["relay-protocol"], params.expiryTimestamp);
}

In real apps you would not parse this yourself: the WalletConnect SDKs generate the URI on the dapp side and consume it on the wallet side.

Things to know

  • Status: Final. The URI format itself is stable; the meaning of parameters is tied to the protocol version.
  • The URI carries a symmetric session key, so treat it as short-lived and only show it to the user who is connecting. It does not contain or expose the user's private keys.
  • Version 1 relied on bridge servers and has been retired by WalletConnect; current integrations use version 2.
  • For payment requests rather than session pairing, see the ethereum: URI formats in ERC-681 and ERC-831. Once connected, dapps typically talk to the wallet through an EIP-1193-style provider.

#walletconnect #uri #wallet #qr-code #connection

Details

Authors
ligi (@ligi), Pedro Gomes (@pedrouid)
Status
Final
Type
Standards Track / ERC
Created
2018-08-15
Required by

Machine-readable: Markdown · JSON