Slide 1

Slide 1 text

ERC-721Λ͔ͧ͑ͯ 2019-08-27 Road to Devcon 3.0 double jump.tokyoגࣜձࣾ ϦʔυΤϯδχΞ ຬ଍ ྄

Slide 2

Slide 2 text

• Re-building the future of gaming
 with blockchain technology !! • 2018೥4݄ ૑ۀ • ϒϩοΫνΣʔϯήʔϜઐۀ։ൃձࣾ • ैۀһ17ਓʢۀ຿ҕୗΛؚΉʣ • ϒϩοΫνΣʔϯʹ೤ҙͷ͋ΔΤϯδχΞΛੵۃ࠾༻தͰ͢ʂ double jump.tokyoגࣜձࣾ

Slide 3

Slide 3 text

• ຬ଍ ྄ ʢManzoku Ryoʣ • double jump.tokyo ϦʔυΤϯδχΞ • 2018೥7݄ΑΓ Πϯϑϥઃܭӡ༻ɺαʔόαΠυ։ൃɺ SmartContract։ൃɺϒϩοΫνΣʔϯٕज़ௐࠪͳͲΛ୲౰ • աڈʹ͸ιʔγϟϧήʔϜձࣾɺEdTechΞϓϦձࣾͰΠϯϑϥ ΤϯδχΞͱͯ͠AWSΛத৺ͱͨ͠Ϋϥ΢υΠϯϑϥ͔ΒΞϓ Ϧ·ͰͷશମઃܭɺߏஙɺվળΛܦݧ ࣗݾ঺հ

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

• ຬ଍ ྄ ʢManzoku Ryoʣ • double jump.tokyo ϦʔυΤϯδχΞ • 2018೥7݄ΑΓ Πϯϑϥઃܭӡ༻ɺαʔόαΠυ։ൃɺ SmartContract։ൃɺϒϩοΫνΣʔϯٕज़ௐࠪͳͲΛ୲౰ • աڈʹ͸ιʔγϟϧήʔϜձࣾɺEdTechΞϓϦձࣾͰΠϯϑϥ ΤϯδχΞͱͯ͠AWSΛத৺ͱͨ͠Ϋϥ΢υΠϯϑϥ͔ΒΞϓ Ϧ·ͰͷશମઃܭɺߏஙɺվળΛܦݧ ࣗݾ঺հ σβΠϯͷܦݧ͸ͳ͍ͷͰ
 SolidityͱWebύϑΥʔϚϯεͷ࿩Λ͠·͢ʂ

Slide 6

Slide 6 text

• Ϣʔβʔମݧͱ͍͏ҙຯͰɺࠓ೔ʹ͓͍ͯ
 ΦϯνΣʔϯͰαʔϏε͸શͯΛ࣮૷͢Δͷ͸ෆՄೳ • Ethereum X.X ʹظ଴ʂ • “Read world”ʹαʔϏεΛఏڙ͢ΔͨΊʹ͸ɺΦϑνΣʔϯͱ ͷ૊Έ߹Θ͕ͤඞਢ • ʮERC-721τʔΫϯΛ਺͑Δʯͱ͍͏ྫͰ՝୊Λ঺հ • WebύϑΥʔϚϯεͷ؍఺͔ΒUX՝୊Λײͯ͡΋Β͑Ε͹ MyCryptoHeroesͷܦݧ͔Β͓࿩Ͱ͖Δ͜ͱ

Slide 7

Slide 7 text

ࠓ೔͸ԕྀ͠ͳ͍͍ͯ͘ͱฉ͍ͯ·͢

Slide 8

Slide 8 text

• ΋͍ͬͯͳ͍ • 1͔ͭΒ9͍ͭ࣋ͬͯΔ • 10Ҏ্͍࣋ͬͯΔ • 2Ҏ্ͷίϯτϥΫτͷτʔΫϯΛ͍࣋ͬͯΔ • 10Ҏ্ͷίϯτϥΫτͷτʔΫϯΛ͍࣋ͬͯΔ • ࣗ෼͕σϓϩΠͨ͠ίϯτϥΫτͷτʔΫϯΛ100ΞυϨεҎ্ ͕ॴ༗͍ͯ͠Δ ERC-721ͷτʔΫϯ࣋ͬͯ·͔͢ʁ

