- Run
git submodule update --init --recursiveto update/download all libraries. - Run
yarn installto install any additional dependencies.
- Install solidity extension https://marketplace.visualstudio.com/items?itemName=juanblanco.solidity
- Navigate to a .sol file
- Right-click, select
Solidity: Change global compiler version (Remote)
- Select 0.7.6
- Install solhint extension https://marketplace.visualstudio.com/items?itemName=idrabenia.solidity-solhint
Install Foundry CLI (forge 0.2.0) from official website.
- To install a specific version, see here.
Run forge test to run test using installed forge cli or make test to run tests in docker container.
Log level is controlled by the -v flag. For example, forge test -vv displays console.log() statements from within contracts. Highest verbosity is -vvvvv. More info: https://book.getfoundry.sh/forge/tests.html#logs-and-traces. Contracts that use console.log() must import lib/forge-std/src/console.sol.
Run make anvil-test to setup anvil test node in docker container and run integration tests. There is an example in anvil/ folder
Run yarn lint to lint all .sol files in the src and test directories.
Run make analyze-{message-transmitter | message-transmitter-v2 | token-messenger-minter} to set up Mythril dependency and run Mythril on all source files. If Mythril dependency has been installed, alternatively run myth -v4 analyze $FILE_PATH --solc-json mythril.config.json --solv 0.7.6 to run static analysis on a .sol file at the given $FILE_PATH. Please note that this can take several minutes.
We use Github actions to run linter and all the tests. The workflow configuration can be found in .github/workflows/ci.yml
You can manually trigger the Olympix.ai Code Scanning workflow using the workflow_dispatch feature of GitHub Actions.
- Click on the
Actionstab. - In the left sidebar, select
Olympix Scan. - Select the branch & click on the
Run workflowbutton.
Use Docker to run Foundry commands. Run make build to build Foundry docker image. Then run docker run --rm foundry "<COMMAND>" to run any forge, anvil or cast commands. There are some pre defined commands available in Makefile for testing and deploying contract on anvil. More info on Docker and Foundry here.
ℹ️ Note
- Some machines (including those with M1 chips) may be unable to build the docker image locally. This is a known issue.
The contracts are deployed using Forge Scripts. The script is located in scripts/v1/deploy.s.sol. Follow the below steps to deploy the contracts:
-
Add the below environment variables to your env file
MESSAGE_TRANSMITTER_DEPLOYER_KEYTOKEN_MESSENGER_DEPLOYER_KEYTOKEN_MINTER_DEPLOYER_KEYTOKEN_CONTROLLER_DEPLOYER_KEYATTESTER_ADDRESSUSDC_CONTRACT_ADDRESSREMOTE_USDC_CONTRACT_ADDRESSMESSAGE_TRANSMITTER_PAUSER_ADDRESSTOKEN_MINTER_PAUSER_ADDRESSMESSAGE_TRANSMITTER_RESCUER_ADDRESSTOKEN_MESSENGER_RESCUER_ADDRESSTOKEN_MINTER_RESCUER_ADDRESSTOKEN_CONTROLLER_ADDRESSDOMAINREMOTE_DOMAINBURN_LIMIT_PER_MESSAGE
In addition, to link the remote bridge, one of two steps needs to be followed:
- Add the
REMOTE_TOKEN_MESSENGER_DEPLOYERaddress to your env file and run scripts/precomputeRemoteMessengerAddress.py with argument--REMOTE_RPC_URLfor the remote chain, which will automatically add theREMOTE_TOKEN_MESSENGER_ADDRESSto the .env file - Manually add the
REMOTE_TOKEN_MESSENGER_ADDRESSto your .env file.
-
Run
make simulate-deploy RPC_URL=<RPC_URL> SENDER=<SENDER>to perform a dry run. Note: Use address from one of the private keys (used for deploying) above assender. It is used to deploy the shared libraries that contracts use -
Run
make deploy RPC_URL=<RPC_URL> SENDER=<SENDER>to deploy the contracts
Deploy Create2Factory first if not yet deployed.
- Add the environment variable
CREATE2_FACTORY_OWNER(address) to your env file. - Run
make simulate-deploy-create2-factory RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<PRIVATE_KEY>to perform a dry run. - Run
make deploy-create2-factory RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<PRIVATE_KEY>to deploy the Create2Factory.
Deploy the implementation contracts.
-
Add the following env variables
CREATE2_FACTORY_CONTRACT_ADDRESSTOKEN_MINTER_V2_OWNER_KEYTOKEN_CONTROLLER_ADDRESSDOMAINMESSAGE_BODY_VERSIONVERSION
-
Run
make simulate-deploy-implementations-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to perform a dry run. -
Run
make deploy-implementations-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to deploy MessageTransmitterV2, TokenMinterV2, and TokenMessengerV2.
The proxies are deployed via CREATE2 through Create2Factory. The scripts assumes the remote chains are EVM compatible and predicts that remote contracts will be deployed at the same addresses. Follow the below steps to deploy the contracts:
-
Replace the environment variables in your env file with the following:
Note:
REMOTE_DOMAINS,REMOTE_USDC_CONTRACT_ADDRESSES, andREMOTE_TOKEN_MESSENGER_V2_ADDRESSESmust all correspond 1:1:1 in order.-
USDC_CONTRACT_ADDRESS -
TOKEN_CONTROLLER_ADDRESS -
REMOTE_DOMAINS -
REMOTE_USDC_CONTRACT_ADDRESSES -
REMOTE_TOKEN_MESSENGER_V2_ADDRESSES -
CREATE2_FACTORY_CONTRACT_ADDRESS -
MESSAGE_TRANSMITTER_V2_OWNER_ADDRESS -
MESSAGE_TRANSMITTER_V2_PAUSER_ADDRESS -
MESSAGE_TRANSMITTER_V2_RESCUER_ADDRESS -
MESSAGE_TRANSMITTER_V2_ATTESTER_MANAGER_ADDRESS -
MESSAGE_TRANSMITTER_V2_ATTESTER_1_ADDRESS -
MESSAGE_TRANSMITTER_V2_ATTESTER_2_ADDRESS -
MESSAGE_TRANSMITTER_V2_PROXY_ADMIN_ADDRESS -
TOKEN_MINTER_V2_PAUSER_ADDRESS -
TOKEN_MINTER_V2_RESCUER_ADDRESS -
TOKEN_MESSENGER_V2_OWNER_ADDRESS -
TOKEN_MESSENGER_V2_RESCUER_ADDRESS -
TOKEN_MESSENGER_V2_FEE_RECIPIENT_ADDRESS -
TOKEN_MESSENGER_V2_DENYLISTER_ADDRESS -
TOKEN_MESSENGER_V2_PROXY_ADMIN_ADDRESS -
TOKEN_MESSENGER_V2_MIN_FEE_CONTROLLER_ADDRESS -
TOKEN_MESSENGER_V2_MIN_FEE -
DOMAIN -
BURN_LIMIT_PER_MESSAGE -
TOKEN_CONTROLLER_KEY -
TOKEN_MINTER_V2_OWNER_KEY
-
-
Run
make simulate-deploy-proxies-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to perform a dry run. -
Run
make deploy-proxies-v2 RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to deploy the contracts -
ONLY perform steps 5-7 for additional remote resources NOT already configured above.
-
Replace the environment variables in your env file with the following. We'll just add one remote resource (e.g. adding remote token messenger and remote usdc contract addresses) at a time, so just pick any and then repeat these steps. This will need to be repeated for each remote chain:
TOKEN_MESSENGER_V2_OWNER_KEYTOKEN_CONTROLLER_KEYTOKEN_MESSENGER_V2_CONTRACT_ADDRESSTOKEN_MINTER_V2_CONTRACT_ADDRESSUSDC_CONTRACT_ADDRESSREMOTE_USDC_CONTRACT_ADDRESSREMOTE_DOMAIN
-
Run
make simulate-setup-remote-resources-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to perform a dry run of adding remote resources. -
Run
make setup-remote-resources-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to setup the remote resources.
[Remaining steps are only for mainnet]
-
Replace the environment variables in your env file with:
MESSAGE_TRANSMITTER_V2_CONTRACT_ADDRESSTOKEN_MESSENGER_V2_CONTRACT_ADDRESSTOKEN_MINTER_V2_CONTRACT_ADDRESSMESSAGE_TRANSMITTER_V2_OWNER_KEYTOKEN_MESSENGER_V2_OWNER_KEYTOKEN_MINTER_V2_OWNER_KEYMESSAGE_TRANSMITTER_V2_NEW_OWNER_ADDRESSTOKEN_MESSENGER_V2_NEW_OWNER_ADDRESSTOKEN_MINTER_V2_NEW_OWNER_ADDRESSNEW_TOKEN_CONTROLLER_ADDRESS
-
Run
make simulate-rotate-keys-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to perform a dry run of rotating the keys. -
Run
make rotate-keys-v2 RPC_URL=<RPC_URL> SENDER=<SENDER>to rotate keys.
Use Create2Factory to deploy the helper library to a deterministic address for easy integration.
-
Set the following env variables:
CREATE2_FACTORY_CONTRACT_ADDRESS
-
Run
make simulate-deploy-address-utils-external RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to perform a dry run. -
Run
make deploy-address-utils-external RPC_URL=<RPC_URL> SENDER=<SENDER> CREATE2_FACTORY_OWNER_KEY=<CREATE2_FACTORY_OWNER_KEY>to deploy.
The PredictCreate2Deployments.s.sol script can help compute expected deployment addresses for various contracts. You can run it like so:
-
Predicting MessageTransmitterV2 Implementation:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "messageTransmitterV2Impl(address,uint32,uint32)" <create2FactoryAddress> <domain> <message version> -
Predicting TokenMessengerV2 Implementation:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "tokenMessengerV2Impl(address,uint32)" <create2FactoryAddress> <messageBodyVersion> -
Predicting MessageTransmitterV2 Proxy:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "messageTransmitterV2Proxy(address)" <create2FactoryAddress> -
Predicting TokenMessengerV2 Proxy:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "tokenMessengerV2Proxy(address)" <create2FactoryAddress> -
Predicting TokenMinter:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "tokenMinterV2(address)" <create2FactoryAddress> -
Predicting AddressUtilsExternal:
forge script scripts/v2/PredictCreate2Deployments.s.sol --sig "addressUtilsExternal(address)
For license information, see LICENSE and additional notices stored in NOTICES.

