| Crates.io | bonk-staking-rewards-v3 |
| lib.rs | bonk-staking-rewards-v3 |
| version | 0.1.0 |
| created_at | 2026-01-05 03:47:33.606717+00 |
| updated_at | 2026-01-05 03:47:33.606717+00 |
| description | A composable Rust library for interacting with the Bonk Stake Program on Solana |
| homepage | |
| repository | https://github.com/hogyzen12/bonk-staking-rewards |
| max_upload_size | |
| id | 2023048 |
| size | 194,622 |
A composable Rust crate for interacting with the Bonk Stake Program on Solana.
Add to your Cargo.toml:
[dependencies]
bonk-staking-rewards = "0.1.0"
# Build the project
cargo build --release
# Run the staking tool
cargo run --bin stake-bonk
# Or with logging
RUST_LOG=info cargo run --bin stake-bonk
use bonk_staking_rewards_v3::{build_deposit_transaction, StakeConfig};
use solana_client::rpc_client::RpcClient;
use solana_sdk::signature::Keypair;
// Configure your stake
let config = StakeConfig {
amount: 10_000_000, // 100 BONK (5 decimals)
lockup_duration: 7_776_000, // 90 days
nonce: 0,
};
// Build and send transaction
let client = RpcClient::new("https://api.mainnet-beta.solana.com".to_string());
let payer = Keypair::new(); // Your keypair
let recent_blockhash = client.get_latest_blockhash()?;
let tx = build_deposit_transaction(&payer, &config, recent_blockhash)?;
let signature = client.send_and_confirm_transaction(&tx)?;
The Bonk Staking Program uses these constants:
STAKEkKzbdeKkqzKpLkNQD3SUuLgshDKCD7U8duxAbBBcKdLUv1xJ3hFyZptPiMoN5bC5c3bpFqZPNAv9F4mUg8Configure your own keypair and RPC URL when using the library in your application.
Configure your staking parameters:
pub struct StakeConfig {
pub amount: u64, // Amount in smallest units (5 decimals for BONK)
pub lockup_duration: u64, // Duration in seconds
pub nonce: u32, // Nonce for multiple stakes
}
build_deposit_instructionBuild a raw deposit instruction for the staking program.
pub fn build_deposit_instruction(
payer: &Pubkey,
owner: &Pubkey,
from_token_account: &Pubkey,
config: &StakeConfig,
) -> Result<Instruction, StakingError>
build_deposit_transactionBuild a complete transaction with compute budget and deposit instruction.
pub fn build_deposit_transaction(
payer: &Keypair,
config: &StakeConfig,
recent_blockhash: Hash,
) -> Result<Transaction, StakingError>
// Derive stake deposit receipt PDA
pub fn derive_stake_deposit_receipt(
owner: &Pubkey,
stake_pool: &Pubkey,
nonce: u32,
program_id: &Pubkey,
) -> (Pubkey, u8)
// Derive vault PDA
pub fn derive_vault(
stake_pool: &Pubkey,
program_id: &Pubkey,
) -> (Pubkey, u8)
// Derive stake mint PDA
pub fn derive_stake_mint(
stake_pool: &Pubkey,
program_id: &Pubkey,
) -> (Pubkey, u8)
let config = StakeConfig {
amount: 10_000_000, // 100 BONK
lockup_duration: 7_776_000, // 90 days
nonce: 0,
};
let config = StakeConfig {
amount: 100_000_000, // 1000 BONK
lockup_duration: 15_552_000, // 180 days
nonce: 0,
};
// First stake
let config1 = StakeConfig {
amount: 10_000_000,
lockup_duration: 7_776_000,
nonce: 0, // First deposit
};
// Second stake
let config2 = StakeConfig {
amount: 20_000_000,
lockup_duration: 15_552_000,
nonce: 1, // Second deposit
};
You can easily integrate this crate into your Rust application:
# In your app's Cargo.toml
[dependencies]
bonk-staking-rewards = "0.1.0"
# Compatible with Solana SDK 2.3.x
# solana-sdk = "2.3.1"
# solana-client = "2.3.2"
# spl-token = "8.0.0"
# borsh = "1.5.7"
# etc.
Then use it in your Dioxus app:
use bonk_staking_rewards_v3::{build_deposit_transaction, StakeConfig};
async fn stake_bonk(amount: u64, duration: u64) -> Result<String, Box<dyn Error>> {
let config = StakeConfig {
amount,
lockup_duration: duration,
nonce: 0,
};
// Build and send transaction
// ... your logic here
Ok(signature.to_string())
}
Run tests:
cargo test
Run with logging:
RUST_LOG=debug cargo test -- --nocapture
The crate provides a comprehensive StakingError enum:
pub enum StakingError {
InvalidProgramId,
InvalidStakePool,
InvalidMint,
InvalidRewardVault,
SerializationError(std::io::Error),
ClientError(solana_client::client_error::ClientError),
KeypairError(String),
InvalidKeypair,
}
This crate is designed to be composable and extensible. Feel free to add:
MIT
Made with 🔥 by hogyzen12