<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harry Chang on Medium]]></title>
        <description><![CDATA[Stories by Harry Chang on Medium]]></description>
        <link>https://medium.com/@harry830622?source=rss-ab9f719e5adf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Xr23QYRyhbVwNbxo5PFIlw.jpeg</url>
            <title>Stories by Harry Chang on Medium</title>
            <link>https://medium.com/@harry830622?source=rss-ab9f719e5adf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:22:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harry830622/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NBA Top Shot 主合約 Cadence 解析]]></title>
            <link>https://medium.com/flow-tw/nba-top-shot-%E4%B8%BB%E5%90%88%E7%B4%84-cadence-%E8%A7%A3%E6%9E%90-d85cab5f208d?source=rss-ab9f719e5adf------2</link>
            <guid isPermaLink="false">https://medium.com/p/d85cab5f208d</guid>
            <category><![CDATA[flow]]></category>
            <category><![CDATA[cadence]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Harry Chang]]></dc:creator>
            <pubDate>Sun, 27 Feb 2022 06:22:03 GMT</pubDate>
            <atom:updated>2022-02-27T06:28:48.755Z</atom:updated>
            <content:encoded><![CDATA[<p>大家好，我是 FLOW 台灣技術大使 Harry，眾所周知 FLOW 上面最成功的 NFT 就是 NBA Top Shot 球員卡，所以今天想要為大家帶來 NBA Top Shot 的主合約解析，希望可以讓大家更了解這個成功的 NFT 背後合約的技術細節。</p><p>接下來我會以三個大方向切入</p><ol><li>合約架構</li><li>資料結構</li><li>常見互動</li></ol><p>以下內容假設讀者對 FLOW 的合約語法至少有初步的認識，如果是完全不了解的人，建議先前往官方文件瀏覽一下。</p><h4>合約架構</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3df56a7becd936ce88677a276f9b4ccc/href">https://medium.com/media/3df56a7becd936ce88677a276f9b4ccc/href</a></iframe><p>首先宣告合約名字為 TopShot 並且繼承官方的 NonFungibleToken 合約，Flow 跟 ETH 不一樣，原生就有推出 NFT standard 讓開發者可以直接使用</p><p>接下來則是各種 events 的宣告</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e7ccece4c01a85435493c4f75502323/href">https://medium.com/media/8e7ccece4c01a85435493c4f75502323/href</a></iframe><p>再來是各種合約內部的 variables</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/686757bbf0ef5857c1fe781b24c7b19f/href">https://medium.com/media/686757bbf0ef5857c1fe781b24c7b19f/href</a></iframe><p>各種 data structures 紀錄球員卡資訊</p><p>各種 methods 提供互動介面</p><p>跟最後的 constructor 初始化上面提到的內部 variables</p><h4>資料結構</h4><p>以下我會交叉使用一些同義詞：<br>卡片等義 moment<br>系列等義 set<br>收藏等義 collection<br>世代等義 series</p><p>相信有買過 NBA Top Shot 的朋友都知道，每張卡片有幾個重點：</p><ol><li>這張卡代表的是哪個 play？</li><li>這張卡片是出自哪個 set？</li><li>這張卡片的 serial number 是多少？</li></ol><p>所以在 contract 裡分別有不同的 data structures 儲存這些資料</p><p>Play</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/053d84051ee7afe01f7ce1dfb5ae46e3/href">https://medium.com/media/053d84051ee7afe01f7ce1dfb5ae46e3/href</a></iframe><p>Set</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e11aecc187713bddee0671e04c20bfa2/href">https://medium.com/media/e11aecc187713bddee0671e04c20bfa2/href</a></iframe><p>MomentData</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a6506ef4274ace548ba996eb3f3f91f/href">https://medium.com/media/7a6506ef4274ace548ba996eb3f3f91f/href</a></iframe><p>TopShotMomentMetadataView</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a1e52a41d456832f041bd70adeaa026/href">https://medium.com/media/5a1e52a41d456832f041bd70adeaa026/href</a></iframe><p>NFT</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b395987020650f27b037577a0d6d7b79/href">https://medium.com/media/b395987020650f27b037577a0d6d7b79/href</a></iframe><p>Collection</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc607496ae4e3426c3f024456bc999dc/href">https://medium.com/media/fc607496ae4e3426c3f024456bc999dc/href</a></iframe><p>Set</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39613fb0885cc2aee85e38ed64f391a2/href">https://medium.com/media/39613fb0885cc2aee85e38ed64f391a2/href</a></iframe><p>Admin</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed5471d30ceab413cdfcbd7b05a80897/href">https://medium.com/media/ed5471d30ceab413cdfcbd7b05a80897/href</a></iframe><p>各種可互動的 methods</p><p>基本上都非常直觀，就是存取以上解析過的 data structures，這裡就不一一贅述。</p><p>init()</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5485bb105223fd30c7f9a19e5d8d6d28/href">https://medium.com/media/5485bb105223fd30c7f9a19e5d8d6d28/href</a></iframe><h4>常見互動</h4><p>首次建立卡片收藏：</p><p>FLOW 上面的 NFT 首次購買前一定都要先做這個動作，因為有別於 Ethereum 存一個 centeralized mapping 在 ERC721 合約裡，FLOW 是真的把你的 NFT 存在你的 account storage 裡面，所以必須要先建立一個 collection 用來接收卡片 NFT 在你的帳戶裡面</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d12a62ab8dfb4b19f800a47b39429bef/href">https://medium.com/media/d12a62ab8dfb4b19f800a47b39429bef/href</a></iframe><p>管理者新增一個 play：</p><p>這裡主要就是讓大家看看 NBA Top Shot 官方要新增一個 play 時該怎麼做。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d84e887fff9f9a91955f109c7fe8642/href">https://medium.com/media/4d84e887fff9f9a91955f109c7fe8642/href</a></iframe><p>以上就是針對 NBA Top Shot 主合約的架構以及各個 data structure 及 methods 的解析，希望各位讀者都可以輕鬆理解，畢竟這個合約本身其實沒有什麼太複雜的地方，主要還是在於 FLOW 本身的語法以及 asset ownership model 跟 Ethereum 有很大的差別。</p><p>最後，若有任何問題或建議，歡迎留言，謝謝～</p><p>References:</p><ul><li><a href="https://github.com/dapperlabs/nba-smart-contracts">GitHub - dapperlabs/nba-smart-contracts: Smart contracts and transactions for Topshot, the official NBA digital collectibles game on the Flow Blockchain</a></li><li><a href="https://github.com/onflow/flow-nft">GitHub - onflow/flow-nft: The non-fungible token standard on the Flow blockchain</a></li><li><a href="https://docs.onflow.org/cadence/language/">The Cadence Programming Language</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d85cab5f208d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flow-tw/nba-top-shot-%E4%B8%BB%E5%90%88%E7%B4%84-cadence-%E8%A7%A3%E6%9E%90-d85cab5f208d">NBA Top Shot 主合約 Cadence 解析</a> was originally published in <a href="https://medium.com/flow-tw">flow_tw</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>