Skip to main content

Introduction

Stake SOL from a Swig wallet with an allowlisted validator. Use this flow to choose a validator, authorize a staking role, and deposit principal. TypeScript and Python support yield; Rust has no yield client. Use configured clients on the wallet’s network. Writes prepare unsigned transactions. Sign, submit, and confirm each transaction before its dependent step.

SDK examples

List yield options

Choose an allowlisted validator that accepts new deposits. These examples use swig configured for the wallet’s network; TypeScript binds it once as yieldClient. Address variables are public keys.

Prepare a role that can stake

Reuse a qualifying role or prepare a narrowly scoped role for your yield authority.
A create result contains an unsigned AddRole transaction. Complete signing, submit, and confirm it before continuing. An existing result is ready to use.

Deposit SOL

Prepare a new position funded by the wallet. The fee payer supplies rent and fees.
Sign and submit deposit.transaction, then wait for confirmation. Keep the returned position address to track activation.

Flow

Input

prepareRole reuses All or AllButManageAuthority, or a role with System and Stake program access, a general SOL allowance covering maxDeposit, and StakeAll. A finite stake limit can authorize an individual operation but does not qualify for automatic reuse because withdrawals may include rewards. New roles receive exactly Program(System), Program(Stake), SolLimit(maxDeposit), and StakeAll. StakeAll alone cannot invoke the Stake program; ProgramCurated does not cover it. Existing roles remain unchanged.

Output

Track the deposit

Use Yield position to follow activation and earning balances, Yield reward for credited rewards, and Yield withdrawal to exit and return funds.

Errors