Added basic docs
This commit is contained in:
59
doc/01_environment.md
Normal file
59
doc/01_environment.md
Normal file
@ -0,0 +1,59 @@
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Installation](#installation)
|
||||
- [Getting a test Ethereum wallet](#getting-a-test-ethereum-wallet)
|
||||
- [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)
|
||||
|
||||
|
||||

|
||||
|
||||
## 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)
|
||||
|
48
doc/02_minimal.md
Normal file
48
doc/02_minimal.md
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
- [Compiling and deploying](#compiling-and-deploying)
|
||||
- [Interacting with the contract](#interacting-with-the-contract)
|
||||
|
||||
This document focuses on the minimal setup required to deploy a smart contract to the Ethereum blockchain. It assumes you have already set up your development environment and have a test Ethereum wallet.
|
||||
|
||||
|
||||
## Compiling and deploying
|
||||
First, modify `scripts/deploy.js` in the Hardhat project:
|
||||
|
||||
```js
|
||||
const hre = require("hardhat");
|
||||
|
||||
async function main() {
|
||||
const initialSupply = hre.ethers.parseUnits("1000", 18); // 1000 MTK tokens
|
||||
const MyToken = await hre.ethers.deployContract("MyToken", [initialSupply]);
|
||||
await MyToken.waitForDeployment();
|
||||
|
||||
console.log(`MyToken deployed to: ${MyToken.target}`);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
```
|
||||
|
||||
then, deploy like this:
|
||||
```bash
|
||||
npx hardhat run scripts/deploy.js --network sepolia
|
||||
```
|
||||
|
||||
## Interacting with the contract
|
||||
|
||||
You can see it on your favorite block explorer (e.g., [Etherscan](https://etherscan.io/)) by pasting the contract address.
|
||||
|
||||
You can send it via the MetaMask extension by clicking "Send" and pasting the contract address.
|
||||
|
||||
You can also interact with it programmatically using the Hardhat console:
|
||||
|
||||
```bash
|
||||
npx hardhat console --network sepolia
|
||||
```
|
||||
|
||||
```js
|
||||
const MyToken = await ethers.getContract("WhateverYouNamedIt", "0xYourContractAddress");
|
||||
await MyToken.totalSupply();
|
||||
```
|
BIN
doc/assets/instruction_test.png
Normal file
BIN
doc/assets/instruction_test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
Reference in New Issue
Block a user