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": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresAt": "2025-09-17T12:34:56Z"
}
jwt
— the Flashnet access token, to be passed asAuthorization: Bearer <jwt>
in API callsexpiresAt
— ISO timestamp when the token expires (token must be renewed afterwards)
❌ Errors
If the request fails, the method will reject with an error object:
{
"errorCode": "FSAG-2001",
"message": "Signature verification failed: Invalid nonce",
"requestId": "01H8Z0HMVXJN6A8Q9GR1J6Z34E"
}
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