spark_flashnet_signStructuredMessage

Use the spark_flashnet_signStructuredMessage method to request a signature from the user’s Spark wallet on a structured Flashnet message.

The wallet will only sign if the message is:

  • A valid Flashnet intent (e.g. swap, liquidity, pool creation, deposit confirmation, clawback).

  • A Flashnet authentication challenge for JWT issueance

    • the payload must be a string prefixed with:

      FLASHNET_AUTH_CHALLENGE_V1: <32 random bytes>

Any other message is rejected to prevent unsafe signing.

The wallet ensures users see a clear review screen of what they’re signing (“What You See Is What You Sign”), preventing arbitrary or unsafe message signing.


Parameters

{
  message: string;  // raw structured message
}

Examples

Flashnet intent (executeSwap):

{
  message: JSON.stringify({
      userPublicKey: "02abcdef...",
      lpIdentityPublicKey: "03aabbccddeeff...",
      assetInSparkTransferId: "spark-transfer-uuid-123",
      assetInAddress: "03bitcoinassetpubkey...",
      assetOutAddress: "03usdstablecoinpubkey...",
      amountIn: "100000000",
      minAmountOut: "99500000",
      maxSlippageBps: "50",
      nonce: "swap-nonce-123",
      totalIntegratorFeeRateBps: "0"
    })
}

Flashnet JWT issuance challenge:

{
  message: "FLASHNET_AUTH_CHALLENGE_V1:aabbccddeeff00112233445566778899..."
}

Responses

Success

{
  message: "<validated-message>",   // the exact intent JSON or challenge string
  signature: "<spark-signature>"    // signature from the user’s Spark identity key
}

Error

{
  errorCode: RpcErrorCode.INVALID_PARAMS,
  message: "Invalid or unsupported structured message",
  requestId: "01HJZKFABCDEFGHJKLMNPQRSTVW"
}

Common error cases:

  • Message not valid JSON (when intent expected).

  • Message doesn’t match any supported Flashnet intent schema.

  • JWT challenge missing the required FLASHNET_AUTH_CHALLENGE_V1: prefix.

  • User rejects the request in the wallet.

Last updated