Skip to content

Deploying contracts

Ref - https://book.getfoundry.sh/forge/deploying

To deploy a contract, use the forge create command.

You will need some ETH to be able to deploy it.

Screenshot 2024-12-10 at 10.12.14 PM.png

forge create --rpc-url <your_rpc_url> --private-key <your_private_key> src/MyContract.sol:MyContract
  1. RPC URL - You can get one from Alchemy
  2. Private key - Export from Metamask
  3. Balance ETH - https://cloud.google.com/application/web3/faucet/ethereum/sepolia

Deploying ERC-20 contract on ETH Sepolia

forge create --rpc-url https://eth-sepolia.g.alchemy.com/v2/nnY0qPUQLYsUvb5BKJM5bh81sI6O0PQG --private-key fba7342ef6879df2c735644c734ea69c140f423d84eb2d53fbdfd53fd5d7c586 src/Token.sol:MyToken --legacy

Screenshot 2024-12-10 at 10.28.11 PM.png

https://sepolia.etherscan.io/tx/0xdd82ea46c582aa492b05e2c3340308aad06d5778e4b32950d8ea28c2dd457c03

Contract - https://sepolia.etherscan.io/address/0x1974d184240f5ff9cfb37f32da22d82fc6b66aa8

Screenshot 2024-12-10 at 10.29.52 PM.png

You can also go to etherscan and verify the contract.