Developer Guides

Getting Started

The quickest way to integrate PhotonBolt Wallet is to detect window.photon, prompt the user to connect, and cache the approved account in your app state.

Browser Extension

PhotonBolt Wallet is a browser extension. The provider is injected into standard HTTP and HTTPS pages. If the user installs the extension after opening your page, ask them to refresh so the provider is injected.

Recommended flow: detect the provider on page load, render an install CTA if it is missing, and enable your connect button only when the provider exists.

Console Playground

If the extension is installed, you can test it from the browser developer console before wiring it into your app.

Browser Console
window.photon && "PhotonBolt is ready"

Minimal Connect Example

This example checks for the provider, requests a connection, then stores the selected address and network in local state.

JavaScript
async function connectPhoton() {
  const photon = window.photon;

  if (!photon || !photon.isPhoton) {
    throw new Error("PhotonBolt Wallet is not installed.");
  }

  const result = await photon.connect();

  return {
    address: result.address,
    network: result.network,
    connected: result.connected,
  };
}

document.querySelector("#connectBtn").addEventListener("click", async () => {
  try {
    const session = await connectPhoton();
    console.log("Connected session", session);
  } catch (error) {
    console.error(error.message);
  }
});

Suggested App State

State Why Keep It
installed Controls whether to show install instructions or wallet actions.
connected Controls whether protected actions like sign or send are enabled.
address Lets you label the active account in the UI and logs.
network Protects against mainnet/testnet mismatches.
balance Lets you preview spendability before prompting a send approval.

Best Practices

  1. Never assume the extension is installed.
  2. Never assume the user already approved your origin.
  3. Always display the active network next to any amount field.
  4. Catch rejected approvals and show them as normal user actions, not application crashes.
  5. Re-read account and network after connection, because the wallet is the source of truth.