Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Crypto Lesson

Crypto Lesson

20d0ddc61e80bce04a63680da0160756?s=128

Aletheia

April 12, 2022
Tweet

More Decks by Aletheia

Other Decks in Programming

Transcript

  1. ERC20, ERC721 and NFTs 2022-04-12 Basic theoretical concepts and practical

    examples
  2. Who am I? Luca Bianchi, PhD CTO @ Neosperience CTO

    @ WizKey AWS Hero, passionate about serverless and machine learning github.com/aletheia https://it.linkedin.com/in/lucabianchipavia https://speakerdeck.com/aletheia www.ai4devs.io @bianchiluca
  3. ERC-20: fungible tokens

  4. What is an ERC-20 It’s a standard version of a

    smart contract • An ERC-20 token is a smart contract that has an established data structure. • ERC20 de f ines balanceOf , totalSupply , transfer , transferFrom , approve , and allowance and also name, symbol, and the number of decimals. • Any one token is exactly equal to any other token; no tokens have special rights or behavior associated with them. • ERC20 tokens are useful for things like a medium of exchange currency, voting rights, staking,
  5. What is an ERC-20 It’s a standard version of a

    smart contract • An ERC-20 token is a smart contract that has an established data structure. • ERC20 de f ines balanceOf , totalSupply , transfer , transferFrom , approve , and allowance and also name, symbol, and the number of decimals.
  6. ERC-721 and NFTs

  7. What is an ERC-721 A standard interface for non-fungible tokens,

    also known as deeds. • Used in situations like real estate, voting rights, or collectibles, where some items are valued more than others, due to their usefulness, rarity, etc. • ERC721 is a standard for representing ownership of non-fungible tokens, that is, where each token is unique. • ERC721 is a more complex standard than ERC20, with multiple optional extensions, and is split across a number of contracts. • https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
  8. What is an ERC-721 A standard interface for non-fungible tokens,

    also known as deeds. • An ERC-721 provides basic functionality to track and transfer NFTs. • NFTs can represent ownership over digital or physical assets
  9. Writing dApp “backend”

  10. How to create an ERC-20 Using Solidity language, a smart

    contract can be created (and deployed) in many ways https://tru ff lesuite.com/ https://remix.ethereum.org/
  11. What do we need to develop Smart Contracts? Aiming to

    write Smart Contracts for production use cases, we need more tools • Use your own IDE • Linting • Programmable deployment toolchain • Local blockchain for inspection • Testing support
  12. Introducting Hardhat Using Solidity language, a smart contract can be

    created (and deployed) in many ways https://hardhat.org/
  13. How to get started Hardhat is a NPM package, targeting

    JS developers npx hardhat init
  14. Anatomy of Hardhat toolchain

  15. How to deploy our smart contract npx hardhat init npx

    hardhat node npx hardhat run —network localhost scripts/sample-script.js npx hardhat run —network rinkeby scripts/sample-script.js # NOT CONFIGURED!!
  16. Smart Contract Templates

  17. None
  18. Contracts Wizard • https:// docs.openzeppelin.com/ contracts/4.x/wizard

  19. Writing dApp frontend

  20. Application Binary Interface A middle man to communicate with your

    contract • The Contract Application Binary Interface (ABI) is the standard way to interact with contracts in the Ethereum ecosystem, both from outside the blockchain and for contract-to-contract interaction. Data is encoded according to its type, as described in this speci f ication. • EVM (Ethereum Virtual Machine) is the core component of the Ethereum network, and smart contract is pieces of code stored on the Ethereum blockchain which are executed on EVM. Smart contracts written in high-level languages like Solidity or Vyper need to be compiled in EVM executable bytecode. • Languages that compile for the EVM maintain strict conventions about these conversions, but in order to perform them, one must know the precise names and types associated with the operations. • The ABI documents these names and types precisely, easily parseable format, doing translations between human-intended method calls and smart-contract operations discoverable and reliable. • ABI de f ines the methods and structures used to interact with the binary contract, just like API does but on a lower-level.
  21. Work f low Metamask APIs • Metamask o ff ers

    standard layer of APIs to connect to a wallet • private keys are never shared, but transactions are routed through the wallet • metamask injects a window.ethereum variable • we need a frontend library to handle Metamask and Smart Contract APIs
  22. A client library to handle Smart Contracts

  23. ether.js Provider, Signer and connector

  24. ether.js Work f low • ethers returns a provider •

    can use speci f ic providers (i.e. Alchemy or a standard Web3 provider) • returns a signer to sign transactions • returns a contract interface to call contract functions
  25. A real-life example

  26. CryptoAltMuseum a dApp to mint Retro tokens

  27. NFT real use cases

  28. WizKey DeFiNe A NFT platform to handle receivables on the

    blockchain • Upload the documentation, 
 De f ine your portfolio and sell it in a global market. • Improved portfolio management • Improved negotiation and transfer of credits • Access to a global market • Guaranteed security on transactions • High level of con f identiality www.wizkey.io/en
  29. one more thing…

  30. Pinata Your dropbox to IPFS

  31. Foundry A blazing fast, portable and modular toolkit for Ethereum

    application development • it is not developer friendly, but powerful • Forge: Ethereum testing framework (like Tru ff le, Hardhat and Dapptools). • Blockchain Forking • Write Tests in Solidity • Support for Fuzz testing • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. https://github.com/gakonst/foundry https://book.getfoundry.sh/
  32. DappTools A suite of Ethereum focused CLI tools following the

    Unix design philosophy • it is not developer friendly, but powerful • dapp - All you need Ethereum development tool. Build, test, fuzz, formally verify, debug & deploy solidity contracts. • seth - Ethereum CLI. Query contracts, send transactions, follow logs, slice & dice data. • hevm - Testing oriented EVM implementation. Debug, fuzz, or symbolically execute code against local or mainnet state. • ethsign - Sign Ethereum transactions from a local keystore or hardware wallet. https://github.com/dapphub/dapptools http://dapp.tools
  33. thank you.