FlowStakingCollection contract is a contract that manages a resource containing a user's stake and delegation objects.
FlowStakingCollection allows a user to manage multiple active nodes or delegators
and interact with node or delegator objects stored in either their optional locked account
or in the StakingCollection itself (stored in the main account).
If a user has locked tokens, StakingCollection allows a user to interact with their locked tokens
to perform staking actions for any of their nodes or delegators.
The staking collection also manages creating a node's machine accounts if they have any collector or consensus nodes. It also allows them to deposit and withdraw tokens from any of their machine accounts through the staking collection.
See the Staking Collection Docs for more information on the design of the staking collection contract.
Use the following transactions to interact with the StakingCollection.
_Note: The StakingCollection differentiates between stake and delegation requests through
passing an optional DelegatorID argument. For example, if you wish to Stake New Tokens for an active node,
nil as the optional DelegatorID argument to the Stake New Tokens transaction.
The same applies for all the other staking operation transactions.
|Get All Delegator Info||stakingCollection/scripts/get_all_delegator_info.cdc|
|Get All Node Info||stakingCollection/scripts/get_all_node_info.cdc|
|Get Delegator Ids||stakingCollection/scripts/get_delegator_ids.cdc|
|Get Node Ids||stakingCollection/scripts/get_node_ids.cdc|
|Get Does Stake Exist||stakingCollection/scripts/get_does_stake_exist.cdc|
|Get Locked Tokens Used||stakingCollection/scripts/get_locked_tokens_used.cdc|
|Get Unlocked Tokens Used||stakingCollection/scripts/get_unlocked_tokens_used.cdc|
|Get Machine Accounts||stakingCollection/scripts/get_machine_accounts.cdc|
To setup the Staking Collection for an account, use the
The setup process finds any node or delegator records already stored in the main account's storage, as well as any in the associated locked account if an associated locked account exists. It connects these node and delegator records with the new Staking Collection, allowing them to be interacted with using the Staking Collection API.
StakingCollection contract emits an event whenever an important action occurs.
1pub event NodeAddedToStakingCollection(nodeID: String, role: UInt8, amountCommitted: UFix64, address: Address?)2pub event DelegatorAddedToStakingCollection(nodeID: String, delegatorID: UInt32, amountCommitted: UFix64, address: Address?)34pub event NodeRemovedFromStakingCollection(nodeID: String, role: UInt8, address: Address?)5pub event DelegatorRemovedFromStakingCollection(nodeID: String, delegatorID: UInt32, address: Address?)67pub event MachineAccountCreated(nodeID: String, role: UInt8, address: Address)