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

ERC-721をかぞえて / Enumerate ERC-721

ERC-721をかぞえて / Enumerate ERC-721

Ryo Manzoku

August 27, 2019
Tweet

More Decks by Ryo Manzoku

Other Decks in Programming

Transcript

  1. • Re-building the future of gaming
 with blockchain technology !!

    • 2018೥4݄ ૑ۀ • ϒϩοΫνΣʔϯήʔϜઐۀ։ൃձࣾ • ैۀһ17ਓʢۀ຿ҕୗΛؚΉʣ • ϒϩοΫνΣʔϯʹ೤ҙͷ͋ΔΤϯδχΞΛੵۃ࠾༻தͰ͢ʂ double jump.tokyoגࣜձࣾ
  2. • ຬ଍ ྄ ʢManzoku Ryoʣ • double jump.tokyo ϦʔυΤϯδχΞ •

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

    2018೥7݄ΑΓ Πϯϑϥઃܭӡ༻ɺαʔόαΠυ։ൃɺ SmartContract։ൃɺϒϩοΫνΣʔϯٕज़ௐࠪͳͲΛ୲౰ • աڈʹ͸ιʔγϟϧήʔϜձࣾɺEdTechΞϓϦձࣾͰΠϯϑϥ ΤϯδχΞͱͯ͠AWSΛத৺ͱͨ͠Ϋϥ΢υΠϯϑϥ͔ΒΞϓ Ϧ·ͰͷશମઃܭɺߏஙɺվળΛܦݧ ࣗݾ঺հ σβΠϯͷܦݧ͸ͳ͍ͷͰ
 SolidityͱWebύϑΥʔϚϯεͷ࿩Λ͠·͢ʂ
  4. • Ϣʔβʔମݧͱ͍͏ҙຯͰɺࠓ೔ʹ͓͍ͯ
 ΦϯνΣʔϯͰαʔϏε͸શͯΛ࣮૷͢Δͷ͸ෆՄೳ • Ethereum X.X ʹظ଴ʂ • “Read world”ʹαʔϏεΛఏڙ͢ΔͨΊʹ͸ɺΦϑνΣʔϯͱ

    ͷ૊Έ߹Θ͕ͤඞਢ • ʮERC-721τʔΫϯΛ਺͑Δʯͱ͍͏ྫͰ՝୊Λ঺հ • WebύϑΥʔϚϯεͷ؍఺͔ΒUX՝୊Λײͯ͡΋Β͑Ε͹ MyCryptoHeroesͷܦݧ͔Β͓࿩Ͱ͖Δ͜ͱ
  5. • ΋͍ͬͯͳ͍ • 1͔ͭΒ9͍ͭ࣋ͬͯΔ • 10Ҏ্͍࣋ͬͯΔ • 2Ҏ্ͷίϯτϥΫτͷτʔΫϯΛ͍࣋ͬͯΔ • 10Ҏ্ͷίϯτϥΫτͷτʔΫϯΛ͍࣋ͬͯΔ

    • ࣗ෼͕σϓϩΠͨ͠ίϯτϥΫτͷτʔΫϯΛ100ΞυϨεҎ্ ͕ॴ༗͍ͯ͠Δ ERC-721ͷτʔΫϯ࣋ͬͯ·͔͢ʁ
  6. • ΢ΥϨοτͱ͸ʁ • Metamask on Chrome • tokenPocket / GO

    Wallet ଞϞόΠϧܥ • Opera • HTC Exodus / FINNY • Dapper • ࣗ࡞ ΢ΥϨοτ͸ͳʹΛ࢖͍ͬͯ·͔͢ʁ
  7. • 2018/9/21-10/1 ώʔϩʔϓϨηʔϧͷ࣮ࢪ • 2018/9/25-11/2 ότϧβͷ࣮ࢪ • Loom NetworkΛར༻ͨ͠ΦϯνΣʔϯότϧγεςϜ •

    2018/10/23 gRPC-WebͷGAΛड͚࣮ͯ૷ͷมߋ • 2018/11/30 ຊϦϦʔε MyCryptoHeroesϦϦʔε·Ͱͷมભ
  8. 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); }
  9. 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); }
  10. • infuraͷϊʔυ͸ɺւ֎ʹ͋ΔͨΊϨΠςϯγ͕େ͖͍ • ͍ΘΏΔʮޫ஗͍໰୊ʯ • await͍ͯ͠Δ͔ΒͰ͸ʁ • ͦ͏Ͱ͢Ͷɻ
 ͕ɺຊ୊͸ͦ͜Ͱ͸ͳ͘100ݸ΋ϦΫΤετΛൃߦ͢Δ͜ͱ •

    UXతͳ࿩ͩͱ΋ͪΖΜฒྻԽ͢΂͖ • ͔͠͠HTTP1.1ͷϒϥ΢β͸6ຊఔ౓͔͠ฒྻԽͰ͖ͳ͍ ΋͠100ݸͷτʔΫϯΛ͍࣋ͬͯΔਓͩͬͨΒ
  11. • 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;
  12. 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
  13. 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); }
  14. ൺֱද ERC-721 ERC-721 Enumerable MCH+ ERC-721 ྻڍ ☓ ˚ ̋

    mint Gas 66,878 158,461 66,871 transfer Gas 44,742 72,236 44,742