Slide 1

Slide 1 text

Copyright ©2018 chaintope, Inc. all rights reserved. hicon2018 Truffleの紹介 2018/11/10 chaintope, Inc Yukishige Nakajo

Slide 2

Slide 2 text

Copyright ©2018 chaintope, Inc. all rights reserved. 自己紹介 ● Yukishige Nakajo ● 株式会社chaintope Chief Ethereum Researcher ● 福岡県の飯塚市でEthereumの研究中 ● 最近はBitcoinもやってます ● truffle-hdwallet-providerのcontributerです! https://twitter.com/nakajo https://y-nakajo.hatenablog.com/

Slide 3

Slide 3 text

Copyright ©2018 chaintope, Inc. all rights reserved. Truffleの紹介 1. Truffleの概要 2. migation 3. ganache 4. mocha 5. その他の機能 今日話すこと

Slide 4

Slide 4 text

Copyright ©2018 chaintope, Inc. all rights reserved. Truffleの紹介 1. Truffleの概要 2. migation 3. ganache 4. mocha 5. その他の機能 今日話すこと

Slide 5

Slide 5 text

Copyright ©2018 chaintope, Inc. all rights reserved. 出典元:https://truffleframework.com/truffle Truffle is the most popular development framework for Ethereum 1. Truffleの概要

Slide 6

Slide 6 text

Copyright ©2018 chaintope, Inc. all rights reserved. 1. Truffleの概要

Slide 7

Slide 7 text

Copyright ©2018 chaintope, Inc. all rights reserved. Deploy Tool 1. Truffleの概要

Slide 8

Slide 8 text

Copyright ©2018 chaintope, Inc. all rights reserved. Deploy Tool Test Tool 1. Truffleの概要

Slide 9

Slide 9 text

Copyright ©2018 chaintope, Inc. all rights reserved. Deploy Tool Test Tool Node for Dev 1. Truffleの概要

Slide 10

Slide 10 text

Copyright ©2018 chaintope, Inc. all rights reserved. Truffleの紹介 1. Truffleの概要 2. migation 3. ganache 4. mocha 5. その他の機能 今日話すこと

Slide 11

Slide 11 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● Smart Contractのデプロイ方法を記述するもの ● DB Migrationのようにバージョンを分けて記述可能 ● DB Migrationと大きく違うのはrollbackできないこと ● バージョンを指定して途中までdeployとかもできない。 2. Migration

Slide 12

Slide 12 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● 基本的なDeploy https://truffleframework.com/docs/truffle/getting-started/running-migrations 2. Migration

Slide 13

Slide 13 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● Deploy時に使えるParameter https://truffleframework.com/docs/truffle/getting-started/running-migrations 2. Migration

Slide 14

Slide 14 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● Deploy時に使えるParameterその2 https://truffleframework.com/docs/truffle/getting-started/running-migrations 2. Migration

Slide 15

Slide 15 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● Library ContractとのLink https://truffleframework.com/docs/truffle/getting-started/running-migrations 2. Migration

Slide 16

Slide 16 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● Promisefy https://truffleframework.com/docs/truffle/getting-started/running-migrations 2. Migration

Slide 17

Slide 17 text

Copyright ©2018 chaintope, Inc. all rights reserved. Truffleの紹介 1. Truffleの概要 2. migation 3. ganache 4. mocha 5. その他の機能 今日話すこと

Slide 18

Slide 18 text

Copyright ©2018 chaintope, Inc. all rights reserved.  開発用のnode ● 即時マイニング機能 ● 固定されたmnemonic ● 便利なRPC ● 任意のgas limitが指定可能(別起動時に指定可能) 3. ganache

Slide 19

Slide 19 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● 即時マイニング ● Transactionが発行されるたびにすぐにminingが行 われる。 ● Transactionが行方不明にならない! ● mining待ちも発生しない。 3. ganache

Slide 20

Slide 20 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● 固定されたmnemonic 3. ganache

Slide 21

Slide 21 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● 固定されたmnemonic 3. ganache

Slide 22

Slide 22 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● 便利なRPC ● evm_increaseTime: block timeを任意の時間に設 定(ただし未来のみ) ● evm_mine: 即時mining ● evm_snapshot: 現在の状態のsnapshotをとる ● evm_revert: 状態を指定されたsnapshotに戻す 3. ganache

Slide 23

Slide 23 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● 任意のgas limitが指定可能(別起動時に指定可能) https://github.com/trufflesuite/ganache-cli#using-ganache-cli $ ganace-cli -l 99999999 & truffle test 3. ganache

Slide 24

Slide 24 text

Copyright ©2018 chaintope, Inc. all rights reserved. Truffleの紹介 1. Truffleの概要 2. migation 3. ganache 4. mocha 5. その他の機能 今日話すこと

Slide 25

Slide 25 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● Javascriptでは有名なunit test tool ● basic (describe, it) ● before, after, beforeEach, afterEach ● skip, only 4. mocha

Slide 26

Slide 26 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● basic (describe, it) https://mochajs.org/#asynchronous-code 4. mocha

Slide 27

Slide 27 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● basic (describe, it) https://mochajs.org/#asynchronous-code 4. mocha

Slide 28

Slide 28 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● before, after, beforeEach, afterEach https://mochajs.org/#hooks 4. mocha

Slide 29

Slide 29 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● skip, only https://mochajs.org/#inclusive-tests 4. mocha

Slide 30

Slide 30 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● skip, only https://mochajs.org/#inclusive-tests 4. mocha

Slide 31

Slide 31 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● skip, only https://mochajs.org/#exclusive-tests 4. mocha

Slide 32

Slide 32 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● skip, only https://mochajs.org/#exclusive-tests 4. mocha

Slide 33

Slide 33 text

Copyright ©2018 chaintope, Inc. all rights reserved. Truffleの紹介 1. Truffleの概要 2. migation 3. ganache 4. mocha 5. その他の機能 今日話すこと

Slide 34

Slide 34 text

Copyright ©2018 chaintope, Inc. all rights reserved. ● truffle-debugger ● https://github.com/trufflesuite/truffle/tree/next/packages/truffle-debugger#truffle-debug ger ● truffle-contract : 単体でも使える ● truffle-artifactor 5. その他の機能

Slide 35

Slide 35 text

Copyright ©2018 chaintope, Inc. all rights reserved. ここからは Step 1をハンズオン形式で 説明します! おわり