3c/doc/01_environment.md
2025-02-10 19:01:44 +01:00

64 lines
2.2 KiB
Markdown

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Getting a test Ethereum wallet](#getting-a-test-ethereum-wallet)
- [Getting free money 😎](#getting-free-money-)
- [Writing the contract](#writing-the-contract)
## Prerequisites
- Node.js and npm
## Installation
```bash
npm init -y
npm install --save-dev hardhat
npx hardhat
```
> What's Hardhat?
It's a development environment to compile, deploy, test, and debug your Ethereum software. It helps developers manage and automate the recurring tasks that are inherent to the process of building smart contracts and dApps[^1].
## Getting a test Ethereum wallet
>[!IMPORTANT]
> In order to do this you need to have 0.0001 ETH in your **Mainnet** wallet (for some fucking reason) which is ~25 real cents. Everything else is free.
1. Go to [MetaMask](https://metamask.io/)
2. Install the browser extension
3. Go to Advanced settings, click "Show Test Networks"
4. Click this button and select "Sepolia" from the dropdown (should be at the bottom)
![the button](assets/instruction_test.png)
## Getting free money 😎
The [google faucet](https://cloud.google.com/application/web3/faucet/ethereum/sepolia) is the easiest way to go. Unfortunately you only get 0.05 Sepolia ETH which is not enough to deploy a contract. You can also "mine" it [here](https://sepolia-faucet.pk910.de), but you need to go through a verification process.
## Writing the contract
Create a new file in the `contracts` directory called `CoinCoinCoin.sol` (or whatever) and paste the following code:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract TheTokenName is ERC20 {
constructor(uint256 initialSupply) ERC20("TheTokenName", "TTN") {
_mint(msg.sender, initialSupply * 10 ** decimals()); // This is the initial supply of the token
}
}
```
- This code creates a new ERC20 token with the name `TheTokenName` and the symbol `TTN`.
- It uses [OpenZeppelin](https://openzeppelin.com/solidity-contracts)'s `ERC20` contract to do so.
You're ready to [deploy the contract](02_minimal.md)! I don't want to add the fucking emojis but this is where you'd do the 🚀✨ and whatnot.
[^1]: Decentralized applications (lmao)