Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Getting Started In Ethereum, with an interactive ERC-20, ERC-721 and ERC-1155 token contract explorer dapp

License

NotificationsYou must be signed in to change notification settings

bokkypoobah/GetStartedWithDevelopingInEthereum

Repository files navigation

Materials prepared forETHSydney August - Get started with developing in Ethereum, Tuesday Aug 13 2024.

If you like this, please share it.

Aim
  • 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 ofdecimals,18 in this case.

Steps
Outcome

On completion of Exercises 1 & 2, you will have deployed and interacted with your first ERC-20 token contract on the Ethereum Sepolia testnet

ERC-20 Token Browser

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

Requirements
TODO
  • Contents and UI for ERC-721 and ERC-1155


Table Of Contents



Overview



Exercise 1 - Deploy Your Own 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.



Exercise 2 - Interact With Your ERC-20 Token Contract

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.



Exercise 3 - SimpleVault Gadget for ERC-20s

TODO

Aim
  • Deploy and interact with a simple gadget that uses the ERC-20 basic building block
Steps
  1. Set up the Hardhat testing environment -https://hardhat.org/docs
  2. Modifycontracts/SimpleVault.sol to break the functionality and confirm with the tests
  3. Deploy your own SimpleVault to the Sepolia testnet
  4. Send and withdraw some of your very own ERC-20 tokens created in Exercise 1

Exercise 1 - Step 1 - Hardhat Testing Environment

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)


Building Blocks - Tokens

ERC-20 Fungible Tokens - "Coins"

e.g., Bank balance, Opal card balance, transfers

ERC-721 Non-Fungible Tokens - "Pictures"

e.g., Bank account number, Opal card number, drivers license, registry item

ERC-1155 Non-Fungible Tokens - "Coins & Pictures"

e.g., Game items



Resources

Solidity

Other



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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp