From 4db1831d1f4415490f878d05faf1ea0789efa98f Mon Sep 17 00:00:00 2001 From: Luis Fernando Date: Mon, 30 Dec 2024 12:58:42 -0500 Subject: [PATCH] feat(deploy): update forge commands with --broadcast flag and Introduced a deployment script to enhance deployment process --- .../using-foundry.md | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/build-on-mode/deploying-a-smart-contract/using-foundry.md b/build-on-mode/deploying-a-smart-contract/using-foundry.md index 742b8c1..93d8ad9 100644 --- a/build-on-mode/deploying-a-smart-contract/using-foundry.md +++ b/build-on-mode/deploying-a-smart-contract/using-foundry.md @@ -111,6 +111,30 @@ Transaction hash: 0xbe2d27554f130a720c4dd82dad055c941ca44dee836f6333a8507d76022c Copy the “Deployed to” value and store it somewhere to use later. This is the address of your contract. +4.2. Create a deployment script: +In the **/script** directory of your project, create a file named **DeployMyERC20.s.sol** and add the following content: + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {Script} from "forge-std/Script.sol"; +import {MyERC20} from "../src/MyERC20.sol"; + +contract DeployMyERC20 is Script { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + vm.startBroadcast(deployerPrivateKey); + MyERC20 token = new MyERC20(); + vm.stopBroadcast(); + } +} +``` + +```bash +forge script script/DeployMyERC20.s.sol:DeployMyERC20 --rpc-url --broadcast --private-key +``` + ## 5. Verifying the ERC20 token contract after deployment 5.1. For already deployed contracts you can use the verify-contract command: @@ -134,5 +158,3 @@ In the "Contract" tab you'll find your verified contract. Congratulations, you just deployed and verified a contract on Mode Network using Foundry. To learn more about Mode and how to turn your code into a business, join our [Discord](https://discord.gg/modenetworkofficial) and say hello 👋 - -If you want the next challenge, you can try registering a contract for the SFS following this guide: [sfs-registering-a-contract-with-remix.md](../sfs-sequencer-fee-sharing/register-a-smart-contract/sfs-registering-a-contract-with-remix.md "mention")\