Skip to content

BootNodeDev/hyperlane-create2-factory-router

Repository files navigation

Hyperlane InterchainCreate2FactoryRouter

This repo contains a possible solution for hyperlane-xyz/hyperlane-monorepo#2232.

The InterchainCreate2FactoryRouter would allow to deploy a contract on any given chain Hyperlane and the router are deployed from another chain with the same conditions. This allows developers to just have a balance on one chain but deploy contracts on multiple chains.

Deploy the router

  • Run yarn install to install all the dependencies
  • Create a .env file base on the .env.example file file, and set the required variables depending which script you are going to run.

Set the following environment variables required for running all the scripts, on each network.

  • NETWORK: the name of the network you want to run the script
  • API_KEY_ALCHEMY: you Alchemy API key

If the network is not listed under the rpc_endpoints section of the foundry.toml file you'll have to add a new entry for it.

For deploying the router you have to run the yarn run:deployRouter. Make sure the following environment variable are set:

  • DEPLOYER_PK: deployer private key
  • MAILBOX: address of Hyperlane Mailbox contract on the chain
  • ROUTER_OWNER: address of the router owner
  • PROXY_ADMIN: address of the proxy admin. The router is deployed using a TransparentUpgradeableProxy
  • ISM_SALT: a salt for deploying the ISM the router uses. The provided in this repo is an RoutingIsm which allows the user indicate the ISM used when sending the message
  • ROUTER_IMPLEMENTATION: the address of an existing implementation in the network
  • ISM: the address of an existing implementation in the network
  • CUSTOM_HOOK: some custom hook address to be set, address zero indicates the Mailbox default hook should be used

For enrolling routers you have to run yarn run:enrollRouters. Make sure the following environment variable are set:

  • ROUTER_OWNER_PK: the router's owner private key. Only the owner can enroll routers
  • ROUTER: address of the local router
  • ROUTERS: a list of routes addresses, separated by commas
  • DOMAINS: the domains list of the routers to enroll, separated by commas

Example usage

Running the example script yarn run:interchainDeploy would deploy a TestDeployContract from the chain you set on NETWORK to the one you set on DESTINATION_NETWORK using the router set on ROUTER and the salt on EXAMPLE_SALT

Installing Dependencies

Foundry typically uses git submodules to manage dependencies, but this template uses Node.js packages because submodules don't scale.

This is how to install dependencies:

  1. Install the dependency using your preferred package manager, e.g. yarn install dependency-name
    • Use this syntax to install from GitHub: yarn install github:username/repo-name
  2. Add a remapping for the dependency in remappings.txt, e.g. dependency-name=node_modules/dependency-name

Note that OpenZeppelin Contracts is pre-installed, so you can follow that as an example.

Usage

This is a list of the most frequently needed commands.

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Deploy

Deploy to Anvil:

$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545

For this script to work, you need to have a MNEMONIC environment variable set to a valid BIP39 mnemonic.

For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.

Format

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Lint

Lint the contracts:

$ bun run lint

Test

Run the tests:

$ forge test

License

This project is licensed under MIT.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published