> ## 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.

# Getting Started

> Stake on Aptos programmatically with the P2P.org Staking API.

Staking in the Aptos network using the Staking API consists of several main steps:

1. Create a staking request.
2. Sign and send the transaction to the network.

[Get an authentication token](/docs/authentication) to start using Staking API.

Request examples are provided using [cURL](https://curl.se/).

```mermaid theme={null}
sequenceDiagram
    participant Client
    participant P2P API
    participant Blockchain
    Client->>P2P API: Create stake transaction
    P2P API-->>Client: Unsigned transaction
    Client->>Client: Sign transaction locally
    Client->>P2P API: Broadcast signed transaction
    P2P API->>Blockchain: Submit transaction
    Blockchain-->>P2P API: Transaction hash
    P2P API-->>Client: Transaction status
```

<Steps>
  <Step title="Create staking request">
    Send a POST request to [/api/v1/aptos/\{network}/staking/delegated/add](/reference/aptos-staking-delegated-add).

    Example request (for `mainnet` network):

    <CodeGroup>
      ```bash curl theme={null}
           curl --request POST \
           --url https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "amount": 1100000000,
        "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a",
        "gas": {
          "unitPrice": 100,
          "maxGasLimit": 100,
        }
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch(
        "https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add",
        {
          method: "POST",
          headers: {
            "accept": "application/json",
            "authorization": "Bearer <token>",
            "content-type": "application/json",
          },
          body: JSON.stringify({
            amount: 1100000000,
            delegatorAddress: "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a",
            gas: {
              unitPrice: 100,
              maxGasLimit: 100,
            },
          }),
        }
      );
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add",
          headers={
              "accept": "application/json",
              "authorization": "Bearer <token>",
              "content-type": "application/json",
          },
          json={
              "amount": 1100000000,
              "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a",
              "gas": {
                  "unitPrice": 100,
                  "maxGasLimit": 100,
              },
          },
      )
      print(response.json())
      ```

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

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

      func main() {
      	payload := map[string]interface{}{
      		"amount":           1100000000,
      		"delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a",
      		"gas": map[string]interface{}{
      			"unitPrice":   100,
      			"maxGasLimit": 100,
      		},
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add", bytes.NewBuffer(body))
      	req.Header.Set("accept", "application/json")
      	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>

    * `amount` — amount of tokens to stake in Octas. The minimum stake amount is 11 APT (1 APT = 10⁸ Octas).

    * `delegatorAddress` — <Tooltip tip="A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.">delegator</Tooltip> stash account address which keeps tokens.

    * `gas` — optional; computational effort required to execute the transaction, measured in <Tooltip tip="A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.">gas</Tooltip> units.

      * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction.
      * `maxGasLimit` — maximum gas limit for the transaction.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "amount": 1100000000,
            "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a",
            "unsignedTransaction": "0xa571a5bc9b1bfd5fe58e6e09a5be251a3299985494d022959ce206f1f23f752e21000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c096164645f7374616b650002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d28080100000000000000400d03000000000064000000000000<Tooltip tip="A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.">00e574206</Tooltip>8000000000200",
            "createdAt": "2023-08-24T08:14:50.455Z"
          },
          "error": null
        }
      ```
    </CodeGroup>

    * `amount` — amount of tokens to stake in Octas.
    * `delegatorAddress` — delegator account address which keeps tokens.
    * `unsignedTransaction` — unsigned transaction in hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action.
    * `createdAt` — timestamp of the transaction in the ISO 8601 format.
  </Step>

  <Step title="Sign and send transaction">
    Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-aptos) the signed transaction to the Aptos network. By broadcasting this transaction, you're adding the tokens to P2P.ORG delegation pool.

    To check the transaction status, send a GET request to [/api/v1/aptos/\{network}/transaction/status/\{transactionHash}](/reference/aptos-transaction-status).

    Example request (for `mainnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request GET \
           --url https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641 \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json'
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch(
        "https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641",
        {
          method: "GET",
          headers: {
            "accept": "application/json",
            "authorization": "Bearer <token>",
            "content-type": "application/json",
          },
        }
      );
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.get(
          "https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641",
          headers={
              "accept": "application/json",
              "authorization": "Bearer <token>",
              "content-type": "application/json",
          },
      )
      print(response.json())
      ```

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

      import (
      	"fmt"
      	"io"
      	"net/http"
      )

      func main() {
      	req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641", nil)
      	req.Header.Set("accept", "application/json")
      	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>

    * `transactionHash` — hash of the transaction.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "createdAt": "2025-06-24T08:14:50.455Z",
            "gas": {
              "unitPrice": 100,
              "maxGasLimit": 100,
              "used": 100
            },
            "senderAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a",
            "sequenceNumber": 42,
            "status": "success",
            "transactionHash": "0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641"
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `createdAt` — timestamp of the transaction in the ISO 8601 format.

    * `gas` — computational effort required to execute the transaction, measured in gas units.

      * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction.
      * `maxGasLimit` — maximum gas limit for the transaction.
      * `used` — amount of gas spent for the transaction.

    * `senderAddress` — transaction sender address.

    * `sequenceNumber` — number of transactions that have been submitted and committed on-chain from the sender account.

    * `status` — transaction status: `pending`, `success` or `failed`.

    * `transactionHash` — hash of the transaction.
  </Step>
</Steps>


## Related topics

- [Sign and Broadcast Transaction](/docs/signing-transaction-aptos.md)
- [Withdrawal](/docs/withdrawal-aptos.md)
- [Staking API reference](/reference/aptos-staking-delegated-add.md)
