Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gethoハッカソン -ハンズオン-
Search
daisuke sato
December 01, 2018
Technology
1
1k
gethoハッカソン -ハンズオン-
gethoハッカソンの時のハンズオンの内容です。
daisuke sato
December 01, 2018
Tweet
Share
More Decks by daisuke sato
See All by daisuke sato
BlockchainHackathon2019 ワークショップ ~ Twitterとブロックチェーンを使ったアイデンティフィケーションの実現~
daisuke310vvv
0
210
gethoとTruffleを使った DApps開発ワークショップ
daisuke310vvv
0
140
Hi-Con2018 より良いDApp開発をするための話と gethoについて
daisuke310vvv
1
360
getho ~ Ethereum private nodes, tailored for you. ~
daisuke310vvv
0
740
社内仮想通貨をモバイルDappとしてつくってみた
daisuke310vvv
1
3k
Other Decks in Technology
See All in Technology
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
630
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
280
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
AGIについてChatGPTに聞いてみた
blueb
0
130
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
130
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
210
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
380
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.9k
強いチームと開発生産性
onk
PRO
34
11k
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
GitHub's CSS Performance
jonrohan
1030
460k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Raft: Consensus for Rubyists
vanstee
136
6.6k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Happy Clients
brianwarren
98
6.7k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Transcript
getho Hackathon ϋϯζΦϯ
ࣗݾհ ໊લ: ࠤ౻ େี(@st_dsk) ձࣾ: Popshoot, Inc ݴޠ: Golang, Swift,
ຊޠ, ӳޠ ࣄ: Server/Infra ΤϯδχΞ, iOS
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
ΠʔαϦΞϜʹ͍ͭͯ • Ծ௨՟ͷҰछ(ETH) • ΞϓϦέʔγϣϯϓϥοτϑΥʔϜ • BTCͱETHͷҧ͍? • BTC௨՟ͱͯ͠ͷׂ͕ϝΠϯ •
ETHΞϓϦέʔγϣϯΛಈ͔͢ ͨΊͷͷ೩ྉ(Ψε)
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
εϚʔτίϯτϥΫτʹ͍ͭͯ • εϚʔτίϯτϥΫτ • ΠʔαϦΞϜͰಈ͘ΞϓϦέʔγϣϯ • ϊʔυʹঢ়ଶΛ࣋ͭ • ίϯτϥΫτΞυϨε •
։ൃݴޠ • Solidity, Vyper ͳͲ
Solidity • Solidity • εϚʔτίϯτϥΫτΛ࣮͢ΔͨΊͷݴޠ • EVMίʔυʹίϯύΠϧ͞ΕΔ • JavascriptϥΠΫ
Solidity pragma solidity ^0.4.24; contract SimpleStore { uint value; function
set(uint _value) public { value = _value; } function get() public constant returns (uint) { return value; } }
Solidityݴޠ༷ boolean • true or false uint v = 123
!true // => false v == 123 // => true v != 123 // => false v == 123 && true // => true v == 123 || false // => true
Solidityݴޠ༷ intergers • (u)int • (u)int8 ~ (u)int256 • int/uint(u)int256ͷΤΠϦΞε
uint x = 3 x = x + 5 // => 8 x = x * 5 // => 40 x = x / 5 // => 8 x = x % 5 // => 3
Solidityݴޠ༷ address • 20byteͷ(ΠʔαϦΞϜΞυϨε) • address or address payable(>=0.5.0) address
payable x = address(0x123); address myAddress = address(this); if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);
Solidityݴޠ༷ array uint[2] fixedArr; fixedArr[0] = 10; // [10, 0]
arr.length; // 2 string[] arr; arr.push("apple"); // [apple] arr.push("banana"); // [apple,banana]
Solidityݴޠ༷ struct struct Person { address addr; string name; uint8
age; } Person memory p = Person(address(0xabc...), "Vitalik", 24); p.age // => 24
Solidityݴޠ༷ mapping mapping(address => uint) public balances; balances[msg.sender] = 100;
balances[msg.sender] // => 100;
Solidityݴޠ༷ forจ for(int i = 0; i < 20; i++)
{ // do something }
Solidityݴޠ༷ ifจ uint a = 1; uint b = 2;
if (a == b) { // do something } else if (a != b) { // do something } else { // do something }
Solidityݴޠ༷ Time 1 == 1 seconds 1 minutes == 60
seconds 1 hours == 60 minutes 1 days == 24 hours 1 weeks == 7 days
Solidityݴޠ༷ Block, Transaction Properties • blockhash(uint blockNumber) returns (bytes32) •
block.gaslimit: uint • block.number: uint • block.timestamp: uint • tx.gasprice: uint
Solidityݴޠ༷ ͦͷଞ • msg.sender: address payable • msg.value: uint •
now: uint
Solidityݴޠ༷ storageͱmemory • storage • ϒϩοΫνΣʔϯ্ʹΔ • gas͕͔͔Δ • memory
• ϒϩοΫνΣʔϯ্ʹΒͳ͍ • gas͕͔͔Βͳ͍
Solidityݴޠ༷ Function function (<parameter types>) {internal|external} [pure|view|payable] [returns (<return types>)]
• pure, view, payable • pure: storageͷΞΫηεෆՄ • view: storageͷࢀরͷΈՄ • payable: ETHͷૹ͖ۚ
Solidityݴޠ༷ Modifier • ࣮ؔߦ࣌ʹҙͷॲཧΛ࣮ߦ͢Δ contract A { address owner; modifier
onlyOwner { require(msg.sender == owner); _; } function doSomething() public onlyOwner { // do something if owner } }
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
DApp։ൃ4େπʔϧ • ݴޠ(solidity, vyper) • ϑϨʔϜϫʔΫ(truffle, emberk) • IDE(Remix, EthFiddle)
• ςετ༻ϒϩοΫνΣʔϯωοτϫʔΫ(ganache, getho)
DApp։ൃπʔϧ • web3.js • Truffle • OpenZeppelin • MetaMask
DApp։ൃπʔϧ web3.js • ϊʔυʹΞΫηε͢ΔͨΊͷϥΠϒϥϦ var Web3 = require('web3'); var web3
= new Web3(); web3.setProvider(new web3.providers.HttpProvider('http://127.0.0.1:8545')); (web3.eth.getBalance("0x...");
DApp։ൃπʔϧ Truffle • εϚʔτίϯτϥΫτΛ։ൃ͢ΔͨΊͷϑϨʔϜϫʔΫ $ truffle init $ truffle compile
$ truffle migrate
DApp։ൃπʔϧ OpenZeppelin • εϚʔτίϯτϥΫτͷςϯϓϨʔτɺϥΠϒϥϦ • ERC20, ERC721, SafeMathͳͲ
DApp։ൃπʔϧ MetaMask • ϒϥβΥϨοτ • ETHτʔΫϯͷߴࢀরɺૹۚ • web3ͱ࿈ܞՄೳ
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
getho DApp։ൃͷͨΊͷ։ൃϓϥοτϑΥʔϜ ಛ - ςετ༻ϒϩοΫνΣʔϯωοτϫʔΫ - εϚʔτίϯτϥΫτͷ࣮ߦڥ
getho Dashboard • ؆୯ʹىಈ • τϥϯβΫγϣϯཤྺ • σϑΝϧτΞΧϯτ
None
getho ίϯτϥΫτ࣮ߦ • GUI্Ͱ࣮ߦ • ࣮ߦ݁Ռ
None
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ • ࡞Δͷ • ERC20τʔΫϯ • ։ൃڥ • Node •
Truffle • OpenZeppelin • getho
લ४උᶃ • gethoΞΧϯτੜ • ͪ͜Β͔Β => https://getho.io
લ४උᶄ • Πϯετʔϧ $ brew install node // Windows or
Linuxͷ߹దٓ $ npm install -g truffle $ npm install -g openzeppelin-solidity
લ४උᶅ • σΟϨΫτϦੜ $ mkdir ~/HackathonToken $ cd ~/HackathonToken •
truffleͷॳظԽ $ truffle init
contractsʹϑΝΠϧΛՃ $ touch ./contracts/HackathonToken.sol $ vim ./contracts/HackathonToken.sol // ΤσΟλΛ։͘
HackathonTokenͷ࣮ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; contract HackathonToken
is ERC20, ERC20Detailed { constructor( string name, string symbol, uint8 decimals, uint256 initialSupply ) ERC20Detailed(name, symbol, decimals) ERC20() public {} }
migrationsʹϑΝΠϧΛՃ $ touch ./migrations/2_deploy_hackathon.js $ vim ./migrations/2_deploy_hackathon.js // ΤσΟλΛ։͘
σϓϩΠ༻ͷmigrationίʔυΛ࣮ var hackathon = artifacts.require("./HackathonToken.sol"); module.exports = function(deployer){ var name
= "Hackathon Token"; var symbol = "HKT"; var decimals = 18; var initialSupply = 1000000e18 deployer.deploy(hackathon, name, symbol, decimals, initialSupply, { }) }
truffle.jsʹωοτϫʔΫͷՃ $ vim ./truffle.js // ΤσΟλΛ։͘ module.exports = { networks:
{ getho: { host: "<YOUR SUBDOMAIN>.getho.io/jsonrpc", port: 80, gas: 4712388, network_id: 1010 } } };
gethoʹσϓϩΠ $ truffle migrate --network getho // => gethoͰτϥϯβΫγϣϯ֬ೝ
ίϯτϥΫτΛgethoʹొ $ brew tap popshootjapan/homebrew-getho $ brew install getho //
or go get github.com/popshootjapan/getho $ getho login $ getho upload ./build/contracts/HackathonToken.json \ -s <YOUR SUBDOMAIN> // => gethoͰίϯτϥΫτ࣮ߦ ※ gethoཧը໘্͔ΒొͰ͖·͢
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
ToDoΞϓϦͷհ • WebΞϓϦέʔγϣϯ http://<ip>:3000/ • ιʔείʔυ https://github.com/daisuke310vvv/web3todo
ϋοΧιϯΛ ָ͠Έ·͠ΐ͏ʂʂ