It's project deploy my first contract on the Ethereum Sepolia (testnet).
My steps:
- I have installed Metamask wallet on my Google Chrome web browser. https://chromewebstore.google.com/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
- I have installed Visual Studio Code, because my PyCharm is so big and very slowly, and Remix on the web browser not have all options. VSC it's great. https://code.visualstudio.com/Download
- I had synchronic my VSC with my Github account.
- It's installed Node.js for environment starter to going to write scripts in JavaScript. https://nodejs.org/en/download
- Its opened new project in VSC "ContractDeployOnSepoliaEthereum".
- I was created new contract "MyFirstContract.sol".
- Its created new reposytory on GitHub. VSC: Source Control > Publish to GitHub
- Its created .gitignore file when I was pushed my new repository on GitHub.
- Instaled Solidity in Extensions VSC. VSC: Extensions > Solidity (I was choised "juanblanco.solidity")
- I opened terminal bash and I go to my "Contracts" folder in "ContractDeployOnSepoliaEthereum" folder. BASH: cd ~/ContractDeployOnSepoliaEthereum/contracts
- I was checked contents my folder "contracts" in "ContractDeployOnSepoliaEthereum" BASH: ls
- How I check mine correct folder? BASH: pwd
- I always install all necessary tools in the project folder.
- I had installed Node.js, then I could install my first pack for my project in correct folder.
- I started with harmonogram for my project. BASH: npm init -y (Node.js create new file "package.json" with default setting about my project, exp. name project, version project, scrypts in project etc.)
- Node.js install "hardhat" toolbox. BASH: npm install --save-dev hardhat (This install is only tool box, not production code. It's only for dev.)
- I want automatic connection with network testnet Ethereum Sepolia. BASH: npm install -D @nomicfoundation/hardhat-toolbox (This toolbox give me "ethers" plug, it give automatic connection between my code and Sepolia. It easy deploy new contract.)
- Now I must install "ethers" library. It's to appear in "devdependencies" in package.json file. BASH: npm install --save ethers (It's need it for me to going to deploy contract.)
- I was installed "dotenv" library in next step. BASH: npm install --save dotenv (Thanks to this I can load my ".env" secret file.)
- I have created my ".env" file in VSC in project. In this file, I have my two variables: "SEPOLIA_RPC_URL" and "PRIVATE_KEY".
- I need tokens testnet for my Ethereum Sepolia blockchain in Metamask wallet.
- I know a lot of places, where I can download tokens testnet.
- I had choiced Google Cloud Web3 delivery when I download my testnet tokens.
https://cloud.google.com/application/web3/faucet/ethereum/sepolia (This is only 5% ETH but it is enough.) - Now I sign up on the platform: https://cloud.google.com When I have my profile, I create on this site new project for me, and it is similar name what I was created in VSC on my computer. I going to copy API address for connect my libraries "Hardhat" and "ethers" with Sepolia Ethereum. I search: "Blockchain RPC", in up central side. I was chase "Blockchain RPC: product". I copy JSON-ERC endpoint for Ethereum Sepolia > location: "us-central1", and I paste it in .env file to "SEPOLIA_RPC_URL=".
- I had written ".env" in ".gitignore" file, before I downloaded my "PRIVATE_KEY" from Metamask.
- I have downloaded "PRIVATE_KEY" from Metamask and I was wrote it in ".env". METAMASK: select account > tap three dots > account details > private key > password > and I copy to ".env" file Now when I going to deploy new contract hardhat automatic send it to blockchain. Hardhat deploy contract and download gas fee from this transaction. This transact perform in background.
- Create "hardhat.config.cjs" (.cjs = JavaScript in form Hardhat: CommonJS) This file speaks Hardhat how to work.
- Create "deploy.js" (.js = JavaScript) script. This "deploy.js" file deploy contract, connecting with network from "hardhat.config.cjs" and ".env".
- Create contract "MyFirstContract.sol" (.sol = Solidity).
- Now, Hardhat must to know how deploy my Contract on blockchain: BASH: npx hardhat compile
- I deploy my contract on Sepolia Ethereum: BASH: npx hardhat run scripts/deploy.js --network sepolia
- Now, I will go to website Scan Sepolia Ethereum, write my address and I checked would my contract correct deploy: https://sepolia.etherscan.io/
ERRORS and WARNINGS:
-
BASH > HH8 My ".env" wasn't in correct folder. Solution: File ".env" must be in general project folder.
-
BASH > HHE909 HardHat hadn't found compatible solc version. It was wrote 0.8.29 version and Hardhat didn't downloaded. Solution:
solidity: { compilers: [ { version: "0.8.28", }, { version: "0.8.29", }, ], },
-
BASH > Error HHE201 I didn't installed appropriate plugs. Solution: npm install -D @nomicfoundation/hardhat-toolbox
-
BASH > HH13 It "hardhat.config.ts" script in (.ts) typescript version. Solution: I installed: npm install --save-dev ts-node --legacy-peer-deps It didn't working. Solution: I changed name and code in hardhat.config.cjs (.ts > .cjs) nad deploy.js scripts. In bash: npx hardhat clean npx hardhat compile It's working.
-
BASH > HH601 Script "deploy.js" not exist. Solution: I transferred my "deploy.js" file in good place.
Finish.
Other commits: [23.08.2025] Document config filename changes [24.08.2025] Hardhat error HH8