Solana

Unified API + Solana Integration Workflow

In the following guide, the integration process for the solana chain and testnet network is covered. The Solana integration aligns with the general Unified API process but with network-specific parameters.

Get an authentication token to start using the Unified API.

Request examples are provided using cURL.

To check the integration guides for other chains, refer to the Networks section.


📘

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 paying transaction fees.
    • fromPublicKey — account address used to create the staking account.
    • stakeAuthority — account address that can perform staking operations.
    • withdrawAuthority — account address that can perform withdrawal operations.

Staking Flow

1. Create Staking Request

Send a POST request to /api/v1/unified/staking/stake/.

Example request (for testnet network):

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"
}'
  • chain — blockchain network, always set to solana for Solana-related requests.
  • network — environment in which the transaction is processed: mainnet-beta for production use; testnet for development and testing purposes.
  • stakerAddress — unified input for multiple Solana parameters:
    • 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. If not specified, rights will be taken from the fromPublicKey parameter.
    • withdrawAuthority — account address that can perform withdrawal operations with the staking account. If not specified, rights will be taken from the fromPublicKey parameter.
  • amount — amount of tokens to stake in lamports (1 SOl = 10⁹ lamports). Min amount is 1002282880.

Example response:

{
    "error": null,
    "result": {
        "amount": 1002282880,
        "stakerAddress": "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR",
        "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"
        }
    }
}
  • 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 specified (e.g., testnet).
    • 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.
    • voteAccount — validator's vote account address receiving the stake.

2. Sign and Send Transaction

Use unsignedTransactionData to sign the transaction following the Solana-specific signing logic.

To broadcast the signed transaction to the Solana network, send a POST request to /api/v1/unified/transaction/broadcast.

Example request:

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": "9FfyCk9kqgfpg1gYMw8rhksZcAg4JiD9xhuMvkFVdjQY",
    "signedTransaction": "AdtQhLeM0eOMdV7rvagYx3V8mra6CMaiVgeNTcgTds8ltjDUwJi3LMGhZ+Txqj26nJMJa7MxFWe5lmIxAnjKsQUBAAIEep+wazhVDEf2XiuHusgypzGMGyd4WaFZ6lzpHIypRJ3qFo72gQoaoUsCAJcUGGTQGdOONNYMBdVbIhEKwGitMwah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAABojzQ55lMuIXx6AWTccH48p4L12JlvUuCfHkOik1nJLAECAwEDAAQFAAAA"
}'
  • 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:

{
    "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"
        }
    }
}
  • extraData — additional transaction details specific to the network.
    • transactionId — block hash in which the transaction was included.
    • slot — period of time during which each leader collects transactions and creates a block in the Solana network (marker of blockchain time).
    • signerAccounts — account addresses that signed the transaction (e.g., fee-payer, system accounts, and stake-related accounts).
  • 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.

Example request:

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": "9FfyCk9kqgfpg1gYMw8rhksZcAg4JiD9xhuMvkFVdjQY",
    "extra": {
        "amount": "1002282880",
        "stakeAccount": "GknMRQYxnoZphCUUKJJLuw27hwCW8qPKuJ4CsTpchj5L"
    }
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • stakerAddress — account address initiating the unstaking transaction.
  • extra — unified input for multiple Solana parameters:
    • amount — amount of tokens to unstake in lamports (1 SOl = 10⁹ lamports). Min amount is 1002282880.
    • stakeAccount — account address that stores tokens for staking.

Example response:

{
    "error": null,
    "result": {
        "stakerAddress": "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR",
        "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIEgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAC6Oo3oUHKupolPnHZ0RH2ZxtrEHm8tk2Qp2iW0vfhHhgECAwEDAAQFAAAA",
        "createdAt": "2024-12-17T19:46:06.403Z",
        "extraData": {
            "network": "testnet",
            "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
            "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw"
        }
    }
}
  • stakerAddress — account address initiated the unstaking 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 (e.g., testnet).
    • feePayer — account address that will pay the fee for the transaction.
    • stakeAuthority — account address that can perform staking operations with staking account.

2. Sign and Send Transaction

Use unsignedTransactionData to sign and send the unstaking transaction to the Solana network using the Solana-specific signing logic.

3. Create Withdrawal Request

Send a POST request to /api/v1/unified/staking/withdraw.

Example request:

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": "9FfyCk9kqgfpg1gYMw8rhksZcAg4JiD9xhuMvkFVdjQY",
    "extra": {
        "amount": "1002282880"
    }
}'
  • chain — blockchain network.
  • network — environment in which the transaction is processed.
  • stakerAddress — account address initiating the withdrawal transaction.
  • extra — additional transaction details:
    • amount — amount of tokens to withdraw in lamports (1 SOl = 10⁹ lamports).
    • stakeAccount — account address that stores tokens for staking.

Example response:

{
    "error": null,
    "result": {
        "stakerAddress": "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR",
        "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAMFgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGTWE0P7tm7NDHRMga+VEKBtXuFZsxTdf9AAAAPOAx5l5F5rUaY7eB6UQVXzEi9E6HWzj9Mg5vRAcUMlcAQIFAQADBAAMBAAAAICfvTsAAAAA",
        "createdAt": "2024-12-17T19:49:22.476Z",
        "extraData": {
            "network": "testnet",
            "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
            "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
            "recipient": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw",
            "amount": 1002282880
        }
    }
}
  • stakerAddress — 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 details about the transaction:
    • network — specifies the environment (e.g., testnet).
    • 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 the withdrawal transaction to the Solana network using the Solana-specific signing logic.

What's Next?