Slide 9

Slide 9 text

• ΢ΥϨοτͱ͸ʁ • Metamask on Chrome • tokenPocket / GO Wallet ଞϞόΠϧܥ • Opera • HTC Exodus / FINNY • Dapper • ࣗ࡞ ΢ΥϨοτ͸ͳʹΛ࢖͍ͬͯ·͔͢ʁ

Slide 10

Slide 10 text

• ஌Βͳ͍ • ΢ΥϨοτಠࣗϊʔυ • Infura.io • CloudFlare • ࣗલϊʔυ ͓࢖͍ͷ΢ΥϨοτ͕઀ଓ͍ͯ͠Δϊʔυ͸ʁ

Slide 11

Slide 11 text

• MyCryptoHeroesͷ঺հ • ERC-721ͱERC-721 Enumerableʹ͍ͭͯ • ERC-721 Enumerableͷ࣮ࡍͱ՝୊Λ௨ͯ͠”Real world”ͷϒ ϩοΫνΣʔϯαʔϏεΛߟ͑Δ • MCH+ͷ঺հ ͓඼ॻ͖

Slide 12

Slide 12 text

ʹ͍ͭͯ

Slide 13

Slide 13 text

https://mch.gg/start

Slide 14

Slide 14 text

• ήʔϜʹ͔͚ͨ࣌ؒ΋͓ۚ΋৘೤΋ɺ͋ͳͨͷࢿ࢈ͱͳΔੈք • ྺ্࢙ͷώʔϩʔΛूΊɺΞΠςϜΛ֫ಘ͠ɺότϧ͢Δ
 ϒϩοΫνΣʔϯRPGήʔϜ • ϒϩοΫνΣʔϯEthereum͓Αͼ෼ࢄετϨʔδIPFSΛར༻ • Ethereum্ͰͷDailyActiveUserɾNFTऔҾྔ/औҾ਺Ͱੈք1Ґ MyCryptoHeroesʢϚΠΫϦʣͱ͸

Slide 15

Slide 15 text

ήʔϜը໘

Slide 16

Slide 16 text

MyCryptoHeroesͷߏ੒ཁૉ &UIFSFVN 6TFS Ϣʔβʔ͸ECDSAॺ໊༻ͷൿີ伴ͱ ରʹͳΔΞυϨεΛॴ༗ ήʔϜࢿ࢈͸ɺEthereum্Λਖ਼ͱͯ͠؅ཧ ॴ༗৘ใ͸ɺϢʔβʔͷΞυϨεʹ͋Δ ॴ༗৘ใΛ֬ೝ ήʔϜࢿ࢈Λ༻͍ͯήʔϜͰ༡Ϳ ࢿ࢈ΛҭͯΔ MyCryotoHeroesͰ͸ ɾήʔϜࢿ࢈Λ࢖ͬͨ༡ͼͷఏڙ ɾETHʹΑΓήʔϜ಺௨՟Λൢച ɾ৽͍͠ήʔϜࢿ࢈ͷ෇༩ɺൢച ɾήʔϜࢿ࢈΁ΞʔτΛ෇༩

Slide 17

Slide 17 text

• ϒϩοΫνΣʔϯͷ՝୊Ͱ͋ΔεέʔϥϏϦςΟͱUXͷղܾ ͷͨΊήʔϜͱͯ͠ͷػೳ͸ΦϑνΣʔϯͰߏங • σδλϧΞηοτʹ͸NFTʢERC-721ʣΛ࠾༻ • ήʔϜ಺௨՟ߪೖ෦෼ͱNFTؔ࿈ͷΈΦϯνΣʔϯ • NFTͷΞΠίϯ࡞ͬͨͷͰ࢖ͬͯͶʂγʔϧ΋͋ΔΑʂ MyCryptoHeroesͷΞʔΩςΫνϟ

Slide 18

Slide 18 text

