git.delta.rocks / unique-network / refs/commits / 01e8d02674b7

difftreelog

Add walk-through instructions (without white lists so far)

Greg Zaitsev2020-08-13parent: #dd359b9.patch.diff
in: master

1 file changed

modifieddoc/hackusama_walk_through.mddiffbeforeafterboth
22
3This document walks through all Hackusama deliverables made in relation to NFT Blockchain submission.3This document walks through all Hackusama deliverables made in relation to NFT Blockchain submission.
44
5## Updates to NFT Parachain
6
7### Deployed NFT TestNet
8
9The TestNet public node is avaiable at wss://unique.usetech.com. It is easy to verify that it functions with the standard AppsUI:
10
111. Open the [Apps UI](https://polkadot.js.org/apps/#)
122. Click on the network icon in the top left corner
133. Scroll down the list and input `wss://unique.usetech.com` under "custom endpoint"
144. After connection is established, copy these [UI Custom Types](https://github.com/usetech-llc/nft_parachain#ui-custom-types) and paste them in [Developer Settings](https://polkadot.js.org/apps/#/settings/developer). Hit "Save" button.
155. Now the NFT node is connected with AppsUI.
166. Go to [Chain State](https://polkadot.js.org/apps/#/chainstate) and verify that NFT pallet is visible and you can read information from it.
177. For example, select nft -> collection, and enter collection ID 4 (for SubstraPunks) and click "+" button. You will see the collection properties such as UTF-16 encoded collection name and description, UTF-8 encoded token prefix, the size of custom data, etc.
18
19#### Getting some Unique Tokens
20
211. Install Polkadot{.js} extension if you don't have it already installed. Here are the links for [Chrome](https://chrome.google.com/webstore/detail/polkadot%7Bjs%7D-extension/mopnmbcafieddcagagdcbnhejhlodfdd) and [Firefox](https://addons.mozilla.org/en-US/firefox/addon/polkadot-js-extension/) extensions.
222. Create an address
233. Contact us at [Unique Network Telegram channel](https://t.me/joinchat/DPVt1RwN50Uic_Q9lFcg9A) in order to get some Unique token and some Re-Fungible tokens.
24
25### Smart Contracts Pallet
26
271. Open [Contracts](https://polkadot.js.org/apps/#/contracts) tab. It only appears in the UI when Smart Contracts pallet is included in the runtime.
282. Additionally, we can find an existing smart contract. Click on "Add an existing contract" link.
293. Input this contract address: `5GdNqKMv4Sszq3SRd3TkXNa6a9ct4D3nXvtTWTFR7rTyccVJ`
304. Input any contract name, for example `Claim Substrapunks`
315. Download and drag-and-drop this [metadata.json](https://github.com/usetech-llc/substrapunks/releases/download/v1.0.2/metadata.json) file into contract ABI field.
326. Click Save. The contract appears in the page. If the contract did not exist at that address, the UI would display an error message: "Unable to find deployed contract code at the specified address".
33
34### Integration Between Smart Contracts and NFT Pallet
35
36This was one of the most challenging parts of the Hackusama for us. The pre-RC4 versions of Substrate did not function properly when we tried to use `ext_dispatch_call` to dispatch a runtime call to NFT pallet from Contracts pallet, and RC4 had the `ext_dispatch_call` already removed to "free space" for some friendlier way of interaction between pallets, that was not yet implemented. Thanks to Alexander Theißen who reverted the removal of `ext_dispatch_call` and created a special branch based on RC4 for us!
37
38The smart contract source code exists in this [repository folder](https://github.com/usetech-llc/nft_parachain/tree/master/smart_contract/ink-types-node-runtime), but the best way to test how the interaction between smart contracts and NFT pallet works is to see it in action using the [SubstraPunks Game Example](https://ipfs-gateway.usetech.com/ipns/QmaMtDqE9nhMX9RQLTpaCboqg7bqkb6Gi67iCKMe8NDpCE/) that uses smart contract to claim free characters. The complete demo of this game will come later, so please bare with us and let's put this item demonstration for a bit later.
39
40### Re-Fungibility support
41
42This feature is best demonstrated in action using our NFT wallet. First, you need to have some Unique and Re-Fungible tokens. [This section](#getting-some-unique-tokens) tells how to get them.
43
441. Open the [NFT Wallet](https://uniqueapps.usetech.com/#/nft)
452. Search for collection called "Artwork". Search can be done either by collection name or collection ID (which is 2).
463. Click on "+ Add collection" in search results. The collection will appear under "My collections"
474. Expand the "Artwork" collection and see that you own a token with a partial balance
485. Transfer the token to some other address: Click "Transfer token" and enter address and the amount. Amount should be entered as decimal fraction. For example "0.01" to transfer 1/100th part of the token.
496. Observe that your balance decreased by the amount you entered.
50
51#### The Hard Way
52
53Also, the Re-Fungible support can be demonstrated using the standard UI features without NFT wallet.
54
551. Open [Chain State](https://uniqueapps.usetech.com/#/chainstate).
562. Select "nft" - "reFungbleItemList"
573. Enter parameters: 2 and 1, click "+" button
584. Observe the following data structure returned:
59
60```
61{
62 Collection: 2,
63 Owner: [
64 {
65 owner: 5FNujvbtMyKoJC2zTrfGVaQek7jhfR1L558BMhogfFfD7veH,
66 fraction: 3,000
67 },
68 {
69 owner: 5D73wtH5pqN99auP4b6KQRQAbketaSj4StkBJxACPBUAUdiq,
70 fraction: 3,000
71 },
72 {
73 owner: 5FZeTmbZQZsJcyEevjGVK1HHkcKfWBYxWpbgEffQ2M1SqAnP,
74 fraction: 2,000
75 },
76 {
77 owner: 5EnzEXBuxFHdymceAAtstym8FETQqH4inx29XJSP6uHaCUiP,
78 fraction: 1,000
79 },
80 {
81 owner: 5GU6iHnc3qTMaufmKYzHUpDmVN2CgzA2JMcGFQLcKNDbE7c6,
82 fraction: 1,000
83 }
84 ],
85 Data:
86}
87```
88
89The Owner field contains a list of owners with the fractions they own. The fractions are represented as fixed point decimals. The number of decimal points in this fraction is determined by collection properties. For example, in the Artwork collection this property is equal to 4. The owned fraction is then determined as `fraction` divided by 10^DecimalPoints, i.e. 10,000 in this case.
90
915. Staying in Chain State, select "nft" - "colection"
926. Input "2" and click "+"
937. Observe the following structure returned. It tells that collection is ReFungible and DecimalPoints field is equal to 4.
94
95```
96{
97 Owner: 5FNujvbtMyKoJC2zTrfGVaQek7jhfR1L558BMhogfFfD7veH,
98 Mode: {
99 ReFungible: [
100 0,
101 4
102 ]
103 },
104 Access: 0,
105 DecimalPoints: 4,
106 Name: [
107...
108```
109
110### Off-Chain Schema to store token image URLs
111
112This feature is best demonstrated in action using our NFT wallet. First, you need to have some Unique and Re-Fungible tokens. [This section](#getting-some-unique-tokens) tells how to get them.
113
1141. Open the [NFT Wallet](https://uniqueapps.usetech.com/#/nft)
1152. Search for collection called "Artwork". Search can be done either by collection name or collection ID (which is 2).
1163. Expand "Artwork" collection
1174. Click on the image to zoom in.
1185. Right-click on the image and select "Open Image in New Tab"
1196. Note the image URL:
120```
121https://ipfs-gateway.usetech.com/ipfs/QmUSv64cUmL2m44QYkUFWmH89qykC8VLPFwjhpeAScjejS/image1.jpg
122```
1237. Open [Chain State](https://uniqueapps.usetech.com/#/chainstate).
1248. Select "nft" - "colection"
1259. Input "2" and click "+"
12610. Scroll down:
127```
128 ],
129 TokenPrefix: ARTu0000,
130 CustomDataSize: 0,
131 OffchainSchema: https://ipfs-gateway.usetech.com/ipfs/QmUSv64cUmL2m44QYkUFWmH89qykC8VLPFwjhpeAScjejS/image{id}.jpg,
132 Sponsor: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,
133 UnconfirmedSponsor: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM
134}
135```
13611. Observe the field called `OffchainSchema`. This field defines the URL schema that is used to contruct token URLs based on the token ID. In this particular example, the {id} template variable is replaced with token id 1, which results in the proper image URL.
137
138### New economic models
139
140This feature is best demonstrated when you own a SubstraPunk character. Please proceed with the demonstration, and then come back after you claim one.
141
1421. Create a new address in Polkadot{.js} extension. We need an address that has zero balance in Unique tokens. Let's call it "ZERO BALANCE" address.
1432. Open the [NFT Wallet](https://uniqueapps.usetech.com/#/nft)
1443. Search for collection called "SubstraPunks" (partial search also works, so you can just type "punk" and hit Enter)
1454. Add collection
1465. Expand substrapunks collection and transfer your PNK token to your "ZERO BALANCE" address.
1476. Now select your "ZERO BALANCE" address in the drop-down list and repeat searching and adding the collection for this address.
1487. Transfer token back to your main address. Observe that despite the zero balance, the transfer is successful.
149
150## NFT Wallet
151
152All features of the NFT Wallet were already demonstrated previously:
153
154* Enables adding favorite collections
155* Shows tokens owned
156* Allows NFT and Re-Fungible transfers
157* Shows Re-Fungible Balances
158* Shows Token Images
159
160## Our version of AppsUI
161
162The UI was also mainly demonstrated. We only need to show some configuration that happens behind the scenes:
163
164### Loads appropriate custom API types
1651. Open the [NFT Wallet Developer Settings](https://uniqueapps.usetech.com/#/settings/developer)
1662. Observe that Custom UI types are already in place
167
168### Defaults to NFT TestNet
169
1701. Open the [NFT Wallet](https://uniqueapps.usetech.com/)
1712. Observe that Unique Network icon appears in the left top corner without a need to specify the network
1723. Click on Unique Network icon and see that `NFT Testnet` is in the network list
173
174## Unity API and SDK PoC
175
176In order to see Unity Asset in action, please follow the instructions in this README file:
177
178https://github.com/usetech-llc/nft_unity/blob/master/src/DemoApplication/readme.md
179
180
181## SubstraPunks Game
182
183First, you will need some Unique balance. [This section](#getting-some-unique-tokens) tells how to get the TestNet currency.
184
1851. Open this [SubstraPunks Game](https://ipfs-gateway.usetech.com/ipns/QmaMtDqE9nhMX9RQLTpaCboqg7bqkb6Gi67iCKMe8NDpCE/) IPFS link
1862. Find a character you like that still has red background. Red indicates that the character was not yet claimed by anyone.
1873. Allow access for Polkadot{.js} to this site
1884. Click "Claim" button
1895. Select the account that has some Unique balance
1906. Click "Claim" again, sign transaction, and wait until it mines.
191
192Let's make a pause here: You were just demonstrated how the integration between smart contracts and NFT Pallet works. This is what we've been previously talking about [here](#integration-between-smart-contracts-and-nft-pallet)
193
194The source code of the generic smart contract is located in [smart_contract](https://github.com/usetech-llc/nft_parachain/tree/dev/smart_contract/ink-types-node-runtime) folder. But to demonstrate smart contracts in practice we created additional [Claim Contract](https://github.com/usetech-llc/substrapunks/tree/master/smart_contract) to implement claiming functionality in this game.
195
196Here is how Claiming works: Claim Contract owns all characters in the game initially. Player sends a transaction calling the method claim:
197```
198fn claim(&mut self, collection_id: u64, item_id: u64, new_owner: AccountId)
199```
200
201Inside the method `claim` there is a call made to NFT pallet to transfer the token that is being claimed to the player:
202```
203runtime_calls::transfer(collection_id, item_id, new_owner);
204```
205
2067. Follow the link to [NFT Wallet](https://uniqueapps.usetech.com/#/nft)
2078. Search for "SubstraPunks" collection, add it
2089. Expand the collection and find your character in there!
20910. Now you can try transfers and test the [economic model](#new-economic-models), the last thing we put off until a SubstraPunks character is claimed.
5210
211
212