Search…
Solana
How to programmatically delegate and retrieve rewards for delegated wallets on Solana.

Delegation flow

As Solana is a dPOS protocol, staking Solana is done by issuing a single staking transaction: https://explorer.solana.com/tx/ZFVv1c32jdLb59kGkthctvbKRcyFYmsbPxKVAJP4RAF8m4aM7ofkyQMLcTDZCQ4Z8gFq6MWkQaj797p2UTyARhh​
The only inputs needed are the amount to stake, and the validator address to delegate the stake to.

Kiln example widget

We provide an example implementation of a staking widget in Typescript: https://github.com/kilnfi/playground/blob/main/components/Protocols/Solana/SolanaStakingWidget.tsx

Solana official example

The Solana codebase provides an example of how to do this programmatically:
1
let vote_pubkey = vote_account.pubkey();
2
fn process_instructions<T: Signers>(bank: &Bank, keypairs: &T, ixs: &[Instruction]) {
3
let tx = Transaction::new_signed_with_payer(
4
ixs,
5
Some(&keypairs.pubkeys()[0]),
6
keypairs,
7
bank.last_blockhash(),
8
);
9
bank.process_transaction(&tx).unwrap();
10
}
11
​
12
process_instructions(
13
bank,
14
&[from_account, vote_account, validator_identity_account],
15
&vote_instruction::create_account(
16
&from_account.pubkey(),
17
&vote_pubkey,
18
&VoteInit {
19
node_pubkey: validator_identity_account.pubkey(),
20
authorized_voter: vote_pubkey,
21
authorized_withdrawer: vote_pubkey,
22
commission: 0,
23
},
24
amount,
25
),
26
);
Copied!

Custodian API

Based on the custodian you use, you may be able to generate this transaction with a higher-level API, for instance the Fireblocks API.

Reporting API

Solana stake API object

Solana Stake is an API object linked to an Account representing a stake on the Solana chain.
Field
Value
Format
stake_account
Stake Account address
String
withdraw_pubkey
Withdrawal Solana address
String
balance
Total balance of the Solana Stake Account
Number
rewards
Accrued rewards of the Solana Stake Account
Number
apy
APY of accrued rewards
Number

Solana network stats API object

Field
Value
Format
apy
Network current Staking APY
Number
nb_validators
Number of validators running on the network
Number
supply_staked_percent
Percentage of staked tokens on the network
Number

Solana API routes

get
https://api.kiln.fi/v1
/sol/stakes?stakeaccounts
Retrieve Solana Stakes for stake accounts
get
https://api.kiln.fi/v1
/sol/network-stats
Retrieve Solana Network Stats