|
| 1 | +--- |
| 2 | +title: "Wallet Address Smart Redirect" |
| 3 | +description: "One Wallet Address, Two Experiences: Introducing Wallet Address Smart Redirect in Rafiki" |
| 4 | +date: 2025-09-02 |
| 5 | +slug: wallet-address-smart-redirect |
| 6 | +authors: |
| 7 | + - Cozmin Ungureanu |
| 8 | +author_urls: |
| 9 | + - https://www.linkedin.com/in/nodejs-dev/ |
| 10 | +tags: |
| 11 | + - Interledger |
| 12 | + - Rafiki |
| 13 | +--- |
| 14 | + |
| 15 | +When you think of a **wallet address**, you probably think of a string of characters (or in Open Payments's case, a neat URL) that acts as a source or destination for payments. For example: |
| 16 | + |
| 17 | +`https://ilp.interledger.cards/007` |
| 18 | + |
| 19 | +Traditionally, when an Open Payments client queries that address, it receives a structured JSON: |
| 20 | + |
| 21 | +```json |
| 22 | +{ |
| 23 | + "id": "https://ilp.interledger.cards/007", |
| 24 | + "publicName": "John Doe", |
| 25 | + "assetCode": "EUR", |
| 26 | + "assetScale": 2, |
| 27 | + "authServer": "https://auth.interledger.cards", |
| 28 | + "resourceServer": "https://ilp.interledger.cards" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +This is perfect for developers and systems that need machine-readable data. But what about people? |
| 33 | + |
| 34 | +If someone clicks that same wallet address in a browser, JSON isn't exactly a friendly experience. That's where our new **Wallet Address Smart Redirect** comes in. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## What's new? |
| 39 | + |
| 40 | +As of v1.1.2-beta, enabling **Smart Redirect**, Rafiki detects when a request is coming from a browser (using the `Accept: text/html` header). Instead of showing raw JSON, the request automatically redirects to a user-friendly payment page defined in your environment settings. |
| 41 | + |
| 42 | +For example, when opened in a browser, `https://ilp.interledger.cards/007` redirects to: |
| 43 | +`https://interledgerpay.com/payment-choice?receiver=https://ilp.interledger.cards/007` |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +The result: **a single wallet address that works seamlessly for both developers and end-users.** |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Example in Action |
| 52 | + |
| 53 | +Let's say **Alice wants to send money to Bob**. |
| 54 | + |
| 55 | +1. Bob shares his wallet address: `https://ilp.interledger.cards/007` |
| 56 | +2. Alice pastes that link into her browser. |
| 57 | +3. Instead of confusing JSON, Alice is redirected straight to Bob's payment page (configured by the wallet operator). |
| 58 | +4. Alice chooses her payment method and completes the transfer. |
| 59 | + |
| 60 | +Meanwhile, behind the scenes: |
| 61 | + |
| 62 | +- If Alice's wallet operator queried Bob's wallet address directly, it would still get the standard JSON response. |
| 63 | +- One address, two different but perfectly matched experiences. |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Why it matters |
| 68 | + |
| 69 | +- **One address, two roles**: The same URL can serve structured data for APIs _and_ a human-friendly payment experience for browsers. |
| 70 | +- **Frictionless payments**: Users who aren't developers don't have to stare at JSON—they land on a simple payment page. |
| 71 | +- **Configurable**: You control where browser requests are redirected by setting the URL in your environment variable. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Configuration |
| 76 | + |
| 77 | +Enable **Wallet Address Smart Redirect** by setting a single environment variable: |
| 78 | + |
| 79 | +```bash |
| 80 | +WALLET_ADDRESS_REDIRECT_HTML_PAGE="https://interledgerpay.com/payment-choice?receiver=%ewa" |
| 81 | +``` |
| 82 | + |
| 83 | +### Header behavior |
| 84 | + |
| 85 | +- If the request has `Accept` header with `text/html`, Rafiki **redirects** to the URL from `WALLET_ADDRESS_REDIRECT_HTML_PAGE` (after substituting tokens below). |
| 86 | +- Otherwise, Rafiki returns the standard **JSON** response (no redirect). |
| 87 | + |
| 88 | +### URL tokens (drop-in placeholders) |
| 89 | + |
| 90 | +You can compose the redirect URL using these tokens: |
| 91 | + |
| 92 | +| Token | What it inserts | Example redirect template | Example resolved URL (for `http://ilp.dev/007`) | |
| 93 | +| ------ | ------------------------------------ | -------------------------------- | ------------------------------------------------------ | |
| 94 | +| `%wa` | Full wallet address including scheme | `http://rafiki.dev/%wa` | `http://rafiki.dev/http://ilp.dev/007` | |
| 95 | +| `%ewa` | URI-encoded full wallet address | `http://rafiki.dev/?wallet=%ewa` | `http://rafiki.dev/?wallet=http%3A%2F%2Filp.dev%2F007` | |
| 96 | +| `%wp` | Host + path (no scheme) | `http://rafiki.dev/%wp` | `http://rafiki.dev/ilp.dev/007` | |
| 97 | +| `%ewp` | URI-encoded host + path (no scheme) | `http://rafiki.dev/?wallet=%ewp` | `http://rafiki.dev/?wallet=ilp.dev%2F007` | |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## How to use it |
| 102 | + |
| 103 | +1. Set `WALLET_ADDRESS_REDIRECT_HTML_PAGE` in your `backend` environment variables. |
| 104 | +2. Choose the right token for your redirect style. |
| 105 | +3. That's it, your wallet addresses now double as developer endpoints _and_ payment links. |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## Looking ahead |
| 110 | + |
| 111 | +**Wallet Address Smart Redirect** is another step toward making Rafiki wallets more accessible, discoverable, and user-friendly. Whether you're a developer integrating APIs or a user just trying to send money, one address now does it all. |
0 commit comments