# 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).
  * The payload must match one of the supported Flashnet intent schemas (see [`spark_flashnet_signIntent`](/sats-connect/spark-methods/flashnet-trading/spark_flashnet_signintent.md)):
* 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

```ts
{
  message: string;  // raw structured message
}
```

## Examples

### **Flashnet intent (executeSwap):**

```ts
{
  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:**

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

***

## Responses

### :white\_check\_mark: Success

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

### :x: Error

```ts
{
  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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xverse.app/sats-connect/spark-methods/flashnet-trading/spark_flashnet_signstructuredmessage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
