Introduction

The Solana integration aligns with the general Getting Started process, with network-specific parameters highlighted below. parameters and network-specific logic.

Key Solana-Specific Details

  • chain— always set to solana for Solana-related requests.
  • network— specifies the environment (testnet or mainnet-beta).
  • stakerAddress— represents the account address used for staking, unstaking, and withdrawal operations. It also serves as:
    • feePayer —the account paying transaction fees.
    • fromPublicKey — the account used to create the staking account.
    • stakeAuthority — grants permissions for staking operations.
    • withdrawAuthority — grants permissions for withdrawal operations

Unsigned Transactions — use Solana-specific signing logic for unsignedTransactionData. For details, refer to Transaction Signing.

Quick Steps for Solana

Staking Flow

  1. Create a Stake Transaction: Refer to Create Stake Transaction to send the transaction details.
  2. Sign and Broadcast Transaction: Use Solana-specific signing logic as outlined in Sign and Broadcast transaction.

Unstaking Flow

  1. Create Unstake Transaction: Refer to Create an Unstake Transaction to send the transaction details.
  2. Sign and Broadcast Transaction: Use Solana-specific signing logic as outlined in Sign and Broadcast transaction.
  3. Create Withdrawal Transaction: Refer to the Create Withdrawal Transaction section for request structure.
  4. Sign and Broadcast Transaction: Use Solana-specific signing logic as outlined in Sign and Broadcast transaction.

Unified API + Solana Integration Workflow

Staking Flow

Step 1. Create Staking Transaction

Send a POST request to https://api-test.p2p.org/api/v1/unified/staking/stake.

Example request:

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"
}'

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"
        }
    }
}

Step 2. Sign and Broadcast transaction

Use unsignedTransactionData to sign the transaction.

Send a POST request to https://api-test.p2p.org/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"
}'

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"
        }
    }
}

Unstaking Flow

Step 1: Create an Unstake Transaction

Send a POST request to https://api-test.p2p.org/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"
    }
}'

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"
        }
    }
}

Step 2. Sign and Broadcast Unstake Transaction

Sign and broadcast the transaction as outlined above.

Step 3. Create Withdrawal Transaction

Send a POST request to https://api-test.p2p.org/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"
    }
}'

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
        }
    }
}

Step 4. Sign and Broadcast Withdrawal Transaction

Sign and broadcast the transaction as outlined above.

What's Next?