Cross-shard messaging protocol


Harmony is the first sharded Proof-of-Stake blockchain thatโ€™s launched back in 2019. Sharding and scalability have always been the most known and important feature of Harmony and most of our community members and supporters are in it for our technology of sharding.

Our mainnet network has been running with 4 shards for many years without security issues. However, only shard 0 is fully utilized while the other 3 shards are idle almost all the time due to the lack of interoperability between shards.

Launching the cross-shard messaging protocol not only will unlock the utility of all the 4 shards in harmony, it will also mark Harmony as the first blockchain with a fully interoperable sharding solutions which is still EVM compatible.

Competitor Analysis:

  1. Near - their sharding is not functional yet.
  2. Cosmos - the IBC protocol involves complicated network message passing. It takes 9 steps for users to do a cross-zone token transfer.
  3. Polkadot - interoperability are done through bridges and there is not much design detail on it. Seems itโ€™s just using the canonical bridge technology for the parachains to talk to each other.

Current Design:

*By Rongjian Lan; (To be) Approved by Leo, Ganesha, Jack, Peter.

Execution Plan

Further Design Exploration

  1. Write down a list of potential applications that will utilize cross-shard protocol
    1. GameFi
    2. Lending
    3. NFT
    4. DAO Governance
  2. Design and formalize cross-shard HRC20 and NFT smart contract standards.
    1. How tokens can be implemented on multiple shards?
    2. How existing HRC20 tokens on shard 0 can be extended to become cross-shard tokens?
    3. How to deal with error handling on the receiving shards?
    4. Can cross-shard reading without transferring token be achieved?
    5. Registration of all the smart contracts in all shards that belong to the same cross-shard token, so they can recognize each other in the cross-shard communication.
  3. Design the web portal for cross-shard tokens
    1. Could be a website that display cross-shard tokens and interact with metamask to do standard cross-shard token transfers.
    2. Potentially be integrated with 1wallet

Implementation (Pending on Design Exploration)

  1. Protocol
    1. EVM router smart contract
    2. Outgoing message and incoming message creation and storage
    3. Message passing between shards via p2p protocol
    4. Change of existing cross-shard message data structure to include additional fields such as gas related parameters.
    5. Cross-shard gas consumption and resend logic.
  2. SDK and Toolings
    1. Cross-shard sending API with confirmation event listener, timeout handler and retry logic.
    2. Cross-shard token reader API that queries balances across all shards where the token is deployed.
    3. Cross-shard token events subscription
  3. User Interfaces
    1. An official harmony released website to check cross-shard token balances and transfer token across shard (especially for metamask users)
  4. Testing
    1. Functionality testing on SDK, UIs and cross-shard txn.
    2. Load testing on cross-shard txns to make sure the network can handle cross-shard txn spams.


  1. Release
    1. Node client release with the cross-shard txn hard fork
    2. Medium article release describing the feature and the selling points.
    3. Technical documentation about cross-shard txns in docs.harmony.one for developers.
  2. Post-release initiatives
    1. Hackathon on cross-shard HRC20 NFT token standards and any other cross-shard applications.
    2. Marketing effort (news, videos etc) to sell as the first cross-shard txn launched in the industry.

Cross-shard Use Cases

  1. DEX add liquidity pair (token A, token B) case 1: DEX: shard 0, token A: shard 0, token B: shard 1 case 2: DEX: shard 0, token A: shard 1, token B: shard 1 case 3: DEX: shard 0, token A: shard 1, token B: shard 2
  2. Oracle invocation (read-only) case 1: Oracle: shard 0, DApp: shard 1
    1. code example:
    2. import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
      AggregatorV3Interface oneUSD = AggregatorV3Interface(
      (, int256 onePrice, , uint256 oneTimeStamp, ) = oneUSD.latestRoundData(); // price invocation
      // usage of onePrice & oneTimeStamp