> For the complete documentation index, see [llms.txt](https://klik.gitbook.io/klik-ico/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klik.gitbook.io/klik-ico/klikcoin-tokenomics-plan/staking-mechanism.md).

# Staking Mechanism

In addition to liquidity pools, KLIKcoin introduces **staking rewards** to incentivize long-term holding and network participation. **2 billion KLIKcoins** are allocated to staking rewards.

**How Staking Works:**

1. **Stake KLIKcoins**: Users lock their KLIKcoins into the staking contract for a specified period.
2. **Earn Staking Rewards**: Stakers earn KLIKcoin rewards based on the amount staked and the length of the staking period. Longer staking periods result in higher rewards.
3. **Governance Participation**: Stakers can also participate in governance decisions for the platform.

**Solidity Code for Staking Mechanism:**

```solidity
solidityCopy code// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract KLIKStaking is Ownable {
    ERC20 public klikToken;
    uint256 public rewardRate;  // Reward rate for staking rewards
    uint256 public totalStaked;

    struct Staker {
        uint256 stakedAmount;
        uint256 rewardDebt;
    }

    mapping(address => Staker) public stakers;

    constructor(ERC20 _klikToken, uint256 _rewardRate) {
        klikToken = _klikToken;
        rewardRate = _rewardRate;  // Reward rate for staking rewards
    }

    // Stake KLIKcoins into the contract
    function stake(uint256 amount) external {
        require(klikToken.balanceOf(msg.sender) >= amount, "Insufficient KLIK balance");
        
        klikToken.transferFrom(msg.sender, address(this), amount);
        stakers[msg.sender].stakedAmount += amount;
        totalStaked += amount;

        stakers[msg.sender].rewardDebt += (amount * rewardRate);  // Calculate reward debt
    }

    // Unstake KLIKcoins from the contract
    function unstake(uint256 amount) external {
        require(stakers[msg.sender].stakedAmount >= amount, "Insufficient staked amount");

        klikToken.transfer(msg.sender, amount);
        stakers[msg.sender].stakedAmount -= amount;
        totalStaked -= amount;
    }

    // Claim staking rewards
    function claimRewards() external {
        uint256 reward = stakers[msg.sender].rewardDebt;
```
