diff --git a/README.md b/README.md index d7a0f8d..144b0c9 100644 --- a/README.md +++ b/README.md @@ -62,105 +62,67 @@ For running integration tests in Anvil node, run `make anvil-tests`. This runs t * `cast code $address` -## On-chain Deployment & Verification +## Chain Expansion Guide -### Start a Local Network (optional, for testing) +This section explains how to expand the existing smart contracts to new blockchains. -`npx hardhat node` (if using hardhat stack) +### Prerequisites +#### Fund deployer and owner +Make sure there are enough native tokens for the new chain in the deployer address (for contract deployment) and temporary owner +address (for setup and stake). Otherwise, you may hit `insufficient fund` error at any step. -`make anvil` (if using foundry stack). To get a list of pre-funded addresses, you can look at the beginning of the logs in the `anvil` Docker container, or reference . +#### Add new blockchain RPC URLs to foundry +1. Add new blockchain to `[rpc_endpoints]` in `foundry.toml` following the format of `blockchain_a = ${BLOCKCHAIN_A_RPC_URL}` +2. Update `.env.example` with the new RPC URL env var (e.g. `BLOCKCHAIN_A_RPC_URL`), also update your local `.env` to set up the new env var (e.g. `BLOCKCHAIN_A_RPC_URL=https://blockchaina.rpc.com`). +3. Add new blockchain (e.g. `"blockchain_a"`) to `getChains()` function in `./script/bytecode-deploy/100_Constants.sol`. +4. Since the length of `getChains()` changed above, update the length of local chain list generated by `getChains()` in deployment scripts. -### Deploy & Verify -#### SCA and Paymaster - 1. Deployment - * Run the command `env $(grep -v '^#' .env) yarn hardhat deploy --network ` where `` is one of {`mumbai`, `goerli`}. - If you only want to deploy a specific set of smart contracts, you can add the `--tags` flag, for example: `env $(grep -v '^#' .env) yarn hardhat deploy --tags SponsorPaymaster --network goerli` - 2. Verification - * ECDSA wallet factory `env $(grep -v '^#' .env) npx hardhat verify --network mumbai --constructor-args script/ecdsa_account_factory_constructor_args.js ECDSA_ACCOUNT_FACTORY_ADDRESS` - * Sponsor paymaster `env $(grep -v '^#' .env) npx hardhat verify --network goerli --constructor-args script/sponsor_paymaster_constructor_args.js STABLECOIN_PAYMASTER_ADDRESS` - * Fallback: If the verification commands do not work for contracts deployed through the hardhat deployment scripts, you can still verify manually through etherscan's UI by submitting the standard input json. - - You can find this file under `deployments/polygon/solcInputs` (you can try different blockchain but I'm unsure of results). Then submit the file that you think is the one for the contract your trying to verify. It's a bit of guessing, but you can look at the source code to try and figure it out. You may also need to verify the proxies manually through etherscan after having verified the implementation. -#### MSCA - 1. Set up `DEPLOYER_PRIVATE_KEY`, `RPC_URL` and `ETHERSCAN_API_KEY` in .env - 2. Run `source .env` - 3. Run the desired numbered scripts inside the `script/` folder using the below command format. Make sure any environment variable values from previous steps are updated if needed as you progress through the scripts. - * `forge script script/ --rpc-url $RPC_URL --broadcast --verify -vvvv` - - Example: `forge script script/001_DeployPluginManager.s.sol --rpc-url $RPC_URL --broadcast --verify -vvvv` +### Deploy & Verify EPv0.6 SponsorPaymaster +Deploy, setup and verify SponsorPaymaster compatible with ERC-4337 v0.6. - Tip: before executing the above command, verify the simulation works as expected by running the above command without the `--broadcast` and `--verify` flags. This way, you can also make sure your address will have enough tokens to cover the transaction fee estimated in the simulation. +#### Run deploy command +Note that deploy commands attempt to deploy on all chains listed in foundry.toml. - Note: if you are deploying on a local network, don't use the `--verify` flag. - - 4. Include the relevant logs from the `broadcast` folder in your commit. +```shell +forge script script/bytecode-deploy/101_DeploySponsorPaymaster.s.sol -vvvv --slow --broadcast --force --multi +``` - Tip: if you did multiple runs, search the appropriate block explorer for the tx hash corresponding the desired contract's deployment, and then search the logs for the transaction hash. +#### Setup SponsorPaymaster - Tip: logs are organized by chain ID in the lower levels in the `broadcast` folder. Use to lookup IDs of common chains. +Need to use block explorer to run `addStake` and `setVerifyingSigner` from owner address. - 5. Create or update the corresponding file in the `script/cmd` folder using the creation bytecode of the contract from the logs. See the below "Chain Expansion" section for details on how to format of the files in the `script/cmd` folder. - 6. Verify in block explorer like etherscan using standard input json - * Create the standard input json: run the beoow command - - ```shell - forge verify-contract --show-standard-json-input >