Stake SOL
Effortlessly stake SOL on the Jup validator using the StakeManager class. This guide explains how to execute staking operations with simplicity and precision.
Code Breakdown
1. Endpoint Interaction
The staking function interacts with the Jup API to prepare a staking transaction:
Copy
2. Transaction Deserialization and Signing
The API returns a serialized transaction that needs to be deserialized, updated, and signed by the user's wallet:
Copy
3. Submitting and Confirming the Transaction
The transaction is submitted to the Solana network, and its status is confirmed:
Copy
4. Error Handling
If any part of the staking process fails, meaningful exceptions are raised for debugging:
Copy
Key Features
Effortless Staking
Automatically interacts with Jup API to stake SOL.
Transaction Safety
Ensures the transaction uses the latest blockhash and is properly signed.
Error Resilience
Catches and reports API or network issues to ensure reliable staking operations.
Minimal Setup
Only requires the agent instance and the desired staking amount.
Last updated