Skip to content

Premium sections

Premium sections let you sell individual sections of your website, such as a report, a score or an article. Visitors pay from their own wallet in a click, with no account or subscription, and you don't run any payment code.

Readers pay in XRP on the XRP Ledger, XAH on Xahau, or ETH, USDC and RLUSD on Ethereum.

<dhali-premium api="YOUR-API-ID" path="/reports/nova">
  <p>Preview: NOVA has 3 issuer controls. Unlock the full report.</p>
</dhali-premium>

Visitors see your teaser and an Unlock · price button. After they pay, your premium content replaces the teaser, styled by your own CSS.

Premium sections run on the same payment channels as API payments: the reader funds a channel once, each unlock is a signed off-chain payment checked in milliseconds, and payments are settled on-chain to your wallet.

How it works

  1. You put your premium content behind a URL and register it with Dhali, setting a price and currency.
  2. You wrap a teaser in a <dhali-premium> element on your page.
  3. A visitor clicks Unlock and approves a small budget in the Dhali wallet. The first time, this opens a popup. After that, each unlock is one click.
  4. Dhali checks the payment, fetches your content and shows it on the page. You're paid for every unlock.

Get started

1. Serve your premium content

Put your premium content at a URL, as an HTML fragment or JSON. One URL can serve many sections, one per path:

https://premium.your-site.example/reports/nova   →   <section>…full report…</section>

Make it accept only requests from Dhali, so nobody can skip payment. Dhali adds a secret header to every request it forwards. Refuse any request without it. Ready-made examples:

You have Use
Static HTML files, no server Cloudflare Worker
A Node.js app Express
A Python app FastAPI

2. Register it with Dhali

  1. Open the asset manager and link the wallet you want paid.
  2. Go to My Assets → Create, open the new API and click Edit.
  3. Set the Base URL (your URL from step 1), the Pricing (currency and price per unlock), and the Header secret (a name and a long random value, for example from openssl rand -hex 32).
  4. Save, and copy the API's ID from its endpoint URL: https://run.api.dhali.io/<api-id>.

3. Add it to your page

Add the script once, then one element per premium section:

<script src="https://cdn.jsdelivr.net/npm/dhali-premium@1.1.1/releases/v1.0.0/premium.js"
        integrity="sha384-eIiADuK4VnchTIWmxyyl8HWjzB/woYmitFYvfXAiX1RKMQQStC+Gvt0mbh0vkaLD"
        crossorigin="anonymous" type="module" async></script>

<dhali-premium api="YOUR-API-ID" path="/reports/nova">
  <p>Teaser shown before unlocking…</p>
</dhali-premium>

It's a standard HTML element, so it works anywhere you can add HTML and a script tag, including React, Vue and Svelte.

The <dhali-premium> element

Attribute Required Description
api yes Your Dhali API's ID.
path no Appended to your base URL. Defaults to /.
format no html (default) or json.
label no Button text. Defaults to Unlock. The price and currency are added automatically, for example Unlock report · 0.05 XRP.
  • The element's content is the teaser. Everyone sees it, including search engines, so write it with that in mind.
  • The price and currency come from Dhali, from your API's settings, so the button always shows what's actually charged.
  • JSON responses: with format="json", put a <template> inside the element and use {{field}} placeholders, with dots for nested values.
  • Events: the element fires dhali:unlocked (with the response and the amount paid) and dhali:error.

See the full reference for styling, events, self-hosting the script and Content-Security-Policy settings.

Pricing

  • You set the price per unlock. Every section on one API has the same price, so create a separate API for each price.
  • Each unlock also carries a small compute fee.
  • Visitors approve a small budget, slightly more than one unlock, and later unlocks draw from it. When it runs out, the button asks them to top up.

Your readers' wallets stay safe

  • Approvals stay with Dhali. The Unlock button runs in a Dhali frame, so no script on your page, even a compromised one, can read or spend a reader's approval.
  • Every payment needs a real click. Your page can't trigger a payment, and the button ignores clicks until it has been on screen for half a second.
  • Only paying visitors get your content. Your server refuses any request that doesn't carry Dhali's secret header.
  • The script is small, public and pinned. The integrity hash stops browsers running it if a single byte changes. Read the source.

FAQ

Do my visitors need a Dhali account? No, just a wallet that holds the currency you charge in. The Dhali wallet guides them through the rest.

Do I handle payments, keys or webhooks? No. Dhali checks every payment before your content is fetched.

Can I try it without a wallet or funds? Yes. Clone Dhali-premium, run npm run dev with Node.js 20 or later, and open http://localhost:4000. It runs an example site against a local stand-in for Dhali.