How to Deploy Your Own Hyperlane on Polygon zkEVM

megabytemegabyte
4 min read

gm gm gm!!!

New chains are popping up by the minute, so getting liquidity there is a burning issue. Hyperlane tries to solve this with permissionless bridges. Hyperlane is a permissionless protocol, which means you can deploy your own Hyperlane on any chain without asking the core team. In this guide, you will learn how to deploy Hyperlane on Polygon zkEVM Testnet, Polygon Mumbai Testnet and Sepolia.

There are five steps we need to follow so LFG๐Ÿš€

Subscribe to the Developer DAO Newsletter. Probably Nothing

Prerequisites

1. Setting Up the Keys

Deploying Hyperlane includes smart contracts, validators, and relayers, each requiring a key pair.

The Deployment Keys

To deploy smart contracts, you must have a key pair with the funds for all the chains you will be deploying.

To create the keys, follow these steps:

  • Open your Terminal and enter the following command

      cast wallet new
    

    This will generate new keys for you, which will look something like this ๐Ÿ‘‡๐Ÿป

    โš 
    THIS IS A TESTING WALLET.
  • Save your public address and private key.

  • Fund your address with the tokens of all the networks.

The Validator Keys

This tutorial will use the default Hyperlane's Multisig ISM. Multisig ISM is a module that takes several signatures from validators before completing the transaction. We use 4 addresses with the threshold 1.

Copy any 4 of your public addresses for later use.

Note: Make sure to have a private key secured for the public addresses you use. You can generate key pairs using the above method.

2. Cloning the Deploy Repository

The Hyperlane team provides you with a repository that you can use to deploy Hyperlane on your preferred chain.

Follow these steps to set up the Hyperlane deployment repo:

  • Open your terminal at your preferred directory.

  •     git clone https://github.com/hyperlane-xyz/hyperlane-deploy.git
    
  •     cd hyperlane-deploy
    
  •     yarn install
    

3. Adding a Custom Chain to Hyperlane

Hyperlane provided a few chains in the SDK. To add a chain missing from this list, follow these steps:

  • Open config/chains.ts, where you will find the configuration example for adding new chains.

  • Add the following configuration for the Polygon zkEVM Testnet:

        polygonzkevmtestnet: {
          name: 'polygonzkevmtestnet',
          chainId: 1442,
          protocol: ProtocolType.Ethereum,
          nativeToken: {
            name: 'ether',
            symbol: 'ETH',
            decimals: 18,
          },
          rpcUrls: [
            {
              http: 'https://rpc.public.zkevm-test.net',
            },
          ],
          blockExplorers: [
            {
              name: 'Polygon Scan',
              url: 'https://testnet-zkevm.polygonscan.com',
              apiUrl: 'https://api-zkevm.polygonscan.com/api',
            },
          ],
          isTestnet: true,
        },
    

4. Adding the Validator Keys

We will use the default Multisig as our Interchain Security Module.

Follow these steps to set up the keys:

  • Open config/multisig_ism.ts. You will find the configuration example for adding new chains and their keys there.

  • Add the keys for your validator:

        polygonzkevmtestnet: {
          threshold: 1,
          type: ModuleType.LEGACY_MULTISIG,
          validators: [
            '0xabcabcabcabcabcabcabcabcabcabcabcabcabca',
            '0xabcabcabcabcabcabcabcabcabcabcabcabcabca',
            '0xabcabcabcabcabcabcabcabcabcabcabcabcabca',
            '0xabcabcabcabcabcabcabcabcabcabcabcabcabca',
          ],
        },
    
  • threshold is 1, which means only one of the validator's signatures is required.

Woohoooo!!! You are done setting up the Hyperlane deployment on Polygon zkEVM testnet with remotes Mumbai and Sepolia.


5. Deploying Your Hyperlane

To deploy Hyperlane, run the following command on your terminal.

DEBUG=hyperlane* yarn ts-node scripts/deploy-hyperlane.ts --local polygonzkevmtestnet \
  --remotes mumbai sepolia \
  --key 0xbeda2b3910bae7dbfb4e65e9c0931f001066d4f0df257b77ad55093fa271bde2

In the above command,

  • we are running the deploy-hyperlane.ts script

  • with polygonzkevmtestnet as local chain and

  • mumbai and sepolia as remotes. Since mumbai and sepolia are already provided by the Hyperlane SDK we don't need to add the configurations again.

  • the value after key param is your private key to the address that contains funds for all the networks.

After running the command, wait for a few minutes till your terminal looks like this ๐Ÿ‘‡๐Ÿป


Congrats!!! You just deployed Hyperlane on Polygon zkEVM Testnet.

To test this deployment, you must run validators and relayers for all the chains you deployed (local + remote). To learn how to set up validators and relayers, check out these guides on the Hyperlane blog ๐Ÿ‘‡๐Ÿป


Thanks for reading this article; I hope you learned something today.

๐Ÿ’ก
If you wanna explore more check out the Hyperlane Docs, and if you have any queries get them resolved in Hyperlane India Telegram Channel.

Let me know if you have any doubts on Twitter, Lenster or LinkedIn.

Happy Learning ๐Ÿ™Œ๐Ÿป

Keep Building ๐Ÿงฑ๐Ÿš€

1
Subscribe to my newsletter

Read articles from megabyte directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

megabyte
megabyte

A guy with curiosity about new tech and aims to help the generation save time.