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

EOSでスマートコントラクトを実行してみる

 EOSでスマートコントラクトを実行してみる

EOSでスマートコントラクトを実行してみる
http://diary.shuichi.tech/entry/2018/03/31/000555

91d36c66b64ce58f3e749d9d921aae69?s=128

Shuichi Nagao

April 04, 2018
Tweet

Transcript

  1. EOSͰεϚʔτίϯτϥΫτΛ ࣮ߦͯ͠ΈΔ @ngo275 2018/4/4 1

  2. ࣗݾ঺հ •ӬඌमҰ ( @ngo275 ) •ձࣾɿAnyPay •Swift / JavaScript (React

    Native) / Ruby •͋ͱ͸Solidity΍React΋ॻ͍ͨΓ 2
  3. Requirements for Dapps •Support Millions of Users •Free Usage •Easy

    Upgrades and Bug Recovery •Low Latency •Sequential Performance •Parallel Performance Dan Larimer https://github.com/EOSIO/Documentation/blob/master/TechnicalWhitePaper.md 3
  4. EOSͱ͸ •εϚʔτίϯτϥΫτΛ࣮ߦ͢ΔϓϥοτϑΥʔ Ϝͱͯ͠ͷϒϩοΫνΣʔϯ •dPoS (delegated Proof of Stake) + aBFT

    •1ඵҎ಺ʹෆՄٯੑΛอূͰ͖Δ •TaPoS (Transaction as Proof of Stake) •τϥϯβΫγϣϯͷվ͟ΜΛ๷͙ •WebAssemblyͰίϯύΠϧͨ͠΋ͷΛಈ͔͢ •C / C++ / RustͰίϯτϥΫτΛ࣮૷͢Δ 4
  5. EOSͷΠϯετʔϧ •masterͷಈ࡞͸อূ͠ͳ͍Αɺͱͷ͜ͱ •Ͱ΋ͱΓ͋͑ͣ΍ͬͯΈΔ •(4/3ʹ͜ͷwarning͕ফ͑ͯͨ) 5

  6. EOSͷΠϯετʔϧ $ git clone https://github.com/EOSIO/eos.git --recursive $ cd eos $

    ./eosio_build.sh $ sudo make install <= ෆཁ͔΋ •eosio-abigen •eosio-applesedemo •eosio-launcher •eosio-s2wasm •eosiocpp •eosiowd •nodeos ͱ͔͕࢖͑ΔΑ͏ʹͳΔ 6
  7. EOSΛಈ͔ͯ͠ΈΔ # ઃఆϑΝΠϧΛฤू (ฤू಺༰͸লུ) $ vim /path/to/eos/config.ini # EOSͷlocal testnetͷσʔϞϯΛىಈ

    $ nodeos --config-dir /path/to/eos/ $ cleos wallet create $ cleos wallet list Wallets:["default *"] $ cleos create key Private key: 5K1daHdwBkN6LoCv8SmQipn9tu439k2U2txTWc7xLFmKUCo7TYb Public key: EOS5reEGNsCNcG6JSFRPtRnaP62KX8BjYRy5CHJki9MQ9yMqGitgh σʔϞϯΛىಈ͢Δ walletɾkeyΛ࡞੒ͯ͠ΈΔ 7
  8. EOSΛಈ͔ͯ͠ΈΔ $ cleos wallet import 5K1daHdwBkN6LoCv8SmQipn9tu439k2U2txTWc7xLFmK UCo7TYb imported private key

    for: EOS5reEGNsCNcG6JSFRPtRnaP62KX8BjYRy5CHJk i9MQ9yMqGitgh $ cleos create account eosio helloworld EOS5reEGNsCNcG6JSFRPtRnaP6 2KX8BjYRy5CHJki9MQ9yMqGitgh EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8Bh tHuGYqET5GDW5CV walletʹઌ΄Ͳ࡞੒ͨ͠keyΛೖΕΔ ίϯτϥΫτ༻ʹaccount (helloworld) Λ࡞੒͢Δ 8 $ cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP7 9zkvFD3 imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtH uGYqET5GDW5CV walletʹ͢Ͱʹଘࡏ͢Δaccount (eosio) ͱඥ෇͍ͨkeyΛೖΕΔ
  9. EOSΛಈ͔ͯ͠ΈΔ $ eosiocpp -n helloworld $ cd helloworld $ ls

    helloworld.abi helloworld.cpp helloworld.hpp $ eosiocpp -o helloworld.wast helloworld.cpp $ ls helloworld.abi helloworld.cpp helloworld.hpp helloworld.wast ίϯτϥΫτͷ਽ܗΛ࡞Δ 9
  10. EOSΛಈ͔ͯ͠ΈΔ # σϓϩΠ͢Δ $ cleos set contract helloworld /path/to/helloworld/ helloworld.wast

    /path/to/helloworld/helloworld.abi # ࣮ߦ͢Δ $ cleos push action helloworld transfer '{"from":"currency","to":" eosio","amount":"1"}' --permission helloworld@active σϓϩΠɾ࣮ߦͯ͠ΈΔ 10
  11. ·ͱΊ •master͕ಈ͔ͳ͔ͬͨΓυΩϡϝϯτ௨Γʹಈ ͔ͳ͔ͬͨΓਏ͍͜ͱ͕ଟ͍ •Ethereumͷࢿྉ͸૿͖͑ͯͯDappsͷ։ൃ΋੝ Μʹͳ͖͕ͬͯͨଞͷϒϩοΫνΣʔϯΛݟΔ ͱྑ͍ͱ͜Ζ΋ѱ͍ͱ͜Ζ΋ݟ͑ͯࢀߟʹͳΔ •7݄ʹϝΠϯωοτ͕ϦϦʔε͞ΕΔͦ͏ͳͷͰ ஫໨͓ͯ͘͠ͱྑͦ͞͏ ϒϩάʹ·ͱΊ͓͖ͯ·ͨ͠ http://diary.shuichi.tech/entry/2018/03/31/000555

    11 @ngo275