A hardhat plugin that allows developers to deploy contracts to exact same addresses and verify them on multiple networks (superchain or any EVM compatible network) with few commands.
Superchain Deployer is a hardhat plugin that allows developers to deploy contracts to exact same addresses and verify them on multiple networks (superchain or any EVM compatible network) with few commands.
Using same addresses is needed when it comes to building cross chain dApps. This prevents confusion both for developers and users. The best approach for deploying a contract on multiple networks is to generate a fresh EOA and fund it on multiple networks, then run deploy script on all networks. Superchain Deployer handles this process.
*With "generate-deployer" it generates a deployer EOA account, asks for a password, encypts and saves .json file. This aacount can later be used by any browser wallet application (ex. Metamask).
*Developers can fund this deployer account with "fund-deployer" on multiple networks. This command takes contract and constructor arguments as input, calculates the gas needed to make deployment transaction succeed for sure and sends it to deployer account. For this to work devs need to define a funder account on config file.
*Later using "superchain-deploy" devs can deploy their contracts to all configured networks. This takes the usual deployment script written by the dev and runs it on wanted networks.
*After the deployment they can verify their contracts on all explorers with superchain-verify
command.
Additionally there are "check-balances" and "get-private-key" commands. Devs write their usual deployment script and later run commands in this project to deploy on multiple networks. With this approach it becomes as easy to deploy a dApp working on multiple chains as it is to deploy dApps working on a single network.
This project uses Hardhat Runtime Environment for deploying and verifying smart contracts. It uses ethers library for estimating deployment gas, sending funds, checking balances, generating accounts and encrypting/decrypting them. It is a cli tool and uses ‘chalk’ and ‘prompt-sync’ for user interaction (asking for password, logs, error messages etc..).
It was somewhat hard to change the network on HRE during runtime. For sending funds it was not a problem. Since sending funds was not involving HRE. But for deployment and verifying tasks need to change network constantly and do the same operatiın on each configured network. Directly manipulating hre.network was not working so I took another approach using hre.hardhatArguments to change the network for deploying and running terminal commands with ‘child_process’ for verifying.
To calculate deployment cost I needed several information first how much gas it would take to make the transaction and the gas price. So I used ethers library, took contract and constructor arguments as inputs, generated a deployment transaction and extracted gas estimation from this data. From the provider of the network to deploy called fee data to get current gas. Then in order for deployment transactions to succeed for sure I’ve declared 1.5 times of the deployment cost to be sent from dev’s funder account to deployer account.