Stake tokens for a lock period and earn rewards over time. The operator funds a reward pool, and stakers earn proportional rewards based on their stake amount and duration.
Protocol staking with reward distribution
Liquidity mining incentives
Token lock-up programs with yield
Parameter Type Description token_idTokenIdToken to stake reward_rateu128Reward per second per 1e12 tokens staked min_lock_periodu64Minimum lock duration (seconds) before unstaking
Method Parameters Description initializetoken_id, reward_rate, min_lock_periodSet up the staking vault. Only callable once. stakeamount: u128Deposit tokens. Auto-claims pending rewards if existing stake. unstakeamount: u128Withdraw tokens. Auto-claims rewards. Requires lock period elapsed. claim_rewards-- Claim pending rewards without changing stake. fund_rewardsamount: u128Operator adds tokens to the reward pool.
Method Parameters Returns Description get_config-- StakingConfigVault configuration get_stakeaddress: AddressStakeInfoStake details for an address get_pending_rewardsaddress: Addressu128Claimable rewards for an address get_total_staked-- u128Total tokens staked across all users get_reward_pool-- u128Remaining tokens in the reward pool
pub struct StakingConfig {
pub operator : Address ,
pub token_id : TokenId ,
pub reward_rate : u128 ,
pub min_lock_period : u64 ,
pub created_at : u64 ,
}
pub struct StakeInfo {
pub amount : u128 ,
pub start_time : u64 ,
pub last_claim_time : u64 ,
}
elapsed = now - last_claim_time
rewards = (stake_amount * elapsed * reward_rate) / 1e12
actual = min(rewards, available_pool)
# Deploy
norn wallet deploy-loom --name my-staking
# Upload bytecode
norn wallet upload-bytecode --loom-id < LOOM_I D > \
--bytecode staking.wasm
# Execute (borsh-encoded input)
norn wallet execute-loom --loom-id < LOOM_I D > --input < HE X >
# Query config
norn wallet query-loom --loom-id < LOOM_I D >