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

# Solana

> Unified API + Solana Integration Workflow

In the following guide, the integration process for the `solana` chain is covered. The Solana integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters.

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

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

> To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section.

<Note>
  **Key Solana-specific details**

  * `chain`— always set to `solana` for Solana-related requests.

  * `network`— environment in which the transaction is processed: `testnet` or `mainnet-beta`.

  * `stakerAddress`— account address initiating staking, unstaking or withdrawal transactions. It also serves as:

    * `feePayer` — account address that will pay the fee for the transaction.
    * `fromPublicKey` — account address from which the staking account will be created.
    * `stakeAuthority` — account address that can perform staking operations with the staking account.
    * `withdrawAuthority` — account address that can perform staking operations with the staking account. If not specified, permissions will be taken from the `fromPublicKey` parameter.
</Note>

## Staking flow

### 1. Create staking request

Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction).

Example request (for `testnet` network):

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/staking/stake \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '{
      "chain": "solana",
      "network": "testnet",
      "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
      "amount": "1002282880"
  }'
  ```
</CodeGroup>

* `chain` — blockchain network, always set to `solana` for Solana-related requests.

* `network` — environment in which the transaction is processed: `testnet` or `mainnet-beta`.

* `stakerAddress` — staking account address receiving the staked tokens.

* `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). Min amount is 1002282880.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "amount": 1002282880,
          "stakerAddress": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo",
          "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAh8iugT4hbb/uMDOx66iyC43XvE2dwUsI1HUUjzs6IbAGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAHKEjIcCxFWx4HvZBQrHANtq0grHucq4V1OVMlBvalFQDAgIAAXQDAAAAgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cAYAAAAAAAAAEZiVWJmK1A0UzRLK1h5V3pTRXBjaHc9PYCfvTsAAAAAyAAAAAAAAAAGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAQCAQd0AAAAAIFjhdI9y2XfP9n3vsVrYeYhb33RJ6UQWfZbtPp0o+nAgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBgEDBggFAAQCAAAA",
          "createdAt": "2024-12-17T19:40:29.176Z",
          "extraData": {
              "network": "testnet",
              "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "fromPublicKey": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "voteAccount": "A93XLdBKfc4pwEMAvdFeyxnF6HauN5erNDFbUsemWiaB"
          }
      }
  }
  ```
</CodeGroup>

* `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports).

* `stakerAddress` — staking account address receiving the staked tokens.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted 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.

* `extraData` — additional transaction details:

  * `network` — environment in which the transaction is processed.
  * `feePayer` — account address that will pay the fee for the transaction.
  * `fromPublicKey` — account address from which the staking account will be created.
  * `stakeAuthority` — account address that can perform staking operations with the staking account.
  * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account. If not specified, rights will be taken from the `fromPublicKey` parameter.
  * `voteAccount` — vote account address.

### 2. Sign and send transaction

Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction.

To broadcast the signed transaction to the Solana network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send).

Example request (for `testnet` network):

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '{
      "chain": "solana",
      "network": "testnet",
      "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
      "signedTransaction": "AdtQhLeM0eOMdV7rvagYx3V8mra6CMaiVgeNTcgTds8ltjDUwJi3LMGhZ+Txqj26nJMJa7MxFWe5lmIxAnjKsQUBAAIEep+wazhVDEf2XiuHusgypzGMGyd4WaFZ6lzpHIypRJ3qFo72gQoaoUsCAJcUGGTQGdOONNYMBdVbIhEKwGitMwah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAABojzQ55lMuIXx6AWTccH48p4L12JlvUuCfHkOik1nJLAECAwEDAAQFAAAA"
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.
* `network` — environment in which the transaction is processed.
* `stakerAddress` — staking account address receiving the staked tokens.
* `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "extraData": {
              "transactionId": "2Bno5j3tex8VmcCR2M6JQnjtPxDuqAvSAUjSDpd6gaasRfEQeoWH9MRQdU7ANNtFFbG9UQAGByG1UwPS1qersmyd",
              "slot": 307375529,
              "signerAccounts": [
                  "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
                  "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR",
                  "11111111111111111111111111111111",
                  "A93XLdBKfc4pwEMAvdFeyxnF6HauN5erNDFbUsemWiaB",
                  "Stake11111111111111111111111111111111111111",
                  "StakeConfig11111111111111111111111111111111",
                  "SysvarC1ock11111111111111111111111111111111",
                  "SysvarRent111111111111111111111111111111111",
                  "SysvarStakeHistory1111111111111111111111111"
              ],
              "createdAt": "2024-12-17T19:41:27.450Z"
          }
      }
  }
  ```
