Stake Token Form
A Solana token staking component with shadcn UI styling
Stake Token Form
Stake SOL
Installation
Install dependencies
Start by installing required Solana dependencies
pnpm add @solana/web3.js @solana/wallet-adapter-react
Add Wallet Provider
Make sure you have added the Wallet Provider to your application. If not, follow the steps in the Connect Wallet Button guide first.
Add Stake Token Form
pnpm dlx shadcn@canary add https://www.murphyai.dev/r/stake-token-form.json
Basic Usage
Component Overview
The Stake Token Form component provides a complete interface for staking SOL tokens with Solayer. It includes:
- SOL balance display with auto-refresh
- Amount input with MAX button for convenience
- Transaction status tracking
- Success and error states
- Transaction explorer link
Implementation Details
The component goes through several stages during the staking process:
- Input Stage: User enters the amount to stake
- Confirming Stage: Transaction is being processed
- Success Stage: Transaction completes successfully
- Error Stage: Transaction fails with details
The staking process uses a server-side API route to avoid CORS issues and create the staking transaction.
Advanced Customization
You can customize the Stake Form by extending its functionality:
Props
Prop | Type | Default |
---|---|---|
onSuccess? | (amount: number, signature: string) => void | undefined |
onError? | (error: Error) => void | undefined |
className? | string | undefined |
apiEndpoint? | string | /api/murphy/solayer/stake |
stakingProvider? | string | Solayer |
estimatedApy? | string | 9.26% |