> For the complete documentation index, see [llms.txt](https://bloxxa-1.gitbook.io/bloxxa-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bloxxa-1.gitbook.io/bloxxa-guide/technical-guide/markdown/staking.md).

# Staking

To create a staking contract, you need to specify the following parameters:

* **\_stakingToken** — the address of the token for staking.
* **\_minStake** — the minimum staking amount.
* **\_maxStake** — the maximum staking amount.
* **\_lockPeriod** — the lock-up period (in Unix epoch format).
* **rewardRate** — the reward rate percentage.
* **initialAddress** — the contract owner's address.
* **poolValue** — the number of tokens in the reward pool.

After creating the staking contract, you must transfer tokens to the contract, specifying the amount equal to the **poolValue**.

**Contract Functions:**

* **stake(amount)** — function for staking tokens.
* **withdraw(stakeIndex)** — function for withdrawing staked tokens.
* **claimAllRewards()** — function to withdraw all rewards.
* **claimReward(stakeIndex)** — withdraw rewards from a specific stake.
* **calculateReward(userAddress, stakeIndex)** — calculate the user's reward.
* **getUserStakes(userAddress)** — retrieve all stakes of the user.
* **withdrawTokens()** — withdraw tokens from the staking pool by the contract owner.

**Settings:**

* **setLockPeriod(newLockPeriod)** — change the lock-up period.
* **setMinStake(newMinStake)** — change the minimum staking amount.
* **setMaxStake(newMaxStake)** — change the maximum staking amount.
* **changeRewardRate(newRewardRate)** — change the reward rate percentage.

***