• 2018/9/21-10/1 ώʔϩʔϓϨηʔϧͷ࣮ࢪ • 2018/9/25-11/2 ότϧβͷ࣮ࢪ • Loom NetworkΛར༻ͨ͠ΦϯνΣʔϯότϧγεςϜ • 2018/10/23 gRPC-WebͷGAΛड͚࣮ͯ૷ͷมߋ • 2018/11/30 ຊϦϦʔε MyCryptoHeroesϦϦʔε·Ͱͷมભ

Slide 19

Slide 19 text

• EVMΛ౥ࡌͨ͠αΠυνΣʔϯٕज़Ͱ͋ΔLoom NetworkΛ࠾༻ • ΦϯνΣʔϯٕज़Λ༻͍ͳ͕Β࣮ߦແྉ&ߴ଎࣮ߦΛ࣮ݱ • ϒϩοΫνΣʔϯͰՁ஋Λ୲อ͠ͳ͕ΒήʔϜͱͯ͠ͷUXΛ֬ อͰ͖ͨɺɺ͸ͣ ότϧβ։࢝ͷߏ੒ &UIFSFVN 6TFS

Slide 20

Slide 20 text

• ϩδοΫͱͯ͠ΦϯνΣʔϯʢSolidityʣʹΑΔ࣮ߦ͸Մೳ • ͨͩ͠ɺॏ͗͢Δ • 1ότϧʹ͖ͭ10ඵఔ౓͔͔Γɺͦͷؒશͯͷॻ͖ࠐΈ͕ϒ ϩοΫ͞ΕΔࣄଶ • ͞Βʹৄ͍͠ઓ͍͸ҎԼͷεϥΠυʹͯ • https://mch.gg/hicon2018 • https://speakerdeck.com/rmanzoku/blockchain-game-in-practice ότϧβͷ݁Ռ

Slide 21

Slide 21 text

MyCryptoHeroesͷߏ੒ཁૉ &UIFSFVN 6TFS Ϣʔβʔ͸ECDSAॺ໊༻ͷൿີ伴ͱ ରʹͳΔΞυϨεΛॴ༗ ήʔϜࢿ࢈͸ɺEthereum্Λਖ਼ͱͯ͠؅ཧ ॴ༗৘ใ͸ɺϢʔβʔͷΞυϨεʹ͋Δ ॴ༗৘ใΛ֬ೝ ήʔϜࢿ࢈Λ༻͍ͯήʔϜͰ༡Ϳ ࢿ࢈ΛҭͯΔ MyCryotoHeroesͰ͸ ɾήʔϜࢿ࢈Λ࢖ͬͨ༡ͼͷఏڙ ɾETHʹΑΓήʔϜ಺௨՟Λൢച ɾ৽͍͠ήʔϜࢿ࢈ͷ෇༩ɺൢച ɾήʔϜࢿ࢈΁ΞʔτΛ෇༩

Slide 22

Slide 22 text

ERC-721ʹ͍ͭͯ

Slide 23

Slide 23 text

• EthereumͰNFTΛ࣮ݱ͢Δݱ࣮తͳඪ४࢓༷ • ʮॴ༗৘ใʯʮৡ౉ʯʮৡ౉ݖͷҠৡʯΛنఆͨ͠Πϯλʔ ϑΣʔεΛ࣮૷͢Δඞཁ͕͋Δ • ඪ४࢓༷Ͱ͋ΔͨΊɺERC-721Λ࠾༻ͨ͠ήʔϜɺαʔϏεɺ औҾॴͰ௥Ճ։ൃແ͠Ͱར༻Ͱ͖ΔΑ͏ʹͳΔ • ERC-721Λ࣮૷ͨ͠ = NFT ͱͳΔΘ͚Ͱ͸ͳ͍͜ͱΛ஫ҙ ERC-721ͱ͸

Slide 24

Slide 24 text

