Implementing QR Code for Receiving Crypto Payments in a Mobile App
A QR code for receiving payment isn't just an address in a square. A proper URI format allows the payer to automatically fill in the amount and currency in their wallet. Incorrect size or missing error correction means half the scanners won't read it.
URI Formats for Different Blockchains
Standard formats recognized by most wallets:
-
Bitcoin (BIP-21):
bitcoin:1A2B3C4D5E6F?amount=0.001&label=Order+123 -
Ethereum (EIP-681):
ethereum:0xAbCd1234@1?value=500000000000000000(value in wei) -
ERC-20 transfer (EIP-681):
ethereum:0xTokenAddress@1/transfer?address=0xRecipient&uint256=1000000(USDC, 6 decimals) -
Solana (SPL):
solana:RecipientPubkey?amount=0.5&spl-token=TokenMintAddress&label=Payment
EIP-681 for ERC-20 is unintuitive: first the token contract address, then the transfer method with recipient and amount. Many wallets support a simpler format: ethereum:0xRecipient?value=X&contractAddress=0xToken.
QR Generation with Proper Parameters
// iOS — QR generation via CoreImage with correct correction level
import CoreImage.CIFilterBuiltins
func generateQRCode(from string: String, size: CGFloat = 300) -> UIImage {
let filter = CIFilter.qrCodeGenerator()
filter.message = Data(string.utf8)
filter.correctionLevel = "Q" // 25% error correction — for logo on top of QR
let transform = CGAffineTransform(scaleX: size / filter.outputImage!.extent.width,
y: size / filter.outputImage!.extent.height)
let scaledImage = filter.outputImage!.transformed(by: transform)
// Nearest neighbor interpolation for sharpness
let context = CIContext()
let cgImage = context.createCGImage(scaledImage, from: scaledImage.extent)!
return UIImage(cgImage: cgImage)
}
// Android — ZXing with custom size
import com.google.zxing.BarcodeFormat
import com.google.zxing.EncodeHintType
import com.google.zxing.qrcode.QRCodeWriter
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
val hints = mapOf(
EncodeHintType.ERROR_CORRECTION to ErrorCorrectionLevel.Q,
EncodeHintType.MARGIN to 1,
EncodeHintType.CHARACTER_SET to "UTF-8"
)
val bitMatrix = QRCodeWriter().encode(uri, BarcodeFormat.QR_CODE, 512, 512, hints)
Error correction level Q (25%) is optimal if you plan to overlay a logo on the QR. Without a logo, M (15%) is sufficient.
Dynamic Amount and Token Selection
If the app has an amount input field before QR generation — the URI updates on each amount change. For ERC-20, account for decimals when forming the value:
// Android — value calculation for USDC (6 decimals)
val humanAmount = BigDecimal("100.50") // user input
val decimals = 6
val rawAmount = humanAmount.movePointRight(decimals).toBigInteger() // 100500000
val uri = "ethereum:${usdcContractAddress}@1/transfer?address=${recipientAddress}&uint256=$rawAmount"
Branding Over QR
An app logo in the QR center is standard practice. The central zone up to 30% of the area is safe at correction level Q. The logo should be a white square with an icon to avoid disrupting QR module contrast.
Timeline: 1 day for QR generation via correct URI format, amount input field, "Copy" and "Share" buttons, optional logo in the center.