</CodeGroup>

* `extraData` — additional transaction details:

  * `transactionId` — block hash in which the transaction has been included.
  * `slot` — period of time during which each leader collects transactions and creates a block in the Solana network.
  * `signerAccounts` — account addresses that signed the transaction.
  * `createdAt` — timestamp of the transaction in the ISO 8601 format.

## Unstaking flow

### 1. Create unstaking request

Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction).

Example request (for `testnet` network):

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/staking/unstake \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '{
      "chain": "solana",
      "network": "testnet",
      "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
      "extra": {
          "amount": "1002282880",
          "stakeAccount": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo"
      }
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.

* `network` — environment in which the transaction is processed.

* `stakerAddress` — account address initiated the staking transaction.

* `extra` — additional parameters:

  * `amount` — amount of tokens to unstake in lamports (1 SOL = 10⁹ lamports). Min amount is 1002282880.
  * `stakeAccount` — account address that keeps tokens.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "stakerAddress": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo",
          "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIEgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAC6Oo3oUHKupolPnHZ0RH2ZxtrEHm8tk2Qp2iW0vfhHhgECAwEDAAQFAAAA",
          "createdAt": "2024-12-17T19:46:06.403Z",
          "extraData": {
              "network": "testnet",
              "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw"
          }
      }
  }
  ```
</CodeGroup>

* `stakerAddress` — staking account address initiating the unstake transaction.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted 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.

* `extraData` — additional transaction details:

  * `network` — environment in which the transaction is processed.
  * `feePayer` — account address that will pay the fee for the transaction.
  * `stakeAuthority` — account address that can perform staking operations with the staking account.

### 2. Sign and send transaction

Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Solana-specific signing logic.

### 3. Create withdrawal request

<Note>
  Note that the withdrawal is available only after the unstaking period of 1 epoch (\~72 hours).
</Note>

Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction).

Example request (for `testnet` network):

<CodeGroup>
  ```bash bash theme={null}
  curl --request POST \
       --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \
       --header 'Content-Type: application/json' \
       --header 'Authorization: Bearer <token>' \
       --data '{
      "chain": "solana",
      "network": "testnet",
      "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
      "extra": {
          "amount": "1002282880",
          "stakeAccount": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo"
      }
  }'
  ```
</CodeGroup>

* `chain` — blockchain network.

* `network` — environment in which the transaction is processed.

* `stakerAddress` — account address initiating the withdrawal transaction.

* `extra` — additional parameters:

  * `amount` — amount of tokens to withdraw in lamports (1 SOL = 10⁹ lamports). Min amount is 1002282880.
  * `stakeAccount` — account address that keeps tokens.

Example response:

<CodeGroup>
  ```json JSON theme={null}
  {
      "error": null,
      "result": {
          "stakerAddress": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo",
          "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAMFgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGTWE0P7tm7NDHRMga+VEKBtXuFZsxTdf9AAAAPOAx5l5F5rUaY7eB6UQVXzEi9E6HWzj9Mg5vRAcUMlcAQIFAQADBAAMBAAAAICfvTsAAAAA",
          "createdAt": "2024-12-17T19:49:22.476Z",
          "extraData": {
              "network": "testnet",
              "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "recipient": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
              "amount": 1002282880
          }
      }
  }
  ```
</CodeGroup>

* `stakerAddress` — staking account address initiated the withdrawal transaction.

* `unsignedTransactionData` — unsigned transaction in Base64 encrypted 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.

* `extraData` — additional transaction details:

  * `network` — environment in which the transaction is processed.
  * `feePayer` — account address that will pay the fee for the transaction.
  * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account.
  * `recipient` — account address to which tokens will be sent.
  * `amount` — amount of tokens to withdraw in lamports (1 SOL = 10⁹ lamports).

### 4. Sign and send transaction

Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Solana-specific signing logic


## Related topics

- [Unified API Reference](/reference/unified-create-stake-transaction.md)
- [Integration Workflow Example](/docs/unified-api-getting-started.md)
- [Networks Supported](/docs/unified-api-networks.md)
