spark_flashnet_getJWT

Use the spark_flashnet_getJWT method to request a Flashnet JWT for the user’s Spark wallet. The wallet handles challenge/response with Flashnet:

  • Fetches the challenge

  • Signs it with the user’s Spark identity key

  • Exchanges it for a JWT

Your app receives the JWT directly, without having to manage the user's authentication flow on Flashnet.

Parameters

No parameters are required.

Example

import { request } from "sats-connect";

try {
  const response = await request("spark_flashnet_getJWT", {});
  if ("result" in response) {
    console.log("JWT:", response.result.jwt);
  } else {
    console.error("Error:", response.error.message);
  }
} catch (err) {
  console.error("Unexpected error:", err);
}

Response

βœ… Success

On success, the method resolves to a JWT token that the dApp can use for authenticated Flashnet API calls.

  • jwt β€” the Flashnet access token, to be passed as Authorization: Bearer <jwt> in API calls

  • expiresAt β€” ISO timestamp when the token expires (token must be renewed afterwards)

❌ Errors

If the request fails, the method will reject with an error object:

Common failure cases encountered with Flashnet authentication include:

  • Validation errors (malformed data)

  • Security errors (invalid signature, wrong nonce)

  • Not found (no active challenge for the public key)

These errors are surfaced as standard Sats Connect errors for your App to handle.

Last updated