ERC-721 Interfaces pragma solidity ^0.4.20; interface IERC721 /* is IERC165 */ { event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); function balanceOf(address _owner) external view returns (uint256); function ownerOf(uint256 _tokenId) external view returns (address); function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable; function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable; function transferFrom(address _from, address _to, uint256 _tokenId) external payable; function approve(address _approved, uint256 _tokenId) external payable; function setApprovalForAll(address _operator, bool _approved) external; function getApproved(uint256 _tokenId) external view returns (address); function isApprovedForAll(address _owner, address _operator) external view returns (bool); }

Slide 25

Slide 25 text

• ownerOfؔ਺ʹΑΓ͋ΔτʔΫϯIDͷॴ༗ऀ͕Θ͔Δ • balaceOfؔ਺ʹΑΓ͋ΔΞΧ΢ϯτͷ૯ॴ༗਺͕Θ͔Δ • τʔΫϯͷॴ༗ऀ͸ଞऀʹτʔΫϯΛৡ౉Ͱ͖Δ • approveʹ͍ͭͯ͸ׂѪ • ͋ΔΞΧ΢ϯτͷॴ༗τʔΫϯIDҰཡ͸औಘͰ͖ͳ͍ ERC-721ͷͰ͖Δ͜ͱͰ͖ͳ͍͜ͱ

Slide 26

Slide 26 text

ࣗ෼ͷ࣋ͬͯΔΞηοτฒ΂͍ͨͰ͢ΑͶ

Slide 27

Slide 27 text

ERC-721 Enumerable

Slide 28

Slide 28 text

ERC-721 Enumerable Interface interface ERC721Enumerable is ERC721 { function totalSupply() external view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); function tokenByIndex(uint256 index) external view returns (uint256); }

Slide 29

Slide 29 text

• ྻڍΛՄೳʹ͢ΔΦϓγϣϯ֦ு Enumerable • ownerͱindex͔ΒτʔΫϯIDΛऔಘͰ͖ΔtokenOfOwnerByIndexؔ਺ ͕͋Δ • balanceOfͰͱͬͨ਺͚ͩtokenOfOwnerByIndexΛͿΜճͤ͹Α͍ɻ • ಡΈऔΓࢹ఺ • ҰཡΛऔಘͰ͖ΔΑ͏ʹͱStorage΁৘ใΛอଘ • ॻ͖ࠐΈࢹ఺ ERC-721 Enumerable

Slide 30

Slide 30 text

• to infura.io ௚ྻ100ݸ • 60ඵ͘Β͍͔͔Δ • infra.io͸ΞϝϦΧʹαʔόʔ͕͋ΔͷͰɺ೔ຊ͔Βͩͱݫ͍͠ ͿΜ·Θͯ͠Έ·͠ΐ͏

Slide 31

Slide 31 text

• infuraͷϊʔυ͸ɺւ֎ʹ͋ΔͨΊϨΠςϯγ͕େ͖͍ • ͍ΘΏΔʮޫ஗͍໰୊ʯ • await͍ͯ͠Δ͔ΒͰ͸ʁ • ͦ͏Ͱ͢Ͷɻ
 ͕ɺຊ୊͸ͦ͜Ͱ͸ͳ͘100ݸ΋ϦΫΤετΛൃߦ͢Δ͜ͱ • UXతͳ࿩ͩͱ΋ͪΖΜฒྻԽ͢΂͖ • ͔͠͠HTTP1.1ͷϒϥ΢β͸6ຊఔ౓͔͠ฒྻԽͰ͖ͳ͍ ΋͠100ݸͷτʔΫϯΛ͍࣋ͬͯΔਓͩͬͨΒ

Slide 32

Slide 32 text

• ࠃ಺ʹ͋Δ๭ϊʔυαʔϏε • ଎͘ͳͬͨʂ • ͨͩ͠ɺϢʔβʔ͕࣋ͭ΢ΥϨοτͷϊʔυΛαʔϏεఏڙऀ ͕ࢦఆͰ͖·͔͢ʁ • ίϯτϩʔϧෆՄೳͳྖҬͰͷղܾࡦ͸ແҙຯ ࠃ಺ʹϊʔυ͕͋Ε͹Α͘ͳ͍ʁ

Slide 33

Slide 33 text

