Skip to content

Staking TML Tokens

Enrico Rubboli edited this page Nov 20, 2023 · 17 revisions

Staking with Mintlayer offers you two prominent paths. Whether you want to be at the helm of managing a staking pool or prefer to delegate your tokens to an expertly managed pool, we have you covered. Dive into this guide to learn both methods.

Two Ways to Stake TML Tokens

1. Creating a Staking Pool

For those who possess a robust amount of TML tokens and the technical prowess to maintain a staking pool, this is a route worth considering.

Prerequisites:

  • Balance: Before even thinking of starting a pool, your wallet should have at least 40,000 TML tokens.

  • Always-On Machine: You're not just managing your tokens. You're providing a service to others. Ensure your computer remains online 24/7 to keep the staking pool operational.

NOTE: Staking enables your wallet to attempt block production. When a valid block is found, it's propagated across the network, and rewards are distributed to stakers from blocks included in the blockchain. Generating a valid block doesn't consume energy as in a Proof Of Work consensus system like Bitcoin. However, it requires the wallet to sign the block. This means the wallet must be online and connected to your node for staking to function.

Steps to Create a Staking Pool:

  1. Execute createstakepool Command: This command initiates your staking pool. We discussed its details earlier, but here's a quick recap:

    createstakepool <AMOUNT> <COST_PER_BLOCK> <MARGIN_RATIO_PER_THOUSAND> [DECOMMISSION_KEY]

the initial amount of a pool is called pledge, and is immediately removed from your balance.

  1. Kick-off Staking with startstaking: After setting up your pool, you need to get it going. The startstaking command does just that.

  2. Monitor with stakepoolbalance: Keep an eye on your staking pool's balance. Here's how:

    stakepoolbalance <POOL_ID>

    Arguments:

    • <POOL_ID>: The unique ID of your staking pool. Make sure you have this ID handy.

Example

Wallet> createstakepool 40000 5 0.01
The transaction was submitted successfully
Wallet> listpoolids
[Pool Id: tpool12udk7skuzl3u5msdq4zx3n0wyc3ahp5ejnzh7a59ylvzl39elqcs5zpc5e, Balance: 40000, Creation Block heigh: 16170, timestamp: 1692347114]
Wallet> stakepoolbalance tpool12udk7skuzl3u5msdq4zx3n0wyc3ahp5ejnzh7a59ylvzl39elqcs5zpc5e
40000
Wallet> startstaking
[2023-08-18T08:24:04Z INFO  wallet_controller] Start staking, account_index: 0
Success

NOTE: Remember not to close your wallet or disconnect it from the node, or you won't be able to generate new blocks.

2. Delegating TML Tokens to a Staking Pool

If you're not up for running your own staking pool but still want to earn rewards from staking, delegating your tokens is an excellent choice. The process is trustless, giving you peace of mind knowing you can always retrieve your tokens without the pool manager's consent.

NOTE: You can use delegation to increase your own pool's size or to stake your tokens to someone else's pool.

Steps to Delegate Your Tokens:

  1. Create a New Delegation: Before you can delegate for staking, you need to have a delegation. This step helps in that:

    createdelegation <ADDRESS> <POOL_ID>

    <ADDRESS> is the owner of the delegation, who can sign transactions to move money out of it, or unstake. <POOL_ID> is the ID of the pool you want to delegate the token to. Following this command, Mintlayer Wallet will provide you with a unique delegation ID. Keep this ID safe; you'll need it in subsequent steps.

  2. Discover Available Delegations: List the delegations you have created:

    listdelegationids 

    This command displays available delegation IDs alongside their respective balances.

  3. Delegate for Staking: With your delegation created, you can now delegate your tokens for staking:

    delegatestaking <AMOUNT> <DELEGATION_ID>

    Remember, while your tokens are safe and under your control, the staking reward is contingent on the pool's proper operation.

  4. Retrieve Tokens from Delegation: If you ever need to pull your tokens from a delegation and send them to a specific address, use the following command:

    sendfromdelegationtoaddress <ADDRESS> <AMOUNT> <DELEGATION_ID>

    Make sure to provide the necessary parameters, like the destination address.

NOTE: Retrieving tokens from a delegation incurs a 7200-block maturity period, which means the tokens are frozen for about 10 days.

Example

Wallet> newaddress
tmt1q80n8emgq9d92dgwahgmg2efuy4krljwv5qkfrjg
Wallet> createdelegation tmt1q80n8em...uy4krljwv5qkfrjg tpool12ud...3ahp5ejnzh7a59ylvzl39elqcs5zpc5e
Success, the creation of delegation transaction was broadcast to the network. Delegation id: tdelg1c3hxuzwmwc9yu2syyd8f699sj8t5tz78cmxya4snz9l7ml8yjesstw0cuk
Wallet> delegatestaking 1000 tdelg1c3hxuzwmwc9yu2syyd8f699sj8t5tz78cmxya4snz9l7ml8yjesstw0cuk
Success, the delegation staking transaction was broadcast to the network
[.. after a few minutes .. ]
Wallet> listdelegationids
[Delegation Id: tdelg1c3hxuzwmwc9yu2syyd8f699sj8t5tz78cmxya4snz9l7ml8yjesstw0cuk, Balance: 1000]
Wallet> stakepoolbalance tpool12udk7skuzl3u5msdq4zx3n0wyc3ahp5ejnzh7a59ylvzl39elqcs5zpc5e
41000

Decommission and withdraw tokens from the pool

While you can't reduce the pledge from a staking pool without fully decommissioning the pool, you can always withdraw tokens from a delegation. However, it's important to note that both operations come with a locking period. This means tokens will be locked for 2,000 blocks, which is roughly equivalent to 3 days, following the operation.

How to withdraw tokens from a delegation

The sendfromdelegationtoaddress function facilitates the transfer of tokens directly from a user's delegation to a specified address. The command requires three parameters: the recipient's address, the amount of tokens to be transferred, and the unique identifier of the delegation, denoted as DELEGATION_ID.

Example:

Wallet> sendfromdelegationtoaddress tmt1q9p6q46...jg3kfvx0llpu 1000 tdelg14xnrh2...c75vk3mhssuq6ux2
Success. The transaction was broadcast to the network

Decommission a staking pool

When decommissioning a staking pool the pledge tokens are sent back to your wallet. Use the command decommissionstakepool.

Wallet> decommissionstakepool tpool1uhkpnrxqydvypxl58xg4dtckakfyt4lxm3cqzeh4vw77qyacn73qwsmyp8
The transaction was submitted successfully
Wallet> listpoolids
[]
Wallet> getbalance locked
Coins amount: 40000

NOTE: Decommissioning a pool incurs a 7200-block maturity period, which means the tokens are frozen for about 10 days.

Wrapping Up

Whether you're starting a staking pool or riding the wave by delegating, Mintlayer offers a seamless staking experience. As with all investments and blockchain operations, always stay informed and updated. Happy staking!


Note: Parameters and staking details might evolve over time. Stay connected with Mintlayer's official channels and community to get the latest scoop.

Clone this wiki locally