- Notifications
You must be signed in to change notification settings - Fork0
Getting Started In Ethereum, with an interactive ERC-20, ERC-721 and ERC-1155 token contract explorer dapp
License
bokkypoobah/GetStartedWithDevelopingInEthereum
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Materials prepared forETHSydney August - Get started with developing in Ethereum, Tuesday Aug 13 2024.
If you like this, please share it.
Have the capabilities to launch your ownsh*tcoin within minutes!
You can do this on Ethereum mainnet for the cost of ~600k gas or ~USD 3, at time of writing. As well as most "EVM" (Ethereum Virtual Machine)compatible chains like Arbitrum, Base or Optimism.
Demystify ERC-20s
An ERC-20 token contract is a little bit like a database table with two columns - owner and balance. And with stored procedures to implement transfer rules.
balances: section in the ERC-20 browser.
With events logs recording the transfers
events: section in the ERC-20 browser.
Token amounts are stored as raw numbers with a specified number of
decimals,18in this case.
- Deploy your own ERC-20 token contract -contracts/ERC20Token.sol (Sepolia0x1e5D...4D59) orcontracts/FixedSupplyToken.sol (Sepolia0x8fAF...d093).
- Interact with your own ERC-20 token contract
- Deploy a simple vault that operates with your ERC-20 token contract -contracts/SimpleVault.sol
- Interact with your simple vault
On completion of Exercises 1 & 2, you will have deployed and interacted with your first ERC-20 token contract on the Ethereum Sepolia testnet
I built a simple tool to inspect and interact with ERC-20 token contracts. The main source code file isdocs/index.html. View the developer pane when running this tool to see the simple interactions required between your web browser and the blockchain.
This tool can also be run locally by executing e.g.anywhere in thedocs/ folder of this GitHub repository downloaded onto your local machine
- Web browser, with the MetaMaskhttps://metamask.io/, or Rabbyhttps://rabby.io/ browser plug-in
- Sepolia testnet ethers in your MetaMask account. Tryhttps://www.alchemy.com/faucets,https://www.infura.io/faucet/sepolia,https://sepolia-faucet.pk910.de/ orhttps://cloud.google.com/application/web3/faucet/ethereum/sepolia
- For developing and testing on your local computer, familiarity with the Linux, MacOS or Windows command line. Andnpx to run commands from Node packages.
- Contents and UI for ERC-721 and ERC-1155
- Overview
- Exercise 1 - Deploy Your Own ERC-20 Token Contract
- Exercise 2 - Interact With Your ERC-20 Token Contract
Go tohttps://remix.ethereum.org/. In theFILE EXPLORER tab, create a newERC20Token.sol document underdefault_workspace ->contracts. Copy the content fromcontracts/ERC20Token.sol or , orcontracts/FixedSupplyToken.sol and paste into your newly createdERC20Token.sol document.
Change the_name and_symbol on lines 80 and 81. Save and you should have a green tick below the third icon on the sidebar.
Switch to theSOLIDITY COMPILER tab. Note theCOMPILER version,0.8.26+commit.8a87fa7a in this case. Check thatEnable optimisation is ticked and the number beside it set to200.
Switch to theDEPLOY & RUN TRANSACTIONS tab. SetENVIRONMENT toInjected Provider - MetaMask and your MetaMask account should appear under theACCOUNT label.
SelectCONTRACT to beERC20Token - contracts/ERC20Token.sol.
Click [Deploy], and [Confirm] your transaction in MetaMask.
In the bottom pane, you will see your completed transaction and newly createdcontract address.0xac09587d186d70d93dd9b16328c2e4fa845cc9cf in my case.
The contract can be viewed athttps://sepolia.etherscan.io/address/0xac09587d186d70d93dd9b16328c2e4fa845cc9cf, in my case.
Switch to theContract tab.
Click on [Verify and Publish] to upload the source code for your ERC-20 token contract. Select theCompiler Type ofSolidity(Single file). Select theCompiler Version to compiler version you compiled your contract with,0.8.26+commit.8a87fa7a currently. Select theOpen Source License Type of3) MIT License (MIT). Click [Continue].
Paste the contents of ERC20Token.sol from Remix into the text box underEnter the Solidity Contract Code below.
SetOptimization toYes andRuns to200, matching the same parameters in Remix above.
Click [Verify and Publish].
CONGRATULATIONS You have published your ?first contract!
The newly deployed contract code can be viewed athttps://sepolia.etherscan.io/address/0xac09587d186d70d93dd9b16328c2e4fa845cc9cf#code, in my case.
The ERC-20 token transactions can be viewed athttps://sepolia.etherscan.io/token/0xac09587d186d70d93dd9b16328c2e4fa845cc9cf, in my case. You can see1,000,000 tokens being minted from address0x0000...0000 to deploying address.
Click on the [Holders] tab to view the account holdings.
View your ERC-20 token contract onhttps://bokkypoobah.github.io/GetStartedWithDevelopingInEthereum/.
Using my newly deployed ERC-20 token contract0xAC09587d186D70d93dd9B16328C2E4fA845cC9CF, you can see the initially minted1,000,000TOOSEXY tokens transferred to my account when my ERC-20 token contract was deployed.
If required, create your second MetaMask account and transfers some Sepolia testnet ethers to it.
In thetransfer: block, setto: to your second MetaMask account, andtokens: to10. Click [Transfer], then confirm the transaction in MetaMask.
After MetaMask sends your transaction, you should see yourtxHash:. Click on the link toView in explorer if you want to view your transaction.
Click [Retrieve], and you can see the new transaction of10 tokens, and 3 rows in thebalances: table.
Execute a second transfer of1 token to your second account.
Click [Retrieve] at the top of the page, and you can see the new transaction of1 token, andbalances: table updated appropriately.
In theapprove: block, setspender: to your second MetaMask account, andtokens: to100. Click [Approve], then confirm the transaction in MetaMask.
After MetaMask sends your transaction, you should see yourtxHash:. Click on the link toView in explorer if you want to view your transaction.
Click [Retrieve] at the top of the page, and you can see the newApproval transaction of100 token, andallowances: table updated appropriately.
In theallowance: block, you can check the allowance just set.
Switch to your second account in MetaMask.
In thetransferFrom: block, setfrom: to be your first account, andtokens: to be0.12345. Click [Transfer From], then confirm the transaction in MetaMask.
Click [Retrieve] at the top of the page, and you can see the newTransfer transaction of0.12345 token, andbalances: table updated appropriately.
In theallowance: block, you can see that the allowance of100 that you set has now been reduced to99.87655, as account2 has used0.12345 of their allowance.
TODO
- Deploy and interact with a simple gadget that uses the ERC-20 basic building block
- Set up the Hardhat testing environment -https://hardhat.org/docs
- Modifycontracts/SimpleVault.sol to break the functionality and confirm with the tests
- Deploy your own SimpleVault to the Sepolia testnet
- Send and withdraw some of your very own ERC-20 tokens created in Exercise 1
npm install --save-dev hardhat# Run testnpx hardhattest# Or run test and save output in ./testIt.out./10_testIt.sh# 00_test_0# Deployment# Signers# * owner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266# * otherAccount: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8# Deploying ERC20# * symbol: MYSYMBOL# * name: My Name# * decimals: 18# * totalSupply: 1000000000000000000000000# Deploying SimpleVault# * owner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266# ✔ ERC20 token should have the correct symbol, name, decimals and totalSupply (548ms)# ✔ ERC20 token should emit an event on transfers and balanceOf adds up# ✔ SimpleVault should process token deposits and withdrawals correctly### 3 passing (581ms)
e.g., Bank balance, Opal card balance, transfers
e.g., Bank account number, Opal card number, drivers license, registry item
e.g., Game items
- Solidity compiler and deployer -https://remix.ethereum.org/
- Solidity Documentation -https://docs.soliditylang.org/
- OpenZeppelin Contracts -https://github.com/OpenZeppelin/openzeppelin-contracts
- Hardhat development environment -https://hardhat.org/
- mindmap/GetStartedWithDevelopingInEthereum-202408.mm that can be viewed inFreePlane
Enjoy!
(c) BokkyPooBah / Bok Consulting Pty Ltd 2024. The MIT Licence.
About
Getting Started In Ethereum, with an interactive ERC-20, ERC-721 and ERC-1155 token contract explorer dapp
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.

































