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

ブロックチェーン概論とインストール大会 / Blockchain Overview and I...

ブロックチェーン概論とインストール大会 / Blockchain Overview and Installation

慶應義塾大学大学院メディアデザイン研究科「サービスデザインプロジェクトB」2024秋 第2回にて使用したスライドです。

Kenji Saito

October 12, 2024
Tweet

More Decks by Kenji Saito

Other Decks in Technology

Transcript

  1. Generated by Stable Diffusion XL v1.0 B 2024 2 (

    ) B 2024 — 2 — 2024-10-14 – p.1/62
  2. ( ) 1 10 7 • 2 10 14 •

    3 10 21 4 11 28 5 11 4 1 6 11 11 2 7 11 18 8 11 25 ( ) Discord B 2024 — 2 — 2024-10-14 – p.3/62
  3. ެ։୆ா ެ։Ͱͳ͚Ε͹ͳΒͳ͍ ʜ ຊਓ ɾૹۚه࿥ ɾίʔυ ɾσʔλͷมԽ ɾ࣮ߦϩά ݕӾͰ͖Δୈࡾऀ ͜Εɺ

    ه࿥͍ͨ͠Μ͚ͩͲ ͋ͳͨ͸ ॻ͍ͨΒμϝ ͜ͷ಺༰͸ ॻ͍ͨΒμϝ ॻ͍ͪΌͬͨͷʁ ͜͏ॻ͖׵͑·͠ΐ͏ ॻ͍ͯͳ͍ͷʁ ͜͏ॻ͔Εͨ͜ͱʹ ͠·͠ΐ͏ ॻ͍ͪΌͬͨͷʁ ফ͠·͠ΐ͏ %P4 ߈ܸͱ͔Ͱ ๦֐ͯ͠ࢭΊ·͠ΐ͏ B 2024 — 2 — 2024-10-14 – p.6/62
  4. Bitcoin . . . : (i.e. ) ( ) :

    : : ⇒ ( ) ← B 2024 — 2 — 2024-10-14 – p.7/62
  5. ৽ن ϒϩοΫ ܈ ௥Ճ ίετϨδελʔ෇͖ ୆ா ਖ਼౷ͳཤྺ ఏҊ͞ΕΔ৽͍͠ཤྺ ίετ େ

    ੎ ͕ ࢀ Ճ ݁Ռ B มߋແ͠ C ௥ه D ॻ͖׵͑ ɾ৽͍͠ཤྺ͕͜Ε·Ͱͷཤྺʹ஝ੵ͞Εͨ ɹίετΛ૿େͤ͞ΔΑ͏ͳ΋ͷͰͳ͍ͷ ɹͳΒ͹มߋ͸ੜ͡ͳ͍ɻ ɾίετ͸݁ՌతʹɺωΠςΟϒ҉߸ࢿ࢈ ݐͯͰଌΒΕΔɻ ɾ୆ாͷҡ࣋ʹࢀՃ͢Ε͹ɺ֬཰తʹେ͖ͳ ใुΛωΠςΟϒ҉߸ࢿ࢈ͰಘΒΕΔɻ ɾใुΛಘΔͨΊʹ͸ίετෛ୲ͰϚδϣϦςΟ ଆʹ͍ͳ͚Ε͹ͳΒͳ͍ɻ B 2024 — 2 — 2024-10-14 – p.8/62
  6. 4 ( ) ( ) ( ; ) ( )

    B 2024 — 2 — 2024-10-14 – p.9/62
  7. ( ) ೖྗ σδλϧͳΒԿͰ΋Α͍σʔλͷू߹ ແݶ ग़ྗ CJU ͳͲݻఆ௕ͷ਺ͷू߹ ༗ݶ ग़ྗ஋͸ʮμΠδΣετʯͱ΋ݺ͹ΕΔ

    খ ͞ ͍ ॱ ʹ ฒ Μ Ͱ ͍ Δ ͱ ͠ ͯ খ ͞ ͍ ॱ ʹ ฒ Μ Ͱ ͍ Δ ͱ ͠ ͯ 4)"ͳͲͷؔ਺ 4)"4FDVSF)BTI"MHPSJUIN Ұ༷ʹ෼෍ ϋογϡؔ਺ͷੑ࣭ ภͬͯ෼෍ Ϛοϐϯάʹ๏ଇੑ͕ແ͍Α͏ʹݟ͑ɺ ˠͷํ޲ʹ͸҆ՁʹܭࢉͰ͖Δ͕ɺ ٯͷํ޲ʹ͸ܭࢉͰ͖ͳ͍ Ұํ޲ੑ ҉߸ֶతϋογϡؔ਺ͷੑ࣭ ແݶΛ༗ݶʹϚοϐϯά͢ΔͷͰɺҟͳΔೖྗ͕ ಉ͡ग़ྗ݁ՌʹͳΔ৔߹΋͘͝رʹ͋Δ িಥ িಥ ͤ͞Δํ๏ ͕ݟ͔ͭͬͨ҉߸ֶతϋογϡ ؔ਺͸΋͸΍҆શͱ͸ݟͳ͞Εͳ͍ B 2024 — 2 — 2024-10-14 – p.10/62
  8. ( ) ൿີ伴 伴ϖΞ ͋Β͔͡Ί ੜ੒ ൿີʹӅ࣋ͭ͠ ͋Β͔͡Ί౉͓͍ͯͯ͠΋Α͍ ॺ໊Λ࡞ͬͨͷ͸ެ։伴ʹ ରԠ͢Δൿີ伴Λ࢖͑Δ୭

    ͔ ͢ͳΘͪॺ໊ऀ ͩ͠ɺ ݩͷσʔλ͸ॺ໊ޙ͸CJU ΋มΘͬ ͍ͯͳ͍ ͜ͷ࢓૊Έ͕ਖ਼͘͠ಈ࡞͢ΔͨΊʹ͸ɺ ड͚औͬͨެ։伴͕ຊ౰ʹॺ໊ऀͷ΋ͷ Ͱ͋Δͱ͍͏ԿΒ͔ͷূ໌͕ඞཁ ʲॺ໊ΞϧΰϦζϜʳ ೖྗݩͷσʔλɺ ൿີ伴 ग़ྗॺ໊ ʲॺ໊ݕূΞϧΰϦζϜʳ ೖྗݩͷσʔλɺ ॺ໊ɺ ެ։伴 ग़ྗ0,·ͨ͸/( ެ։伴 ॺ໊ऀ ॺ໊ ΞϧΰϦζϜ ॺ໊ݕূ ΞϧΰϦζϜ 0, ·ͨ͸ /( Πϯλʔωοτ ݕূऀ ެ ެ։ ։伴 伴 ެ։ ެ։伴 ެ ެ։ ։伴 伴 ݩͷ σʔλ ݩͷ σʔλ ॺ໊ ॺ໊ B 2024 — 2 — 2024-10-14 – p.11/62
  9. ϒϩοΫ O ࣌ؒ ϒϩοΫϔομʔ ͍ΖΜͳ৘ใ͕ೖ͍ͬͯΔ ϒϩοΫ O ͷ μΠδΣετ औҾ

    σʔλ ެ։伴 ˍॺ໊ औҾ σʔλ ެ։伴 ˍॺ໊ औҾ σʔλ ެ։伴 ˍॺ໊ ʜʜ ϒϩοΫ O  ϒϩοΫϔομʔ ͍ΖΜͳ৘ใ͕ೖ͍ͬͯΔ ϒϩοΫ O ͷ μΠδΣετ औҾ σʔλ ެ։伴 ˍॺ໊ औҾ σʔλ ެ։伴 ˍॺ໊ औҾ σʔλ ެ։伴 ˍॺ໊ ʜʜ ϒϩοΫͷμΠδΣετ͸ ͦͷϒϩοΫΛҰҙʹࣔ͢ ࣝผࢠͱͯ͠΋༻͍ΒΕΔ औҾσʔλͷ࡟আ౳ͰϒϩοΫͷ ಺༰͕มΘΕ͹ɺͦͷμΠδΣετ ΋มΘΔͷͰɺໃ६͕ੜ͡Δ औҾσʔλʹ͸ૹ৴ऀͷσδλϧ ॺ໊͕෇͍͍ͯΔͷͰվ͟Μ͸ ࠔ೉͕ͩɺऔҾσʔλΛؙ͝ͱ ࡟আ͢Δ͜ͱ͸Ͱ͖Δ ࣍ͷϒϩοΫʹμΠδΣετ͕ ֨ೲ͞Ε͍ͯΔ͜ͱͰɺखલͷ ϒϩοΫͷ಺༰͸ϩοΫ͞Εͯ ͍Δͱ΋ݴ͑Δ͕ʜ ܨ͕͍ͬͯΔϒϩοΫͷϔομʔ ͷதͷμΠδΣετΛ࣍ʑͱॻ͖ ׵͍͚͑ͯ͹ໃ६ͳ͘վ͟ΜͰ͖ ΔͷͰɺϒϩοΫΛ࡞Δ͜ͱࣗମ ʹେ͖ͳίετΛඞཁʹͯ͠कΔ Proof of Work ( ) : ( ) Proof of Stake ( ) : B 2024 — 2 — 2024-10-14 – p.12/62
  10. ( : ) ( : ) ← NFT 4 ⇒

    B 2024 — 2 — 2024-10-14 – p.13/62
  11. (Confidentiality) 4 ( 4 ) ↑ ( = ) (Integrity)

    (Availability) B 2024 — 2 — 2024-10-14 – p.14/62
  12. 2009 ↑ 15 ( 5 ) B 2024 — 2

    — 2024-10-14 – p.15/62
  13. ( ) ( ) ( ) B 2024 — 2

    — 2024-10-14 – p.17/62
  14. ( ) ( ) ( ) B 2024 — 2

    — 2024-10-14 – p.19/62
  15. / ( ) ( ) ( ) ( ) B

    2024 — 2 — 2024-10-14 – p.21/62
  16. ( ) ( ) ( ) B 2024 — 2

    — 2024-10-14 – p.22/62
  17. ( ) ( ) ( ) : https://doi.org/10.1016/j.icte.2021.08.012 ( )

    ( ) ( ) : https://ieeexplore.ieee.org/document/9686409 B 2024 — 2 — 2024-10-14 – p.29/62
  18. ( ) ( ) : https://ieeexplore.ieee.org/document/9686409 3D ( ) :

    HACCP ( ) B 2024 — 2 — 2024-10-14 – p.30/62
  19. — τʔΫϯ ୅ସ՟ฎ εϚʔτίϯτϥΫτ ݕূՄೳͳঢ়ଶϚγϯ ϓϩϏφϯε དྷྺূ໌  ୅ସՄೳ ঈؐෆೳ

    ୅ସՄೳ ঈؐՄೳ ୅ସෆೳ ঈؐՄೳ ୅ସෆೳ ঈؐෆೳ ূ໌͢Δ ಉఆ͢Δ ࢧ෷͍౳ ࠷ॳͷԠ༻ *%Χʔυ౳ ηΩϡϦςΟ τʔΫϯ ূ݊ ౳ ηϯαʔ౳ ෺ྲྀɾ Ҩݴॻ౳ อݥਃ੥౳ ௥੻͢Δ ײ஌͢Δ தԝۜߦ σδλϧ௨՟౳ ҭ੒ήʔϜ౳ ൿີ伴Λ࢖͑Δ͔Βຊਓʁ ෛ࠴  Ξηοτͷ ਺஋දݱΛҠసͰ͖Δʁ ొ࿥͞Εͨίʔυͱ ͦͷ࣮ߦϩάͱ݁Ռͷ ਅਖ਼ੑΛ୲อͰ͖Δʁ ݖҖ͕  Կ͔ͷ಺༰Λূ໌͢Δʁ ࣋ଓ͢Δଘࡏʹ͍ͭͯ ه࿥ΛΞοϓσʔτՄʁ ओମ͕͍ͳ͘ͳͬͯ΋ աڈͷσʔλ͸༗ޮʁ /'5 Ұൠతͳ ೝࣝ ػೳͷ ෼ੳ݁Ռ B 2024 — 2 — 2024-10-14 – p.31/62
  20. 2. Ethereum macOS (Sonoma 14.7) + Homebrew Linux (Ubuntu 24.04)

    (x86/AMD64 and ARM) Windows 11 + Windows Subsystem for Linux (Ubuntu ) Ethereum solidity brownie Lima on macOS B 2024 — 2 — 2024-10-14 – p.32/62
  21. macOS : Homebrew (Apple macOS ) UNIX macOS Lima Homebrew

    brew Apple brew ( ) brew Rosetta brew brew https://github.com/homebrew/install Path : https://zenn.dev/tet0h/articles/a92651d52bd82460aefb $ which brew /opt/homebrew/bin/brew B 2024 — 2 — 2024-10-14 – p.33/62
  22. macOS : Rosetta 2 Apple x86/AMD64 ( ) $ softwareupdate

    --install-rosetta lima Rosetta 2 lima B 2024 — 2 — 2024-10-14 – p.34/62
  23. macOS : Lima macOS Linux ( ) https://github.com/lima-vm/lima QEMU (

    ) Rosetta 2 Apple x86/AMD64 brew $ brew install lima Ubuntu 24.04 (x86/AMD64) “kmd.yaml” ( “kmd.yaml” ) $ limactl start kmd.yaml B 2024 — 2 — 2024-10-14 – p.35/62
  24. macOS : Lima Linux (Ubuntu) x86_64 $ limactl list Linux

    (exit ) $ limactl shell kmd Linux limactl list STATUS Stopped limactl start kmd “.lima” diffdisk 100GB B 2024 — 2 — 2024-10-14 – p.36/62
  25. Solidity Ethereum ( ) http://solidity.readthedocs.io/en/latest/installing-solidity.html Linux (on Windows) “sudo apt”,

    macOS “brew” Linux ARM git clone dependencies solc 0.8.27 (10/5 ) $ solc --version brownie py-solc-x solc (dependencies) ( solc py-solc-x ) B 2024 — 2 — 2024-10-14 – p.37/62
  26. Python3 macOS $ brew install python3 Python 3.8 Homebrew $

    brew uninstall --ignore-dependencies [email protected] $ brew install [email protected] /usr/local/opt/[email protected]/bin/python3 Linux ( python3.12.3 OK) $ sudo apt update $ sudo apt install python3-dev python3-venv python3-tk 16.10 python3(.8) apt (PPA ) python3 python3-dev python3-venv python3-tk B 2024 — 2 — 2024-10-14 – p.39/62
  27. macOS : . . . macOS wget brew dyld: Library

    not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib $ brew uninstall --force gettext $ brew install gettext B 2024 — 2 — 2024-10-14 – p.40/62
  28. Python (venv) macOS (Linux python3 ) OK Python $ python3

    -m venv bbc2env $ source bbc2env/bin/activate (bbc2env) $ pip install -U pip bbc2env ( BBc-2 ) ( ) (bbc2env) $ deactivate B 2024 — 2 — 2024-10-14 – p.41/62
  29. $ brownie init ( ERC-20 ) $ brownie bake token

    $ cd token B 2024 — 2 — 2024-10-14 – p.43/62
  30. contracts (macOS Linux (x86/AMD64) ) $ brownie compile Linux (ARM)

    (AMD64 ) $ python # >>> import solcx >>> solcx.compile_solc(’0.6.12’) # >>> quit() /tmp ∼/.solcx/solc-v0.6.12 ( ) $ pytest tests B 2024 — 2 — 2024-10-14 – p.44/62
  31. Brownie $ brownie console Python >>> len(accounts) 10 >>> accounts[0].balance()

    100000000000000000000 >>> quit() B 2024 — 2 — 2024-10-14 – p.45/62
  32. infura.io Brownie https://infura.io SIGN UP PROJECT ID infura Ethereum API

    infura . . . infura.io PROJECT ID WEB3_INFURA_PROJECT_ID PROJECT ID (∼/.bash_profile ) $ export WEB3_INFURA_PROJECT_ID= PROJECT ID B 2024 — 2 — 2024-10-14 – p.47/62
  33. Sepolia ETH brownie console Sepolia >>> network.disconnect() >>> network.connect(’sepolia’) >>>

    len(accounts) 0 >>> accounts.add() <LocalAccount object ’ 16 ’> >>> accounts[0].private_key 16 >>> quit() Sepolia Testnet ETH Faucet ETH https://sepoliafaucet.com ( ) ( ) Sepolia ETH 0.001 ETH 0.05 Sepolia ETH B 2024 — 2 — 2024-10-14 – p.48/62
  34. Sepolia ETH brownie console Sepolia ETH >>> network.disconnect() >>> network.connect(’sepolia’)

    >>> len(accounts) 0 >>> accounts.add( 16 ) <LocalAccount object ’ 16 ’> >>> accounts[0].balace() ETH >>> quit() ETH >>> accounts[0].transfer(accounts[1], "0.01 ether") B 2024 — 2 — 2024-10-14 – p.49/62
  35. Ethereum Vitalik Buterin, “Ethereum White Paper: A NEXT GENERATION SMART

    CONTRACT & DECENTRALIZED APPLICATION PLATFORM” 12 (= ) = ⇒ → Dapps ( / / ) B 2024 — 2 — 2024-10-14 – p.51/62
  36. Ether Ethereum EOA : Externally-Owned Account ( ) Ether EVM

    EVM B 2024 — 2 — 2024-10-14 – p.56/62
  37. EVM : Ethereum Virtual Machine ঢ়ଶ ֎෦ΞΫλʔ ΞΧ΢ϯτ &7. ίʔυ

    &UIFSˠ(BT ىಈ ίϯτϥΫτ ϝοηʔδ͔ɺ৽͍ࣗ͠ಈΦϒδΣΫτ ΞΧ΢ϯτؒͰ΍ΓऔΓ͞ΕΔσʔλ΍&UIFS ετϨʔδ ঢ়ଶ` τϥϯβΫγϣϯ ηοτ σδλϧॺ໊ &7. ਓؒͱ͔ ࣗಈ ΦϒδΣΫτ Gas ( EVM = ( burn)) . . . B 2024 — 2 — 2024-10-14 – p.57/62
  38. EVM : : ← : Solidity — JavaScript LLL —

    Lisp Vyper — Python Fe — Vyper Rust ← NEW! Solidity Vyper Python B 2024 — 2 — 2024-10-14 – p.58/62
  39. Solidity ( ) pragma solidityˆ0.7.0; contract IndivisibleAsset { /* */

    string public _name; string public _symbol; uint256 public _quantity; address public _owner; constructor(string memory name, string memory symbol, uint256 quantity) public { _name = name; _symbol = symbol; _quantity = quantity; _owner = msg.sender; } function transfer(address to) public returns (bool) { require (_owner == msg.sender); _owner = to; return true; } } B 2024 — 2 — 2024-10-14 – p.59/62
  40. ( , ) (constructor) (deploy) = ( ) ( )

    ETH Trusted Actor Model B 2024 — 2 — 2024-10-14 – p.60/62