---
# System prepended metadata

title: dApps Staking Module

---

# dApps Staking Module

## Overview

dApps Staking is a reward mechanism for developers or administrators of smart contracts. 50% of Plasm Network's staking reward goes to application developers who have enhanced the value of the Plasm Network. Plasm allows the assignment of a smart contract administrator, called an "operator." "Operators" can be "Nominated" by other dApps "Nominators." The operator of the smart contract receiving many nominations can receive newly minted PLM token from the chain. 
[`more...`](https://docs.plasmnet.io/learn/dapps-reward)

![](https://i.imgur.com/VxZiYxc.png)



## Interface

### Dispatchable Functions

* `fn bond` - Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it
* `fn bond_extra`- Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking
* `fn unbond` - Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends
* `fn withdraw_unbonded` - Remove any unlocked chunks from the `unlocking` queue from our management
* `fn nominate_contracts` - Declare the desire to nominate `targets` for the origin controller
* `fn vote_contracts` - Vote for contracts with Bad/Good
* `fn chill` - Declare no desire to either validate or nominate
* `fn set_payee` - (Re-)set the payment target for a controller
* `fn slash` - slash the account for the contract
* `fn set_controller` - (Re-)set the controller of a stash
* `fn claim` - rewards are claimed by the contract

### Storage

* `AccountsVote` - Votes for pairs of an account and a contract.
    * `double_map (AccountId, ContractAcc) => VoteCounts`
* `Bonded` - Map from all locked "stash" accounts to the controller account.
    * `map StashAcc => ControllerAcc`
* `ContractVotesUntreatedEra` - The untreated era for each contract for votes.
    * `map ContractAcc => EraIndex`
* `ContractsUntreatedEra` - The untreated era for each contract
    * `map ContractAcc => EraIndex`
* `DappsNominations` - The map from nominator stash key to the set of stash keys of all contracts to nominate
    * `map T::AccountId => Option<Nominations<T::AccountId, BalanceOf<T>>>`
* `ErasContractsParameters` - Holds the parameters of contracts
    * `double_map (EraIndex, AccountId) => StakingParameters`
* `ErasStakingPoints` - Rewards of stakers for contracts(called by "Dapps Nominator") at era
    * `double_map (EraIndex, AccountId) => EraStakingPoints<T::AccountId, BalanceOf<T>>`
* `TotalStakes` - The total amount staked for the last `HISTORY_DEPTH` eras
    * `double_map (AccountId, AccountId) => BalanceOf<T>`
* `ErasVotes` - Votes for pairs of an era and a contract
    * `double_map (EraIndex, ContractAcc) => VoteCounts;`
* `Ledger` - Map from all (unlocked) "controller" accounts to the info regarding the staking
    * `map AccountId => Option<StakingLedger<T::AccountId, BalanceOf<T>>>`
* `Payee` - Where the reward payment should be made. Keyed by stash
    * `map AccountId => RewardDestination<T::AccountId>`
* `StorageVersion` - Storage version of the pallet
* `TotalStakes` - The total amounts of staking for pairs of nominator and contract
    * `double_map (AccountId, AccountId => BalanceOf<T>` 
* `UntreatedEra` - The untreated era for each contract for votes
    * EraIndex


## Structs
* `Nominations`- A record of the nominations made by a specific account
* `EraStakingPoints`- Reward points of an era. Used to split era total payout between dapps rewards
* `UnlockChunk` - Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked
* `StakingLedger` - The ledger of a (bonded) stash
* `VoteCounts` - The count of bad and good votes

## Enums
* `Vote` - Bad/Good votes

## Events
* `Reward(Balance, Balance)` - The amount of minted rewards. (for dapps with nominators)
* `Bonded(AccountId, Balance)` - An account has bonded this amount. An account has bonded this amount. NOTE: This event is only emitted when funds are bonded via a dispatchable. Notably, it will not be emitted for staking rewards when they are added to stake.
* `Unbonded(AccountId, Balance)` - An account has unbonded this amount.
* `Withdrawn(AccountId, Balance)` - An account has called `withdraw_unbonded` and removed unbonding chunks worth `Balance` from the unlocking queue.
* `TotalDappsRewards(EraIndex, Balance)` - The total amount of minted rewards for dapps.
* `Nominate(AccountId)` - Nominate of stash address.

## Errors
* NotController - Not a controller account.
* NotStash - Not a stash account.
* AlreadyBonded - Stash is already bonded.
* AlreadyPaired - Controller is already paired.
* EmptyTargets - Targets cannot be empty.
* DuplicateIndex - Duplicate index.
* InvalidSlashIndex - Slash record index out of bounds.
* InsufficientValue - Can not bond with value less than minimum balance.
* NoMoreChunks - Can not schedule more unlock chunks.
* NoUnlockChunk - Can not rebond without unlocking chunks.
* FundedTarget Attempting to target a stash that still has funds.
* InvalidEraToReward - Invalid era to reward.
* InvalidNumberOfNominations - Invalid number of nominations.
* NotSortedAndUnique - Items are not sorted and unique.
* EmptyNominateTargets - Targets must be latest 1.
* NotOperatedContracts - Targets must be operated contracts
* NotEnoughStaking - The nominations amount more than active staking amount.
        
        
## Constants
* None

## Related Modules

- [Plasm-Reward](../plasm-rewards/README.md): The Reward module for Plasm Network.
- [Plasm-Support](../plasm-support/README.md): The Plasm helper module.
- [Plasm-Contract-Operator](../operator/README.md): The Plasm module for Smart Contract Operator.


* * *

Plasm is licensed under the GPLv3.0 by Stake Technologies Inc.