Skip to content
CertadocsGet a sandbox key

Guides

Add the Lock button to your page

The Lock button shows the customer the guaranteed amount, fee, deposit and settlement date, and locks on a click. It runs in the browser, so it never gets your API key: your server gives it a short-lived customer token.

1. A customer token, from your server

// Valid 15 minutes, for one customer, from one origin. It can only quote, lock and read.
const { token } = await certa.customerTokens.create({
  customerId,
  origin: "https://shop.example.com",
});

2. The button, in your page

<script src="https://unpkg.com/@certa-fx/widget@0.2.0/dist/certa-widget.js"></script>
<certa-lock-button
  api-url="https://sandbox-api.example.com"
  token="ct_test_…"
  customer-id="…"
  amount="10000000"
  tenor="604800"
  terms-url="https://example.com/terms"
></certa-lock-button>
<script>
  document.querySelector("certa-lock-button")
    .addEventListener("certa-locked", (e) => saveLock(e.detail.lockId));
</script>

Or in React:

import { LockButton } from "@certa-fx/widget/react";

<LockButton apiUrl={apiUrl} token={token} customerId={customerId}
  amount="10000000" tenor={604800} onLocked={(lock) => saveLock(lock.id)} />

3. Live mode: the customer signs

With execution="unsigned", the button hands the lock's transactions to your onTransactions callback, which signs them with the customer's wallet. The widget has no wallet library inside.

Theming

Set theme to light, dark or auto, and override CSS variables such as --certa-accent and --certa-radius on the element. Keep text contrast at 4.5:1 or more.