/
onflow.org
Flow Playground

How to Delegate Locked FLOW


Introduction

This guide demonstrates how a token holder can delegate locked FLOW tokens to another node using the LockedTokens contract.

Setup

After the account setup process is complete, the token holder will have access to a LockedTokens.TokenHolder resource in their storage. This resource can be used as a proxy to indirectly delegate locked FLOW tokens.

Register as a Delegator

To register as a delegator, the token holder can use the Register Delegator (TH.12) transaction with the following arguments:

ArgumentTypeDescription
idStringThe ID of the node to delegate to.
amountUFix64The number of FLOW tokens to delegate.

This transaction registers the account as a delegator to the node ID they specified and attaches a NodeDelegatorProxy capability to the TokenHolder resource. This capability can later be used to perform delegation actions.

Once an account has registered as a delegator with one node, they cannot register with any others. For more information, see "Register to stake for a different node" below. This feature will be added in the future.

Delegation Actions

Delegate New Tokens

The token holder can delegate additional tokens after registering as a delegator.

Note: This transaction delegates additional tokens to the same node that was registered in the setup phase. It is currently not possible to delegate to multiple nodes from the same account.

To delegate new tokens via the NodeDelegatorProxy, the token holder can use the Delegate New Locked FLOW (TH.15) transaction with the following arguments:

ArgumentTypeDescription
amountUFix64The number of FLOW tokens to delegate.

Re-delegate Unstaked Tokens

After delegated tokens become unstaked, the token holder can choose to re-delegate the unstaked tokens to the same node.

To delegate unstaked tokens via the NodeDelegatorProxy, the token holder can use the Re-delegate Unstaked FLOW (TH.16) transaction with the following arguments:

ArgumentTypeDescription
amountUFix64The number of unstaked FLOW tokens to delegate.

Re-delegate Rewarded Tokens

After earning rewards from delegation, the token holder can choose to re-delegate the rewarded tokens to the same node.

To delegate rewarded tokens via the NodeDelegatorProxy, the token holder can use the Re-delegate Rewarded FLOW (TH.17) transaction with the following arguments:

ArgumentTypeDescription
amountUFix64The number of rewarded FLOW tokens to delegate.

Unstake Delegated Tokens

The token holder can submit a request to unstake their delegated tokens at any time.

To unstake delegated tokens via the NodeDelegatorProxy, the token holder can use the Unstake Delegated FOW (TH.18) transaction with the following arguments:

ArgumentTypeDescription
amountUFix64The number of FLOW tokens to unstake.

Note: unstaked delegated tokens will be held by the central staking contract for a period of time (the rest of the current epoch plus all of the next epoch) before they are released to the token holder. Once the tokens are released (unstaked), they can be claimed via the Withdraw Unstaked Tokens action below.

Withdraw Unstaked Tokens

After delegated tokens become unstaked, the token holder can withdraw them from the central staking contract.

To withdraw unstaked tokens via the NodeDelegatorProxy, the token holder can use the Withdraw Unstaked FLOW (TH.19) transaction with the following arguments:

ArgumentTypeDescription
amountUFix64The number of unstaked FLOW tokens to withdraw.

This transaction moves the unstaked tokens back into the LockedTokens.Lockbox owned by the token holder.

Withdraw Rewarded Tokens

After earning rewards from delegation, the token holder can withdraw them from the central staking contract.

To withdraw rewarded tokens via the NodeDelegatorProxy, the token holder can use the Withdraw Rewarded FLOW (TH.20) transaction with the following arguments:

ArgumentTypeDescription
amountUFix64The number of rewarded FLOW tokens to withdraw.

This transaction moves the rewarded tokens back into the LockedTokens.Lockbox owned by the token holder. However, unlike unstaked tokens, rewards are unlocked FLOW and can be immediately withdrawn from the lockbox.

Getting Info about an accounts delegation

To return a struct with all the information associated with a delegator, anyone can use the Get Delegator Info (TH.21) script with the following arguments:

ArgumentTypeDescription
nodeIDStringThe 32 byte ID of the node of the delegator
nodeIDUInt8The ID of the delegator

This script returns a FlowIDTableStaking.DelegatorInfo struct.

Edit on GitHub