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

# Overview

> How to stake tokens in Solana network using P2P.ORG Staking SDK.

1. Initialize the API client object via the [`StakingApiClient`](/docs/staking-sdk-stakingapiclient) constructor.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const client = new StakingApiClient({
    baseUrl: 'https://api.p2p.org',
    token: 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9',
    network: 'mainnet-beta',
  });
  ```
</CodeGroup>

2. Retrieve the staking accounts from your P2P.ORG profile with [`getStakingAccounts()`](/docs/staking-sdk-solana-getstakingaccounts).

<CodeGroup>
  ```javascript JavaScript theme={null}
  var result = await client.solana.getStakingAccounts({
    status: 'active',
  });

  const account = result.accounts[0];
  ```
</CodeGroup>

3. Create a new stake transaction with [`stake()`](/docs/staking-sdk-solana-stake). The result will contain a base64-encoded unsigned transaction which you can convert to a Solana [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object.

<CodeGroup>
  ```javascript JavaScript theme={null}
  var result = await client.solana.stake({
    feePayer: account.stakeAccount,
    fromPublicKey: account.stakeAccount,
    stakeAuthority: account.stakeAuthority,
    withdrawAuthority: account.withdrawAuthority,
    amount: '1002282880',
  });

  var transaction = client.solana.decodeTransaction(result.unsignedTransaction);
  ```
</CodeGroup>

4. Sign the transaction using the dedicated wallet software. P2P.ORG Staking SDK provides a simple method [`signWithKeypairs()`](/docs/staking-sdk-solana-signwithkeypairs), though it is intended for testing and development only. In production, replace it with the software or hardware wallet integration or a dedicated signing service integration.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const key = process.env.SOLANA_PRIVATE_KEY;
  client.solana.signWithKeypairs(transaction, [key]);
  ```
</CodeGroup>

5. Verify the signed transaction with [`verifyTransaction()`](/docs/staking-sdk-solana-verifytransaction). This ensures that the transaction was not modified by external software before signing.

<CodeGroup>
  ```javascript JavaScript theme={null}
  client.solana.verifyTransaction({
    tx: transaction,
    expectedFeePayer: account.stakeAuthority,
    expectedStakeAuthority: account.stakeAuthority,
    expectedWithdrawAuthority: account.withdrawAuthority,
    strict: true,
  });
  ```
</CodeGroup>

6. Broadcast the transaction to the Solana network with [`sendTransaction()`](/docs/staking-sdk-solana-sendtransaction).

<CodeGroup>
  ```javascript JavaScript theme={null}
  await client.solana.sendTransaction({
    signedTransaction: transaction,
  });
  ```
</CodeGroup>


## Related topics

- [StakingApiClient](/docs/staking-sdk-stakingapiclient.md)
- [getStakingAccounts()](/docs/staking-sdk-solana-getstakingaccounts.md)
- [Staking API reference](/reference/solana-staking-stake.md)
