Payment data types produce standardised cryptocurrency payment request URIs that are recognised by all major wallet applications. A single scan pre-fills the recipient address, the requested amount, and optional metadata so the payer never has to type an address by hand.
These data types generate standard bitcoin: and ethereum: scheme URIs.
They are compatible with wallets including MetaMask, Trust Wallet, Coinbase
Wallet, BlueWallet, Muun, and any other app that implements BIP-21 (Bitcoin)
or EIP-681 (Ethereum).
Bitcoin (BTC)
QrCode::BTC() produces a BIP-21 bitcoin: payment URI. Pass the recipient address and amount, with optional label, message, and return URL.
Signature
QrCode::BTC(
string $address,
float|string $amount,
?string $label = null,
?string $message = null,
?string $returnAddress = null,
)
The recipient Bitcoin address. Must be a non-empty string.
The amount in BTC. Must be a positive numeric value. Pass as a string (e.g.
'0.005') to avoid floating-point precision issues with very small values.
A human-readable label for the payment destination, shown in the wallet UI
(maps to the label query parameter).
A message or note to attach to the payment request (maps to the message
query parameter).
A URL the wallet should redirect to after the transaction is broadcast (maps
to the r query parameter).
Examples
use Linkxtr\QrCode\Facades\QrCode;
// Minimal — address and amount only
$qr = QrCode::BTC('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', 0.005);
// With label and message
$qr = QrCode::BTC(
address: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
amount: 0.0034,
label: 'Donation',
message: 'Thanks for supporting open source!',
);
// With a return URL
$qr = QrCode::BTC(
address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7Divf',
amount: 0.01,
label: 'Order #1042',
returnAddress: 'https://shop.example.com/orders/1042/confirm',
);
// Render as a 400 px SVG inline
echo QrCode::BTC('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', 0.0034)
->size(400)
->generate();
// Save to disk as PNG
QrCode::BTC('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', 0.005)
->format('png')
->size(400)
->generate(storage_path('app/qrcodes/btc-payment.png'));
Passing an empty address or a non-numeric amount throws an
InvalidBTCArgumentException. Always validate wallet addresses from user
input before encoding them.
Ethereum
QrCode::Ethereum() produces an EIP-681 ethereum: payment URI. Pass the wallet address and an optional amount denominated in ETH.
Signature
QrCode::Ethereum(
string $address,
float|string|null $amount = null,
)
The recipient Ethereum address. Must be a non-empty string (e.g. an EIP-55
checksummed address).
The requested amount in ETH. Omit or pass null to create an address-only QR
code with no fixed amount.
Examples
use Linkxtr\QrCode\Facades\QrCode;
// Address only — no fixed amount
$qr = QrCode::Ethereum('0x742d35Cc6634C0532925a3b8D2b2CE1e5bfb043d');
// With a fixed ETH amount
$qr = QrCode::Ethereum('0x742d35Cc6634C0532925a3b8D2b2CE1e5bfb043d', 1.5);
// Small amount — string form avoids floating-point precision issues
$qr = QrCode::Ethereum('0x742d35Cc6634C0532925a3b8D2b2CE1e5bfb043d', '0.005');
// Render inline as SVG
echo QrCode::Ethereum('0x742d35Cc6634C0532925a3b8D2b2CE1e5bfb043d', 0.1)
->size(400)
->generate();
// Save as PNG
QrCode::Ethereum('0x742d35Cc6634C0532925a3b8D2b2CE1e5bfb043d', 1.5)
->format('png')
->size(400)
->generate(storage_path('app/qrcodes/eth-payment.png'));
Pass the amount as a string (e.g. '0.005') rather than a float when
dealing with very small values to avoid PHP floating-point representation
issues producing an invalid URI.
An empty address or a non-numeric amount throws an
InvalidEthereumArgumentException. Validate the address format before
encoding user-supplied values.