MAINNET:
Loading...
TESTNET:
Loading...
/
onflow.org
Flow Playground

Flow Staking Collection Contract Reference


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
Canary/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.

Scripts

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.

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

    pub event NodeRemovedFromStakingCollection(nodeID: String, role: UInt8, address: Address?)
    pub event DelegatorRemovedFromStakingCollection(nodeID: String, delegatorID: UInt32, address: Address?)

    pub event MachineAccountCreated(nodeID: String, role: UInt8, address: Address)