> ## 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 Ethereum, sign the unsigned transaction provided by the Pooled 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/deposit`, `/staking/unstake` 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 Ethereum network by sending a POST request to [/api/v1/staking/pool/\{network}/transaction/send](/reference/eth-pool-transaction-broadcast).

Example request (for `hoodi` network):

<CodeGroup>
  ```bash curl theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send \
       --header 'accept: application/json' \
       --header 'authorization: Bearer <token>' \
       --header 'content-type: application/json' \
       --data '
  {
      "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8"
  }'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send", {
    method: "POST",
    headers: {
      "authorization": "Bearer <token>",
      "content-type": "application/json",
    },
    body: JSON.stringify({
        "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8"
    }),
  });
  const data = await response.json();
  console.log(data);
  ```

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

  response = requests.post(
      "https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send",
      headers={
          "authorization": "Bearer <token>",
          "content-type": "application/json",
      },
      json={
              "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8"
      },
  )
  print(response.json())
  ```

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

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

  func main() {
  	payload := map[string]interface{}{
  		"signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8",
  	}
  	body, _ := json.Marshal(payload)
  	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/staking/pool/hoodi/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.

Example response:

<CodeGroup>
  ```json theme={null}
  {
        "error": null,
        "result": {
            "hash": "0x9945ee6bbbdb7c34565b8833d37d302da9c76d63262d12a36f7c8f822553fa84",
            "status": "success",
            "blockNumber": 791360,
            "transactionIndex": 0,
            "gasUsed": "51613",
            "cumulativeGasUsed": "51613",
            "effectiveGasPrice": "2606634082",
            "from": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe",
            "to": "0xba447498DC4c169f2b4f427B2c4D532320457E89"
        }
    }
  ```
</CodeGroup>

* `hash` — hash of the Ethereum transaction.
* `status` — transaction status: `pending`, `confirmed`, or `failed`.
* `blockNumber` — block number in which the transaction has been included; `null` if the transaction has not been confirmed yet.
* `transactionIndex` — value of the position of the transaction in the block in which it has been included.
* `gasUsed` — amount of gas spent for the transaction.
* `cumulativeGasUsed` — total amount of gas used by all transactions in a block up to this transaction.
* `effectiveGasPrice` — actual price per gas unit.
* `from` — sender address of this transaction.
* `to` — recipient address for this transaction.


## Related topics

- [Getting Started](/docs/pooled-staking-getting-started.md)
- [Withdrawal](/docs/withdrawal.md)
- [Pooled Staking API reference](/reference/eth-pool-staking-vaults-list.md)
