Skip to content

Staking

Stake native KNYX and earn rewards that accrue per block.

Contract: 0xe62304CF98d98cad476151359D84f2073a762a46

How rewards accrue

The contract tracks a global rewardPerTokenStored, which grows as blocks pass, and each account's userRewardPerTokenPaid at the point it last interacted. Your earned amount is the difference multiplied by your stake.

This means rewards accrue continuously without anyone iterating over stakers, and staking later does not entitle you to earlier emissions.

Interface

FunctionPurpose
stake(uint256 amount)Stake KNYX
unstake(uint256 amount)Begin unbonding
withdraw()Collect unbonded principal
claimRewards()Collect accrued rewards
earned(address)Rewards accrued but not claimed
stakedOf(address)Current stake
totalStaked()Total across all stakers
rewardPool()Remaining rewards available
rewardRate()Emission rate
unbondingPeriod()Delay before withdrawal

Staking

js
const staking = new ethers.Contract(STAKING, [
  'function stake(uint256 amount)',
  'function stakedOf(address) view returns (uint256)',
  'function earned(address) view returns (uint256)',
], signer);

await (await staking.stake(ethers.parseEther('1'), {
  value: ethers.parseEther('1'),
})).wait();

Native token, so value is sent with the call

KNYX is the chain's native asset, not an ERC-20, so there is no approval step — the amount travels as the transaction's value.

Claiming

js
console.log(ethers.formatEther(await staking.earned(me)), 'KNYX pending');
await (await staking.claimRewards()).wait();

Claiming does not touch your principal.

Unstaking

Two steps, separated by the unbonding period:

js
await (await staking.unstake(amount)).wait();   // begins unbonding
// ... wait out unbondingPeriod ...
await (await staking.withdraw()).wait();        // collects the principal

Unbonding is not instant

Between unstake and withdraw the funds are illiquid. Check unbondingPeriod() for the current value before committing.

Rewards depend on a funded pool

rewardPool() is finite. If it empties, earned stops growing until it is topped up. Check it before assuming a projected yield.

A real transaction

0x19758199e82a990bb1e3db5fe3eae72c40c7ef7df98a6edae6a14996f1b1a800

Block 6,136,442 — a stake.

KriptoNyx testnet — chain ID 3009 (kriptonyx_3009-1)