ࣗ෼ͷ࣋ͬͯΔΞηοτฒ΂Δ͚ͩͰ΋ࠔ೉

Slide 34

Slide 34 text

• WebͷύϑΥʔϚϯεվળʹ͓͍ͯɺࣗ෼ͨͪͷίϯτϩʔϧ ՄೳͳൣғͰ౒ྗΛ͢΂͖ɺࣗ෼ͨͪͷίϯτϩʔϧՄೳͳൣ ғΛ૿΍͢΂͖ • Wallet͸ɺ伴؅ཧͷ؍఺͔Βݴͬͯ΋ෆՄ৵Ͱ͋Δํ͕ྑ͍ • ૉ௚ʹಡΉͷͰ͸ͳ͘ɺϓϩΩγ΍ΩϟογϡΛಋೖ͢΂͖ • ͦ΋ͦ΋ϒϩοΫνΣʔϯͷʮঢ়ଶʯ͸Ωϟογϡͱ૬ੑ͕ྑ ͍ ಡΈऔΓύϑΥʔϚϯεʹ͍ͭͯ

Slide 35

Slide 35 text

• transferͷλΠϛϯάͰɺॴ༗ҰཡΛ؅ཧ͍ͯ͠Δ • https://github.com/OpenZeppelin/openzeppelin-contracts/ commit/d1158ea68c597075a5aec4a77a9c16f061beffd3 • Storageͷߋ৽ͳͷͰ΋ͪΖΜGas͕͔͔Γ·͢ɻ ERC-721 Enumerableͷ࣮૷ // Mapping from owner to list of owned token IDs mapping(address => uint256[]) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex;

Slide 36

Slide 36 text

Gasൺֱද ERC-721 ERC-721 Enumerable ྻڍ ☓ ˚ mint Gas 66,878 158,461 transferFrom Gas 44,742 72,236 https://ropsten.etherscan.io/address/0x78b315eff64c865ad1d903cd771eb85f9bb2558c https://ropsten.etherscan.io/address/0x78b315eff64c865ad1d903cd771eb85f9bb2558c https://ropsten.etherscan.io/address/0xe18e82118b1a277d90beefe7ffd7421b606d0f83

Slide 37

Slide 37 text

• ίϯτϥΫτ্ͰྻڍΛ࢖͏৔߹͸ඞਢ • transferFromΛ·ͱΊ࣮ͯߦ͢Δ • 20ݸ͘Β͍·Ͱߦ͚Δ • ID͝ͱʹuint256ΛׂΓ౰ͯͯͳʹ͔Λ؅ཧ͢Δ • 150ݸ͘Β͍·Ͱ͍͚Δ • ͦ΋ͦ΋uint256ͬͯͲ͏ࢥ͍·͔͢ Enumerable͸࢖͑ͳ͍ͷʁ

Slide 38

Slide 38 text

• ࣗ਎ΛؚΉSmartContract͔Βݺ͹Ε͏ΔཁૉͷΈΛStorageʹ อଘ͢΂͖ • Smart Contract֎͔Βݺ͹Ε͏Δ΋ͷ͸Eventͱ࣮ͯ͠૷͢΂͖ • ΦϑνΣʔϯ΍αΠυνΣʔϯ • ERC-721ʹݶΒͣͦ͏͍͏ઃܭํ਑Λݟ͔͚Δ • ༨ܭͳཁૉ͸ɺকདྷʹ౉ΓϢʔβʔ΁༨ܭͳGasͷෛ୲Λڧ͍Δ ͜ͱʹͳΔ → Ϣʔβʔମݧ΁ͷѱӨڹ SmartContractͷઃܭํ਑

Slide 39

Slide 39 text

