Kiln docs
Search…
⌃K

Solana (SOL): Stake SOL with Kiln Connect

Stake SOL programmatically with Kiln Connect SDK.

Stake

On Solana, a wallet can create multiple Stake Accounts, link them to a validator and delegate funds to them that will earn rewards after an activation period of one epoch (~2.5 days).
// optional, only for specific setups
const options = {
// to stake on another validator than the default Kiln validator
voteAccountAddress?: string;
// specify a memo in the stake tx
memo?: string;
};
/* async craftStakeTx(accountId: string, walletPubkey: string, amountInSol: number, options?: SolanaStakeOptions): Promise<SolanaTx> */
const tx = await k.sol.craftStakeTx(account.id, WALLET_PUBKEY, 42.1337, options);

Unstake

To unstake a stake account on Solana, you have to perform 2 steps:
  1. 1.
    Deactivate the Stake Account, which is performed an epoch later (~2.5 days)
  2. 2.
    Withdraw the funds on the deactivated Stake Account

Deactivate

Deactivating a Solana Stake Account takes one epoch before you can withdraw it.
/* async craftDeactivateStakeTx(stakeAccountAddress: string, walletAddress: string): Promise<SolanaTx> */
const tx = await k.sol.craftDeactivateStakeTx(stakeAccountAddress, WALLET_PUBKEY);

Withdraw

You can only withdraw a Solana Stake Account if it is deactivated.
/* async craftWithdrawStakedBalanceTx(stakeAccountAddress: string, walletAddress: string, amountSol?: number): Promise<SolanaTx> */
const tx = await k.sol.craftWithdrawStakedBalanceTx(stakeAccountAddress, WALLET_PUBKEY, 42.1337);

Split

Create a new Solana Stake Account by splitting the amount of SOL in an active Stake Account.
/* async craftSplitStakeAccountTx(accountId: string, stakeAccountAddress: string, walletAddress: string, amountSol: number): Promise<SolanaTx> */
const tx = await k.sol.craftSplitStakeAccountTx(account.id, stakeAccountAddress, WALLET_PUBKEY, 12);

Merge

Merge one active Solana Stake Account to an other one.
/* async craftMergeStakeAccountsTx(stakeAccountSourceAddress: string, stakeAccountDestinationAddress: string, walletAddress: string): Promise<SolanaTx> */
const tx = await k.sol.craftMergeStakeAccountsTx(stakeAccountSourceAddress, stakeAccountDestinationAddress, WALLET_PUBKEY);

Sign

Sign Solana transactions by specifying the integration name and the crafted transaction.
/* async sign(integration: string, transaction: SolanaTx, note?: string): Promise<SolanaTx> */
const signed = await k.sol.sign('vault-1', tx);

Broadcast

Broadcast and get the status of a broadcasted transaction. If you specified a custom RPC url for Solana in the SDK configuration, it will be used instead of the default one.
/* async broadcast(transaction: SolanaTx): Promise<string | undefined> */
const hash = await k.sol.broadcast(signed);
/* async getTxStatus(transactionHash: string): Promise<SolTxStatus> */
const status = await k.sol.getTxStatus(hash);