Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

ERC-20: fungible tokens

Slide 4

Slide 4 text

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,

Slide 5

Slide 5 text

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.

Slide 6

Slide 6 text

ERC-721 and NFTs

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Writing dApp “backend”

Slide 10

Slide 10 text

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/

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Introducting Hardhat Using Solidity language, a smart contract can be created (and deployed) in many ways https://hardhat.org/

Slide 13

Slide 13 text

How to get started Hardhat is a NPM package, targeting JS developers npx hardhat init

Slide 14

Slide 14 text

Anatomy of Hardhat toolchain

Slide 15

Slide 15 text

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!!

Slide 16

Slide 16 text

Smart Contract Templates

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Writing dApp frontend

Slide 20

Slide 20 text

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.

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

A client library to handle Smart Contracts

Slide 23

Slide 23 text

ether.js Provider, Signer and connector

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

A real-life example

Slide 26

Slide 26 text

CryptoAltMuseum a dApp to mint Retro tokens

Slide 27

Slide 27 text

NFT real use cases

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

one more thing…

Slide 30

Slide 30 text

Pinata Your dropbox to IPFS

Slide 31

Slide 31 text

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/

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

thank you.