# 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`](https://docs.xverse.app/sats-connect/spark-methods/flashnet-trading/spark_flashnet_signintent)):
* 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.
