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

社内仮想通貨をモバイルDappとしてつくってみた

 社内仮想通貨をモバイルDappとしてつくってみた

Hi-Ether Meetup - Block #1

daisuke sato

March 09, 2018
Tweet

More Decks by daisuke sato

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ ࠤ౻ େี(@st_dsk) Co-Founder & CTO at Popshoot, Inc #go

    #swift #☕ medium.com/@st_dsk 0x01 Works + Dapp?
  2. ࣮૷ύλʔϯ(JSONRPCܦ༝) 0x0f Ethereum
 Client Server (Wallet&Txॺ໊) ϞόΠϧDapp API Tx params

    JSONRPC Signed Tx Ethereum
 Client Wallet App (Wallet&Txॺ໊) ϞόΠϧDapp URL Scheme? JSONRPC Signed Tx Ethereum
 Client ϞόΠϧDapp (Wallet&Txॺ໊) Tx params JSONRPC Signed Tx ᶃ αʔόʔͰ΢ΥϨοτ؅ཧ&Txൃߦ ᶄ ֎෦΢ΥϨοτΞϓϦ͔ΒTxൃߦ ᶅ ΞϓϦͰ΢ΥϨοτ؅ཧ&Txൃߦ
  3. ࣮૷ύλʔϯ(JSONRPCܦ༝) 0x10 Ethereum
 Client Server (Wallet&Txॺ໊) ϞόΠϧDapp API Tx params

    JSONRPC Signed Tx Ethereum
 Client Wallet App (Wallet&Txॺ໊) ϞόΠϧDapp URL Scheme? JSONRPC Signed Tx Ethereum
 Client ϞόΠϧDapp (Wallet&Txॺ໊) Tx params JSONRPC Signed Tx ᶃ αʔόʔͰ΢ΥϨοτ؅ཧ&Txൃߦ ᶄ ֎෦΢ΥϨοτΞϓϦ͔ΒTxൃߦ ᶅ ΞϓϦͰ΢ΥϨοτ؅ཧ&Txൃߦ
  4. ϞόΠϧDappʹඞཁͳཁૉ 0x0e • ΢ΥϨοτ • ൿີ伴΍ΞυϨεͷੜ੒&ӬଓԽ • ABIύʔαʔ(✳ͨͩ͠ඞਢͰ͸ͳ͍) • ABI͔ΒίϯτϥΫτͷؔ਺৘ใΛऔಘ

    • ؔ਺γάωνϟͷϋογϡͱҾ਺ύϥϝʔλΛ࿈݁ͨ͠จࣈྻͷग़ྗ • Txੜ੒ͱॺ໊ • ൿີ伴Λ࢖༻ͯ͠Txʹର͢Δॺ໊(ίϯτϥΫτʹରͯ͠มߋΛՃ͑Δ৔߹) • JSONRPCΫϥΠΞϯτ • EthereumΫϥΠΞϯτͱͷ௨৴(ϒϩοΫνΣʔϯͷࢀর΍TxൃߦͳͲ)
  5. ۩ମతͳϑϩʔ 0x11 • ERC20τʔΫϯͷtransferؔ਺ΛJSONRPCܦ༝ͰCall͢Δ 1. ΢ΥϨοτ͔ΒΞυϨεͷੜ੒ 2. ίϯτϥΫτͷؔ਺γάωνϟͷsha3ϋογϡͱҾ਺ύϥϝʔλͷ256bit௕ͷ16ਐ਺จࣈྻ ͷ࿈݁ •

    "0x" + "sha3(`transfer(address,uint256)`)" + "<ૹۚઌΞυϨε>" + "<ૹֹۚ>" • => τϥϯβΫγϣϯͷdataύϥϝʔλ 3. τϥϯβΫγϣϯੜ੒͠ɺൿີ伴Ͱॺ໊ 4. ॺ໊ͨ͠τϥϯβΫγϣϯΛRLPΤϯίʔσΟϯά => "0xf8aa0684ee6b280082d8...b50504ccf8721dafc7b47" 5. EthereumΫϥΠΞϯτʹରͯ͠JSONRPCͰeth_sendRawTransactionΛCall͢Δ > curl -X POST http://127.0.0.1:8545 --data `{ "jsonrpc": "2.0", "id": 1, "method": "eth_sendRawTransaction", "params": ["0xf8aa0684ee6b280082d8...b50504ccf8721dafc7b47"] }'
  6. ϥΠϒϥϦ(iOS) 0x13 ΢ΥϨοτ ABIύʔαʔ Txੜ੒ͱॺ໊ JSONRPC ΫϥΠΞϯτ web3swift (BANKEX/web3swift) ◦

    passphrase/ BIP32,39,44 ◦ ◦ ◦ Geth Mobile (ethereum/go-ethereum) ◦ passphrase × ◦ × EthereumKit (yuzushiof/EthereumKit) ◦ BIP32,39,44 × ◦ ◦ ୯ҰػೳΛఏڙ͢ΔϥΠϒϥϦ: JSONRPCKit, RLP.swift, BigInt, CryptoSwift, etc... શ෦ͷͤܥϥΠϒϥϦ:
  7. ݱঢ়ͷ՝୊(ϞόΠϧDapp) 0x16 • πʔϧ΍ϥΠϒϥϦෆ଍ • ࣗલͰ࣮૷ or ૊Έ߹ΘͤΔඞཁ͕͋Δ • MetaMaskͷΑ͏ͳγʔϜϨεͳ΢ΥϨοτ͕ͳ͍

    • ։ൃ͕ͮ͠Β͘ɺෆศͳ͜ͱ͕ଟ͍ • Ϣʔβʔ͕ѻ͍ʹ͍͘ • ద੾ͳUI/UX͕ଘࡏ͠ͳ͍ͷͰ໛ࡧ͕ඞཁ • ϞόΠϧͳΒͰ͸ͷ੍໿ͷதͰͷ࣮૷