The following content will guide you through deploying and configuring all smart contracts to a new network (or to deploy a new staging environment).
If you only want to deploy a new diamond contract and use existing deployed facets, please skip to this section
- Prepare your .env file to have the following values set:
ETHNODE_URI<NETWORK>= (NETWORK being the network you deploy to e.g. MAINNET, POLYGON or BSC) (e.g. https://1rpc.io/eth)
<NETWORK>_ETHERSCAN_API_KEY=
if you deploy to another network, make sure you have both variables set for that specific network. E.g.: ETH_NODE_URI_GOERLI and GOERLI_ETHERSCAN_API_KEY for deployments to Goerli etc.
PRODUCTION=false (set to true if you want to deploy to production obviously, but confirm with @Edmund Zynda beforehand)
- Install required packages
https://github.com/foundry-rs/foundry
https://github.com/charmbracelet/gum
https://github.com/stedolan/jq
- Merge your branch with latest master to make sure you have all the latest addresses stored in your deployments folder
-
CREATE3Factory
- Each network has its own CREATE3Factory deployment
- Factory addresses are stored in
networks.json - The factory is automatically deployed if not present on the target network
-
RPC Configuration
- For LI.FI developers: RPC URLs are stored in MongoDB and automatically synced to
.env - For external developers: You must manually set RPC URLs in your
.envfile:Example:ETH_NODE_URI_<NETWORKNAME>="<RPC_URL>"ETH_NODE_URI_MAINNET="https://eth-mainnet.g.alchemy.com/v2/your-api-key" ETH_NODE_URI_POLYGON="https://polygon-mainnet.g.alchemy.com/v2/your-api-key" - See
.env.examplefor the required format - Make sure to use reliable RPC providers for production deployments
- For LI.FI developers: RPC URLs are stored in MongoDB and automatically synced to
-
Network Verification
- Etherscan API keys are required for contract verification
- Keys are stored in
.envfile with the format<NETWORK>_ETHERSCAN_API_KEY - Networks using EtherscanV2 API (like Ethereum mainnet and its L2s) share the same API key
- For networks that don't require an API KEY, use
NO_ETHERSCAN_API_KEY_REQUIREDas the value to prevent Foundry errors
Scripts:
- /scripts/scriptMaster.sh (for deploying any of our contracts)
- execute with command
./scripts/scriptMaster.shin your console
- execute with command
(find detailed instructions for each step above)
- Run this script
./scripts/scriptMaster.shand select3) Deploy all contracts to one selected network (=new network) - Choose a network
- The script will:
- Deploy CREATE3Factory if not present
- Store the factory address in networks.json
- Deploy the diamond contract
- Add all required facets
- Run the script
./scripts/scriptMaster.shand select1) Deploy one specific contract to one network - Choose the network
- Choose the contract you want to deploy and choose to add it to the diamond or not (choose not if you plan to upgrade using a SAFE)
- Make sure you have deployed a new diamond contract (see above)
- Make sure the diamond contract is owned by the SAFE wallet you will use for the upgrade
- Ensure that you have granted access to a secondary wallet to add dexs/sigs
- Make sure the facet you wish to upgrade is deployed but not added to the diamond yet
- Run this script
./scripts/scriptMaster.sh, select11) Propose upgrade TX to Gnosis SAFE - Choose the network you want to run the upgrade on
- Choose the facet(s) you want to upgrade (you can select multiple using the spacebar)
- Hit enter and select the SAFE wallet you want to use
- Hit enter again and wait for the script to finish
- Go to the Gnosis SAFE app and confirm the transaction