Skip to main content

Contract

The FlowStakingCollection contract is a contract that manages a resource containing a user's stake and delegation objects.

The 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.

Source: FlowStakingCollection.cdc

NetworkContract Address
Testnet0x95e019a17d0e23d7
Mainnet0x8d0e87b65159ae63

Transactions​

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, pass nil as the optional DelegatorID argument to the Stake New Tokens transaction. The same applies for all the other staking operation transactions.

IDNameSource
SCO.01Setup Staking CollectionstakingCollection/setup_staking_collection.cdc
SCO.02Register DelegatorstakingCollection/register_delegator.cdc
SCO.03Register NodestakingCollection/register_node.cdc
SCO.04Create Machine AccountstakingCollection/create_machine_account.cdc
SCO.05Request UnstakingstakingCollection/request_unstaking.cdc
SCO.06Stake New TokensstakingCollection/stake_new_tokens.cdc
SCO.07Stake Rewarded TokensstakingCollection/stake_rewarded_tokens.cdc
SCO.08Stake Unstaked TokensstakingCollection/stake_unstaked_tokens.cdc
SCO.09Unstake AllstakingCollection/unstake_all.cdc
SCO.10Withdraw Rewarded TokensstakingCollection/withdraw_rewarded_tokens.cdc
SCO.11Withdraw Unstaked TokensstakingCollection/withdraw_unstaked_tokens.cdc
SCO.12Close StakestakingCollection/close_stake.cdc
SCO.13Transfer NodestakingCollection/transfer_node.cdc
SCO.14Transfer DelegatorstakingCollection/transfer_delegator.cdc
SCO.15Withdraw From Machine AccountstakingCollection/withdraw_from_machine_account.cdc
SCO.22Update Networking AddressstakingCollection/update_networking_address.cdc

Scripts​

IDNameSource
SCO.16Get All Delegator InfostakingCollection/scripts/get_all_delegator_info.cdc
SCO.15Get All Node InfostakingCollection/scripts/get_all_node_info.cdc
SCO.16Get Delegator IdsstakingCollection/scripts/get_delegator_ids.cdc
SCO.17Get Node IdsstakingCollection/scripts/get_node_ids.cdc
SCO.18Get Does Stake ExiststakingCollection/scripts/get_does_stake_exist.cdc
SCO.19Get Locked Tokens UsedstakingCollection/scripts/get_locked_tokens_used.cdc
SCO.20Get Unlocked Tokens UsedstakingCollection/scripts/get_unlocked_tokens_used.cdc
SCO.21Get Machine AccountsstakingCollection/scripts/get_machine_accounts.cdc

Setup Transaction​

To setup the Staking Collection for an account, use the SC.01 transaction.

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.

Events​

The StakingCollection contract emits an event whenever an important action occurs.


_10
pub event NodeAddedToStakingCollection(nodeID: String, role: UInt8, amountCommitted: UFix64, address: Address?)
_10
pub event DelegatorAddedToStakingCollection(nodeID: String, delegatorID: UInt32, amountCommitted: UFix64, address: Address?)
_10
_10
pub event NodeRemovedFromStakingCollection(nodeID: String, role: UInt8, address: Address?)
_10
pub event DelegatorRemovedFromStakingCollection(nodeID: String, delegatorID: UInt32, address: Address?)
_10
_10
pub event MachineAccountCreated(nodeID: String, role: UInt8, address: Address)