Developer Guides

Balances and Transactions

PhotonBolt’s provider exposes a narrow, Bitcoin-focused transaction API. Use it to read the active balance, 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`;
}

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.