Developer Guides

Balances and Transactions

PhotonBolt’s provider exposes a narrow, Bitcoin-focused transaction API. Use it to read the active balance, import regtest RGB assets, produce signed transaction hex, or request a full send flow with user approval.

Read Balance

JavaScript
async function loadBalance() {
  const balanceBtc = await window.photon.getBalance();
  document.querySelector("#balance").textContent = `${balanceBtc} BTC`;
}

Read Asset Inventory

JavaScript
async function loadAssets() {
  await window.photon.connect();

  const assets = await window.photon.getAssets();
  console.log("Imported assets", assets);

  return assets;
}

Read One Asset Balance

JavaScript
async function loadPhoBalance() {
  await window.photon.connect();

  const balance = await window.photon.getAssetBalance({
    assetId: "PHO"
  });

  console.log("PHO balance", balance);
  return balance;
}

Import RGB Asset

On regtest, a connected dApp can import a public Photon registry asset directly into the active wallet by contract ID, ticker, or name.

JavaScript
async function importRgbAsset(contractId) {
  const photon = window.photon;
  if (!photon) throw new Error("PhotonBolt Wallet missing");

  await photon.connect();

  const result = await photon.importAsset({ contractId });
  console.log("Imported asset", result.asset);
  console.log("Already imported?", result.alreadyImported);
}

Send BTC Funding

JavaScript
async function fundAddress(address, amountSats) {
  await window.photon.connect();

  return window.photon.sendBtcFunding({
    address,
    amountSats
  });
}

Pay RGB Lightning Invoice

JavaScript
async function payRgbInvoice(invoice) {
  await window.photon.connect();

  const result = await window.photon.payRgbInvoice({ invoice });
  console.log("RGB payment result", result);
  return result;
}

Transaction Request Shape

Field Required Notes
to Yes Recipient Bitcoin address for the active network.
amount or amountBtc Yes BTC string or number, for example "0.0001".
amountSats No Optional integer string if you prefer satoshi precision.
feeRate No Optional sat/vB override. If omitted, the wallet falls back to live fee estimates.
network No If supplied, it must match the wallet’s active network.

Sign Without Broadcasting

Use signTransaction() when your app needs signed raw transaction hex for another flow.

JavaScript
const signedTxHex = await window.photon.signTransaction({
  to: "tb1qexampleaddress0000000000000000000000000",
  amount: "0.0001",
  feeRate: 2
});

console.log("Signed transaction hex", signedTxHex);

Send Transaction

JavaScript
const txid = await window.photon.sendTransaction({
  to: "tb1qexampleaddress0000000000000000000000000",
  amountBtc: "0.0001",
  feeRate: 3
});

console.log("Broadcast txid", txid);

Sign Message

JavaScript
const signatureHex = await window.photon.signMessage(
  "I authorize this login challenge for app.example.com"
);

console.log("Signature", signatureHex);

End-to-End Example

JavaScript
async function payInvoice({ to, amountBtc }) {
  const photon = window.photon;
  if (!photon) throw new Error("PhotonBolt Wallet missing");

  await photon.connect();

  const [account] = await photon.getAccounts();
  const network = await photon.getNetwork();
  const balance = await photon.getBalance();

  console.log("Paying from", account, "on", network, "with balance", balance);

  const txid = await photon.sendTransaction({
    to,
    amountBtc,
    feeRate: 2
  });

  return txid;
}

Network safety: do not let users paste a mainnet address while your app is labeled testnet. Read getNetwork() before rendering send UI.