> ## Documentation Index
> Fetch the complete documentation index at: https://docs.p2p.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign and Broadcast Transaction

> To complete any staking or withdrawal operation on Sui, sign the unsigned transaction provided by the Staking API and broadcast it to the network.

## 1. Prepare the transaction

Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/stake` or `staking/withdraw`.

## 2. Sign the transaction

Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration.

## 3. Send the transaction

Broadcast the signed transaction to the Sui network by sending a POST request to [/api/v1/sui/\{network}/transaction/send](/reference/sui-transaction-send).

Example request (for `testnet` network):

<CodeGroup>
  ```bash curl theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/sui/testnet/transaction/send \
       --header 'accept: application/json' \
       --header 'Authorization: Bearer <token>' \
       --header 'content-type: application/json' \
       --data '
  {
    "transaction": "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p",
    "signature": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3"
  }
  '
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://api-test.p2p.org/api/v1/sui/testnet/transaction/send", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      transaction: "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p",
      signature: "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3",
    }),
  });
  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api-test.p2p.org/api/v1/sui/testnet/transaction/send",
      headers={
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
      },
      json={
          "transaction": "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p",
          "signature": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3",
      },
  )
  print(response.json())
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	payload := map[string]interface{}{
  		"transaction": "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p",
  		"signature":   "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3",
  	}
  	body, _ := json.Marshal(payload)
  	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/sui/testnet/transaction/send", bytes.NewBuffer(body))
  	req.Header.Set("Authorization", "Bearer <token>")
  	req.Header.Set("Content-Type", "application/json")
  	resp, _ := http.DefaultClient.Do(req)
  	defer resp.Body.Close()
  	respBody, _ := io.ReadAll(resp.Body)
  	fmt.Println(string(respBody))
  }
  ```
</CodeGroup>

* `signedTransaction` — signed transaction in the hexadecimal format which needs to be broadcasted to the network.
* `signature` — signature of the staker account address.

Example response:

<CodeGroup>
  ```json theme={null}
  {
        "error": null,
        "result": {
            "transactionDigest": "DiXajfAeTLVhiQZuW8aH2UD1XsCEoZVH4twRC5PjeK5"
        }
    }
  ```
</CodeGroup>

* `transactionDigest` — hash of the transaction.

Use the `transactionDigest` object to check the transaction status via [explorer](https://suiscan.xyz/testnet/home), e.g., [example of the broadcasted transaction](https://suiscan.xyz/testnet/tx/DiXajfAeTLVhiQZuW8aH2UD1XsCEoZVH4twRC5PjeK5).


## Related topics

- [Getting Started](/docs/staking-sui.md)
- [Withdrawal](/docs/withdrawal-sui.md)
- [Staking API reference](/reference/sui-staking-stake.md)