• ϒϩοΫνΣʔϯ্Ͱ͢΂ͯͷॲཧ͢Δͷ͸೉͍͠ • WebύϑΥʔϚϯεͷ໰୊΍Gasͷ؍఺͔ΒϢʔβʔମݧͱ ͯ͠΋ݫ͍͠ͱݴΘ͟Δ͓͑ͳ͍ • ࢓༷Λࣄલʹߟ͑ͯɺඞཁͳΒΦϑνΣʔϯͱซ༻͢Δ • ຊ౰ʹίϯτϥΫτͰྻڍ͢Δඞཁ͸͋Δͷ͔ʁ • ͦΕΛೖΕΔ͜ͱʹΑͬͯશͯͷϢʔβʔ͕GasΛෛ୲͢Δ ͜ͱΛ಄ʹೖΕ͓ͯ͘ ERC-721 EnumerableΛ௨ͯ͡

Slide 40

Slide 40 text

• ERC-721Ͱ͔ͤͬ͘ن͕ܾ֨·͍ͬͯΔͷ͔ͩΒ͍͍ײ͡ʹͰ ͖ͳ͍ͷɺɺʁ • ϒϩοΫνΣʔϯͰσδλϧΞηοτ؅ཧ͍͚ͨͩ͠ͳΜ͚ͩ Ͳɺɺɺ • ϒϩοΫνΣʔϯήʔϜͬͯͳΜ͔ͩϒϧʔΦʔγϟϯΒ͍͠ ͡Όͳ͍ʁ ͱ͜ΖͰɺɺ

Slide 41

Slide 41 text

ʹ͍ͭͯ

Slide 42

Slide 42 text

• ʮήʔϜʹ͔͚ͨ࣌ؒ΋͓ۚ΋৘೤΋ɺ͋ͳͨͷࢿ࢈ͱͳΔੈ քʯͷ֦େΛ໨ࢦͯ͠ • NFT͕ήʔϜͱήʔϜΛඈͼӽ͑Δੈք؍ͷ࣮ݱʹΉ͚ͯ • MyCryptoHeroesͷϊ΢ϋ΢ΛϑϨʔϜϫʔΫͱͯ͠ఏڙ͢Δϒ ϩοΫνΣʔϯήʔϜ։ൃࢧԉϓϩάϥϜ • ϒϩοΫνΣʔϯήʔϜࢢ৔΁ͷࢀೖোนΛԼ͛Δ MCH+ͱ͸

Slide 43

Slide 43 text

• ΋ͪΖΜྻڍػೳ΋ఏڙ • ERC-721 Metadataػೳ • Approvalؔ࿈ • ͦͷଞӶҙ։ൃதʂ ERC-721ʹ·ͭΘΔAPIΛఏڙ༧ఆ

Slide 44

Slide 44 text

ERC-721 Interfaces pragma solidity ^0.4.20; interface IERC721 /* is IERC165 */ { event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); function balanceOf(address _owner) external view returns (uint256); function ownerOf(uint256 _tokenId) external view returns (address); function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable; function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable; function transferFrom(address _from, address _to, uint256 _tokenId) external payable; function approve(address _approved, uint256 _tokenId) external payable; function setApprovalForAll(address _operator, bool _approved) external; function getApproved(uint256 _tokenId) external view returns (address); function isApprovedForAll(address _owner, address _operator) external view returns (bool); }

Slide 45

Slide 45 text

• ERC-721ʹ͓͍ͯɺtransferΠϕϯτ͸ඞਢ • ੜ·Ε͔ͯΒશͯͷtransferΛ௥͑͹ɺݱࡏͷঢ়ଶ͸൑໌͢Δ ΦϑνΣʔϯͰؤுΔྻڍ $ curl -s https://beta-api.mch.plus/inventory/ethereum/mainnet/ 0xd868711BD9a2C6F1548F5f4737f71DA67d821090/0xdceaf1652a131F32a821468Dc03A 92df0edd86Ea { "token_ids": [ 10021522, 10220372, 20270673, 20270688 ] }

Slide 46

Slide 46 text

ൺֱද ERC-721 ERC-721 Enumerable MCH+ ERC-721 ྻڍ ☓ ˚ ̋ mint Gas 66,878 158,461 66,871 transfer Gas 44,742 72,236 44,742

Slide 47

Slide 47 text

RE-BUILDING THE FUTURE OF GAMING WITH BLOCKCHAIN TECHNOLOGY !!