1/5
## Account Abstraction Lesson 8: Deploy Ethereum This is an exciting time in our learning journey. We have finished our **minimal contract**. Now it is time to write some **deploy scripts**. We will be setting up a lot of code in this lesson. **We won't be going too deep into explanations here**. However, you are encouraged to do so on your own. --- Let's start by naming our first script in the `script` folder. Name it `DeployMinimal.s.sol`. Let's also go ahead and another script - `HelperConfig.s.sol`. We will need a HelperConfig because the EntryPoint contract will vary on different chains. And we will also need a `SendPackedUserOp.s.sol` This will be a vital piece for us and we will be doing a lot of work in this script. Let's get started in `DeployMinimal.s.sol`. **<span style="color:red">DeployMinimal.s.sol</span>** ```js // SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {Script} from "forge-std/Script.sol"; import {MinimalAccount} from "src/ethereum/MinimalAccount.sol"; contract DeployMinimal is Script { function run() public {} function deployMinimalAccount() public {} } ``` If you remember(or go back) to our MinimalAccount, the constructor passes `address entrypoint`. **<span style="color:red">MinimalAccount.sol</span>** ```js constructor(address entrypoint) ``` Let's set this up in our `HelperConfig.s.sol`. > ❗ **NOTE** This is a large block of code below. Please be sure to follow along with the video. **<span style="color:red">HelperConfig.s.sol</span>** ```js // SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {Script} from "forge-std/Script.sol"; contract HelperConfig is Script { error HelperConfig__InvalidChainId(); struct NetworkConfig { address entryPoint; address account; } uint256 constant ETH_SEPOLIA_CHAIN_ID = 11155111; uint256 constant ZKSYNC_SEPOLIA_CHAIN_ID = 300; uint256 constant LOCAL_CHAIN_ID = 31337; address constant BURNER_WALLET = 0X; //Your burner testnet wallet address here NetworkConfig public localNetworkConfig; mapping(uint256 chainId => NetworkConfig) public networkConfigs; constructor() { networkConfigs[ETH_SEPOLIA_CHAIN_ID] = getEthSepoliaConfig(); } function getConfig() public returns (NetworkConfig memory) { return getConfigByChainId(block.chainid); } function getConfigByChainId(uint256 chainId) public returns (NetworkConfig memory) { if (chainId == LOCAL_CHAIN_ID) { return getOrCreateAnvilEthConfig(); } else if (networkConfigs[chainId].account != address(0)) { return networkConfigs[chainId]; } else { revert HelperConfig__InvalidChainId(); } } function getEthSepoliaConfig() public pure returns (NetworkConfig memory) { return NetworkConfig({ entryPoint: 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789, account: BURNER_WALLET }); } function getZkSyncSepoliaConfig() public pure returns (NetworkConfig memory) { return NetworkConfig({ entryPoint: address(0), // There is no entryPoint in zkSync! account: BURNER_WALLET }); } function getOrCreateAnvilEthConfig() public returns (NetworkConfig memory) { if (localNetworkConfig.account != address(0)) { return localNetworkConfig; } } } ``` Now that we have our `HelperConfig`, let's import it in `DeployMinimal.s.sol`. **<span style="color:red">DeployMinimal.s.sol</span>** ```js import { HelperConfig } from "script/HelperConfig.s.sol"; ``` Then we need to add it to our `deployMinimalAccount` function. ```js function deployMinimalAccount() public returns (HelperConfig, MinimalAccount) { HelperConfig helperConfig = new HelperConfig(); HelperConfig.NetworkConfig memory config = helperConfig.getConfig(); vm.startBroadcast(); MinimalAccount minimalAccount = new MinimalAccount(config.account); minimalAccount.transferOwnership(msg.sender); vm.stopBroadcast(); return (helperConfig, minimalAccount); } ``` Let's run `forge build` in our terminal to check that everything is compiling. > ❗ **NOTE** You may see some yellow warnings, but that is not concerning at this point. As long as there aren't any red errors, you are good. We did a lot of coding in this lesson. However, we've still go a way to go. Take a minute to reflect on the code that we have written so far. When you are ready, move on to the next lesson.
Creating a deployment (and helper) script to deploy an Ethereum account!
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Advanced smart contract development
How to develop a stablecoin
How to develop a DeFi protocol
How to develop a DAO
Advanced smart contracts testing
Fuzz testing
Manual verification
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Security researcher
$49,999 - $120,000 (avg. salary)
Guest lecturers:
Juliette Chevalier
Lead Developer relations at Aragon
Nader Dabit
Director of developer relations at Avara
Ally Haire
Developer relations at Protocol Labs
Harrison
Founder at GasliteGG
Last updated on November 29, 2024
Solidity Developer
Advanced FoundryDuration: 36min
Duration: 3h 06min
Duration: 5h 02min
Duration: 2h 47min
Duration: 1h 23min
Duration: 4h 28min
Duration: 1h 19min
Duration: 58min
Course Overview
About the course
Advanced smart contract development
How to develop a stablecoin
How to develop a DeFi protocol
How to develop a DAO
Advanced smart contracts testing
Fuzz testing
Manual verification
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Security researcher
$49,999 - $120,000 (avg. salary)
Guest lecturers:
Juliette Chevalier
Lead Developer relations at Aragon
Nader Dabit
Director of developer relations at Avara
Ally Haire
Developer relations at Protocol Labs
Harrison
Founder at GasliteGG
Last updated on November 29, 2024
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar