Introducing Staking Smart Contract

Rongjian Lan
Harmony
Published in
5 min readFeb 14, 2022

TLDR; Harmony now supports staking at the smart contract level, opening the ability to use MetaMask to stake ONE while offering a number of other benefits to developers and delegates.

Since the launch of open staking in May 2020, Harmony network has seen tremendous growth in the amount of staked tokens, which has been crucial for the security of the blockchain. As of now, more than 4.4 billion ONE tokens from 26000+ stakers are delegated to a total of 160 unique validator pools in the Harmony network.

Previously, stakers can participate in staking only by sending a special staking transaction which is supported by a limited number of wallets such as Harmony chrome extension wallet and MathWallet. This limitation not only prevented users of other wallets such as MetaMask from staking, but also limited the freedom of developers to build customized smart contracts around staking flow.

Now, we are launching the precompiled staking smart contract on Harmony’s EVM so staking operations can be done through smart contracts. The precompiled staking smart contract exists at address 0xfc on shard 0 and supports 3 main operations for stakers: delegate, undelegate, and collect rewards. With the launch of precompiled staking smart contracts, various benefits are brought to the stakers and developers.

Benefits:

  1. Stakers are able to use their favorite wallets such as MetaMask to delegate, undelegate and collect rewards on Harmony staking.
  2. Developers can build trustless staking derivative products which unlocks the liquidity of the 4.4 billion staked ONE tokens. This will significantly boost the liquidity of Harmony’s Defi ecosystem and bring more yields to the ONE token stakers.
  3. Instead of following the fixed block reward distribution mechanism in Harmony’s EPoS model, validators can build customized logic to decide how block rewards are distributed among delegators and fully integrate their business model in the staking flow.
  4. The long-standing competition for liquidity between Defi and staking is resolved and more ONE tokens will be staked for the fact that staking derivative unlocks the liquidity of the stake.

By enabling staking in the smart contract level, ONE token holders from all wallets are able to easily stake their tokens, validators have more flexibility in controlling the incentive model with their delegators and a huge amount of new liquidity is unlocked to benefit both ONE stakers and the Harmony’s Defi ecosystem.

For Developers

Smart contract developers are now able to directly invoke staking operations including delegate, undelegate and collect reward. These operations charge the same gas fee and have exactly the same effect as sending corresponding staking transactions.

Here is an example smart contract code to utilize the staking contracts.

For Delegators

We’ve added an option in the staking dashboard for delegators to stake using MetaMask, and included some steps below to help you along the way.

Installing & Configuring MetaMask for Harmony

See our existing documentation for installing and setting up Harmony on your MetaMask.

https://docs.harmony.one/home/network/wallets/browser-extensions-wallets/metamask-wallet

Staking From a New MetaMask Wallet

If you already have a wallet connected to the staking dashboard, first click “Sign Out” to disconnect your existing wallet. Otherwise, click “Sign In” in the left panel.

Select “Use an existing address” and “Use Metamask Wallet”, then click “Sign In” to connect your MetaMask wallet to the staking dashboard.

You may now proceed to selecting a validator and staking your ONE for passive rewards averaging 10% — 11% as of writing this article. Note that you may also stake with multiple validators, so long as you stake a minimum of 100 ONE.

Migrating to MetaMask

This section provides a few steps on migrating from the Harmony Chrome extension to MetaMask. You have two options:

Option #1 — Import Existing Key in MetaMask

Edit: You are strongly encouraged to transfer your assets to a brand new account, not importing an existing key into MetaMask. This option has been removed from this article on 6/22/22. Please proceed with option #2 below.

Option #2 —Transfer Assets to New Address in MetaMask

Importing the private key is a quick and easy way to begin using MetaMask with your existing balance and assets. Alternatively, moving your ONE and custom tokens to a brand new address created in MetaMask is also recommended as a good security practice. Doing so will associate your balance to an account with a brand new private key.

Proceed when you’ve imported all your ONE and HRC20/HRC721 tokens into MetaMask. Performing this step also requires you unstake and wait the seven epoch unbinding period. Finally, if you have a Ledger Nano S or Nano X, you may connect it to MetaMask before proceeding forward for optimal security.

First, create a new account in MetaMask. Then, with MetaMask open, and your ONE balance shown, click the “Send” button followed by the “Transfer between my accounts” option.

Select the new account created, then enter the amount of ONE you wish to transfer. For the full balance, click the “Max” button. Click Next and then “Confirm” to complete the transfer.

Your assets are now stored on an account with a brand new address and private key, and can be staked using the staking dashboard at https://staking.harmony.one.

About Harmony

Build on Harmony, run on all chains.

Harmony is your open platform for assets, collectibles, identity, governance. Be the ONE to bridge to all blockchains.

Harmony is an open and fast blockchain. Our mainnet runs Ethereum applications with 2-second transaction finality and 100 times lower fees. Harmony’s secure bridges offer cross-chain asset transfers with Ethereum, Binance and other chains. https://www.harmony.one/

--

--