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

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

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

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

Shuichi Nagao

April 04, 2018
Tweet

More Decks by Shuichi Nagao

Other Decks in Programming

Transcript

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

    Native) / Ruby •͋ͱ͸Solidity΍React΋ॻ͍ͨΓ 2
  2. 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
  3. EOSͱ͸ •εϚʔτίϯτϥΫτΛ࣮ߦ͢ΔϓϥοτϑΥʔ Ϝͱͯ͠ͷϒϩοΫνΣʔϯ •dPoS (delegated Proof of Stake) + aBFT

    •1ඵҎ಺ʹෆՄٯੑΛอূͰ͖Δ •TaPoS (Transaction as Proof of Stake) •τϥϯβΫγϣϯͷվ͟ΜΛ๷͙ •WebAssemblyͰίϯύΠϧͨ͠΋ͷΛಈ͔͢ •C / C++ / RustͰίϯτϥΫτΛ࣮૷͢Δ 4
  4. 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
  5. 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
  6. 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ΛೖΕΔ
  7. 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
  8. 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