> ## 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 Hyperliquid programmatically with the P2P.org Staking API.

Staking on the Hyperliquid network using the Staking API consists of several main steps:

1. Transfer tokens from the spot to the staking balance.
2. Create a delegate request.

After each step, 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 HyperCore
    Client->>P2P API: Create transfer transaction (spot → staking)
    P2P API-->>Client: Unsigned transfer transaction
    Client->>Client: Sign transaction locally
    Client->>HyperCore: Broadcast transfer transaction
    HyperCore-->>Client: Transfer confirmed
    Client->>P2P API: Create delegate transaction
    P2P API-->>Client: Unsigned delegate transaction
    Client->>Client: Sign transaction locally
    Client->>HyperCore: Broadcast delegate transaction
    HyperCore-->>Client: Delegation confirmed
```

<Steps>
  <Step title="Transfer tokens to staking balance">
    Since staking on Hyperliquid happens within [HyperCore](https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore), the HYPE tokens are required to be in the staking balance. Just like USDC can be transferred between <Tooltip tip="Perpetual contracts, or perps, allow making operations with an asset with no expiration date so that traders can use leverage and take positions larger than their account balance.">perps</Tooltip> and spot accounts, HYPE can be transferred between spot and staking balances.

    1. Send a POST request to [/api/v1/hyperliquid/\{network}/staking/transfer](/reference/hyperliquid-transfer).

       Example request (for `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
           --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "amount": 10,
        "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch(
        "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer",
        {
          method: "POST",
          headers: {
            "accept": "application/json",
            "authorization": "Bearer <token>",
            "content-type": "application/json",
          },
          body: JSON.stringify({
            amount: 10,
            delegatorAddress: "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
          }),
        }
      );
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer",
          headers={
              "accept": "application/json",
              "authorization": "Bearer <token>",
              "content-type": "application/json",
          },
          json={
              "amount": 10,
              "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
          },
      )
      print(response.json())
      ```

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

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

      func main() {
      	payload := map[string]interface{}{
      		"amount":           10,
      		"delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer", 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 transfer in HYPE.
    * `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> account address which keeps tokens.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "amount": "10",
            "unsignedTransaction": "string",
            "createdAt": "2025-10-01T12:00:00Z"
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `amount` — amount of tokens to transfer in HYPE.
    * `unsignedTransaction` — unsigned transaction in the 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.

    2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-hyperliquid) the transaction to Hyperliquid network.

       After the transaction has been successfully executed, the delegator staking balance can delegate transferred tokens to the P2P validator. Transfers from the spot to the staking balance are instant.
  </Step>

  <Step title="Create delegate request">
    1. Send a POST request to [/api/v1/hyperliquid/\{network}/staking/delegate](/reference/hyperliquid-delegate).

       Example request (for `testnet` network):

    <CodeGroup>
      ```bash curl theme={null}
      curl --request POST \
           --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate \
           --header 'accept: application/json' \
           --header 'authorization: Bearer <token>' \
           --header 'content-type: application/json' \
           --data '
      {
        "amount": 10,
        "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e"
      }
      '
      ```

      ```typescript TypeScript theme={null}
      const response = await fetch(
        "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate",
        {
          method: "POST",
          headers: {
            "accept": "application/json",
            "authorization": "Bearer <token>",
            "content-type": "application/json",
          },
          body: JSON.stringify({
            amount: 10,
            delegatorAddress: "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
          }),
        }
      );
      const data = await response.json();
      console.log(data);
      ```

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

      response = requests.post(
          "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate",
          headers={
              "accept": "application/json",
              "authorization": "Bearer <token>",
              "content-type": "application/json",
          },
          json={
              "amount": 10,
              "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
          },
      )
      print(response.json())
      ```

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

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

      func main() {
      	payload := map[string]interface{}{
      		"amount":           10,
      		"delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
      	}
      	body, _ := json.Marshal(payload)
      	req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate", 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 delegate.
    * `delegatorAddress` — delegator address on the Hyperliquid network.

    Example response:

    <CodeGroup>
      ```json theme={null}
      {
          "result": {
            "amount": "10",
            "unsignedTransaction": "string",
            "createdAt": "2025-10-01T12:00:00Z"
          },
          "error": {}
        }
      ```
    </CodeGroup>

    * `amount` — amount of tokens to delegate.
    * `unsignedTransaction` — unsigned transaction in the 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.

    2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-hyperliquid) the transaction to Hyperliquid network.

       After this transaction has been successfully executed, the delegator starts actively participating in staking through the P2P validator. Note that delegations have a lock-up duration of 1 day, which means that only after this period can delegations be partially or fully undelegated.

       Rewards are accrued every minute and distributed to stakers every day. Rewards are redelegated automatically to the staked validator, i.e., compounded.
  </Step>
</Steps>

## Get delegator summary

Additionally, check the delegator's active balances for HYPE spot balance, stake balance, active delegations, and pending withdrawals by sending the GET request to [/api/v1/hyperliquid/\{network}/staking/info/\{delegatorAddress}](/reference/hyperliquid-info).

Example request (for `testnet` network):

<CodeGroup>
  ```bash curl theme={null}
  curl --request GET \
       --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e \
       --header 'accept: application/json' \
       --header 'authorization: Bearer <token>'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch(
    "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
    {
      method: "GET",
      headers: {
        "accept": "application/json",
        "authorization": "Bearer <token>",
      },
    }
  );
  const data = await response.json();
  console.log(data);
  ```

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

  response = requests.get(
      "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e",
      headers={
          "accept": "application/json",
          "authorization": "Bearer <token>",
      },
  )
  print(response.json())
  ```

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

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

  func main() {
  	req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", nil)
  	req.Header.Set("accept", "application/json")
  	req.Header.Set("authorization", "Bearer <token>")
  	resp, _ := http.DefaultClient.Do(req)
  	defer resp.Body.Close()
  	respBody, _ := io.ReadAll(resp.Body)
  	fmt.Println(string(respBody))
  }
  ```
</CodeGroup>

* `delegatorAddress` — delegator address on the Hyperliquid network.

Example response:

<CodeGroup>
  ```json theme={null}
  {
      "result": {
        "spotBalance": 500.25,
        "stakeBalance": 250.75,
        "delegations": [
          {
            "amount": 100.5,
            "validator": "0x497beec89958848126c2ea65934ce430e1410ad2",
            "lockedUntil": "2024-12-31T23:59:59Z"
          }
        ],
        "pendingWithdrawal": 75
      },
      "error": {}
    }
  ```
</CodeGroup>

* `spotBalance` — amount of tokens on the spot balance available to transfer to the staking balance.

* `stakeBalance` — amount of tokens on the staking balance available to delegate.

* `delegations` — list of all the delegations per delegator.

  * `amount` — amount of delegated tokens in HYPE.
  * `validator` — validator address.
  * `lockedUntil` — timestamp of the delegation expiration in the ISO 8601 format.

* `pendingWithdrawal` — total amount of tokens withdrawn that are pending in the unstaking queue.


## Related topics

- [Sign and Broadcast Transaction](/docs/signing-transaction-hyperliquid.md)
- [Withdrawal](/docs/withdrawal-hyperliquid.md)
- [Staking API reference](/reference/hyperliquid-transfer.md)
