EIPs Explained

ERC-681 · Final · ERC · 2017-08-01

ERC-681: URL Format for Transaction Requests

Defines ethereum: URLs for payment and transaction requests, so a QR code or link can open any wallet with the recipient, amount, token and chain already filled in.

What problem does it solve?

Bitcoin's bitcoin: URLs made "scan to pay" easy: a shop shows a QR code, your wallet opens with the address and amount ready. Ethereum had no common format, so each wallet and point-of-sale app invented its own, or users copied addresses by hand.

ERC-681 standardizes an ethereum: URL that any wallet can parse. It covers plain ether payments, ERC-20 token payments and, more generally, calls to any contract function.

How it works

The syntax:

ethereum:[pay-]<address>[@<chain_id>][/<function>][?<params>]
  • address: a 0x hex address or an ENS name (ERC-137). Mandatory.
  • chain_id: optional decimal chain ID. Without it, the wallet uses its current network.
  • function: optional. If omitted, the URL asks for a native ether payment. If present, it names a contract function to call.
  • params: value, gasLimit (or gas), gasPrice, or ABI type names such as address= and uint256= for function arguments.

Amounts are in the smallest unit (wei, or token base units) and may use scientific notation. value=2.014e18 means 2.014 ETH. Only integers are allowed, so the exponent must cover all decimals.

All values are suggestions: the wallet shows them to the user, who may edit them before signing.

Sample code

Example URLs:

# Pay 2.014 ETH
ethereum:0xfb6916095ca1df60bb79Ce92ce3ea74c37c5d359?value=2.014e18

# Same, but only on chain 1 (mainnet)
ethereum:0xfb6916095ca1df60bb79Ce92ce3ea74c37c5d359@1?value=2.014e18

# ERC-20: call transfer(address,uint256) on the token contract
ethereum:<tokenAddress>/transfer?address=<recipient>&uint256=1e6

Building a token request in TypeScript (ethers v6):

import { getAddress, parseUnits } from "ethers";

function erc681Transfer(token: string, to: string, amount: string, decimals: number, chainId = 1) {
  const units = parseUnits(amount, decimals);          // e.g. "1.5", 6 -> 1500000n
  return `ethereum:${getAddress(token)}@${chainId}/transfer` +
         `?address=${getAddress(to)}&uint256=${units}`;
}

Things to know

  • For tokens, the URL targets the token contract, and the recipient goes in the address parameter. Mixing these up sends a request to the wrong place.
  • Hex addresses always take precedence over ENS names. A wallet must never try to resolve something that looks like 0x + 40 hex digits as ENS, which blocks a phishing trick.
  • URLs can be tampered with in transit. Only trust payment links from authenticated sources, and show the amount clearly, ideally in token units using the contract's decimals().
  • Without @chain_id, the wallet uses whatever network it is on. Include the chain ID for anything outside mainnet so a payment is not sent on the wrong chain.
  • ERC-681 supersedes the older ERC-67 format and stays compatible with it for the simple "address only" case. The pay- prefix is reserved so future incompatible versions can use a different prefix.

#wallet #uri #payments #qr-code

Details

Authors
Daniel A. Nagy (@nagydani)
Status
Final
Type
Standards Track / ERC
Created
2017-08-01
Requires
Required by

Machine-readable: Markdown · JSON