Skip to main content

Overview

TransactionUrl is a branded string type implementing the ERC-681 standard for representing Ethereum transactions as URLs. This enables QR code generation, deep linking, and wallet integrations.

URL Format

ERC-681 defines the format: ethereum:<address>[@<chainId>][/<function>][?<params>] Examples:
  • ethereum:0x1234... - Simple transfer to address
  • ethereum:0x1234@1 - Transfer on mainnet (chainId 1)
  • ethereum:0x1234@1?value=1000000000000000000 - Transfer 1 ETH
  • ethereum:0x1234/transfer?address=0x5678&uint256=100 - ERC-20 transfer call

Type Definitions

Creating TransactionUrls

from

Create a branded TransactionUrl from a string. Validates the URL format.
Throws InvalidTransactionUrlError if the URL is malformed.

format

Build a URL from transaction parameters.

Parsing TransactionUrls

parse

Parse a URL string into its components.
Supported query parameters:
  • value - Wei amount (decimal or hex with 0x)
  • gas - Gas limit
  • gasPrice - Gas price in wei
  • data - Hex-encoded calldata (0x…)
  • Other parameters are stored in functionParams
Throws InvalidTransactionUrlError for:
  • Missing ethereum: scheme
  • Invalid address
  • Invalid chain ID
  • Malformed numeric parameters
  • Invalid hex data

Error Handling

InvalidTransactionUrlError

Thrown when URL operations fail. Extends InvalidFormatError from the error hierarchy.
Properties: Error details include contextual information:
  • url - The malformed URL
  • scheme - For scheme errors
  • address - For address errors
  • chainId - For chain ID errors
Example:

Use Cases

QR Code Generation

ERC-20 Token Transfers

See Also