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.
- 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 scriptAPI_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 keyMAILBOX
: address of Hyperlane Mailbox contract on the chainROUTER_OWNER
: address of the router ownerPROXY_ADMIN
: address of the proxy admin. The router is deployed using aTransparentUpgradeableProxy
ISM_SALT
: a salt for deploying the ISM the router uses. The provided in this repo is anRoutingIsm
which allows the user indicate the ISM used when sending the messageROUTER_IMPLEMENTATION
: the address of an existing implementation in the networkISM
: the address of an existing implementation in the networkCUSTOM_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 routersROUTER
: address of the local routerROUTERS
: a list of routes addresses, separated by commasDOMAINS
: the domains list of the routers to enroll, separated by commas
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
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:
- 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
- Use this syntax to install from GitHub:
- 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.
This is a list of the most frequently needed commands.
Build the contracts:
$ forge build
Delete the build artifacts and cache directories:
$ forge clean
Compile the contracts:
$ forge build
Get a test coverage report:
$ forge coverage
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 the contracts:
$ forge fmt
Get a gas report:
$ forge test --gas-report
Lint the contracts:
$ bun run lint
Run the tests:
$ forge test
This project is licensed under MIT.