> For the complete documentation index, see [llms.txt](https://docs.xverse.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xverse.app/sats-connect/spark-methods/flashnet-trading/spark_flashnet_signstructuredmessage.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
