difftreelog
Add milestones 1 and 2 demo docs
in: master
3 files changed
.gitignorediffbeforeafterboth4# These are backup files generated by rustfmt4# These are backup files generated by rustfmt5**/*.rs.bk5**/*.rs.bk667.DS_Store7.DS_Store8chain-data/doc/demo_milestone1.mddiffbeforeafterboth--- /dev/null
+++ b/doc/demo_milestone1.md
@@ -0,0 +1,201 @@
+# Manual Demos
+
+Milestone 1 and 2 deliverables are marked by tag [release1](https://github.com/usetech-llc/nft_parachain/tree/release1)
+
+## Milestone 1
+
+### A running chain
+
+**Substrate based blockchain node to host NFT Tracking Module created with substrate-up scripts (currently substrate-up only support Substrate 1.0)**
+
+We have created chain based on both versions of substrate: 1 and 2. Nonetheless, the substrate 1 is not being widely used and we decided to obsolete this branch of code. The code still exists in [substrate1](https://github.com/usetech-llc/nft_parachain/tree/substrate1) branch, but this delivery document is based on substrate 2 version.
+
+The node can be run using docker container:
+```
+TBD
+```
+
+#### NFT Tracking Module
+Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics) and find "nft" in the module list. This proves that NFT module is deployed.
+
+#### Balances Module, Other modules included by default
+The [same UI](https://polkadot.js.org/apps/#/extrinsics) allows verification that all other modules are also installed as needed.
+
+#### Configuration of runtime as needed (e.g. for hot module updates)
+
+The `set_code` method worked out of the box and we did not need to perform any additional customizations to upload an updated WASM version of NFT palette.
+
+### NFT Tracking Module
+
+Before we continue, we need to do some preparations in the UI: Add NFT Data types so that the UI knows how to decode them. Go to [Settings-Developer Tab](https://polkadot.js.org/apps/#/settings/developer) and add following types to the JSON object in there:
+```
+{
+ "NftItemType": {
+ "Collection": "u64",
+ "Owner": "AccountId",
+ "Data": "Vec<u8>"
+ },
+ "CollectionType": {
+ "NextItemId": "u64",
+ "Owner": "AccountId",
+ "CustomDataSize": "u32"
+ }
+}
+```
+
+#### CreateCollection
+
+Before running test, open [chain state tab](https://polkadot.js.org/apps/#/chainstate) and read `nft`.`nextCollectionId` state variable, which shows how many collections were created so far. If you just started the chain, this should equal 0.
+
+Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics) and select ALICE account. Select `nft` module and `createCollection` method. Put 1 in `custom_data_sz` and run the transaction. After it is finalized, read the `nft`.`nextCollectionId` state variable. It will be equal 1.
+
+Also, read the state variable `nft`.`collection` with ID = 1 (Because everything in NFT Palette is numbered from 1, not from 0). You will see something like this:
+
+```
+templateModule.collection: CollectionType
+{
+ NextItemId: 0,
+ Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,
+ CustomDataSize: 1
+}
+```
+
+### ChangeCollectionOwner
+
+Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics). Select `nft` module and `changeCollectionOwner` method. First, try to execute it to change owner to BOB for collection 1 from some different account than ALICE - FERDIE to see that it is not possible because ALICE owns collection 1 and FERDIE is not allowed to give it to BOB. Second, select ALICE as transaction signer and run it again. This time the collection owner changes, which will be reflected if you read the state variable `nft`.`collection` with ID = 1:
+
+```
+templateModule.collection: CollectionType
+{
+ NextItemId: 0,
+ Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,
+ CustomDataSize: 1
+}
+```
+
+Change the ownership back to ALICE to continue with this demo.
+
+### DestroyCollection
+
+**Note: Before destroying collection, you can see Milestone 2 deliverables to avoid creating collection again**
+
+Run `nft`.`destroyCollection` with collection ID = 1, and then read collection from state. The returned fields will have default values, which indicates that collection does not exsit anymore:
+```
+{
+ NextItemId: 0,
+ Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,
+ CustomDataSize: 0
+}
+```
+
+### End user documentation
+
+See [application_development.md][doc/application_development.md]
+
+### Docker images for running deliverables for acceptance
+
+**Substrate Node (in dev mode), Unit tests for NFT Module**
+
+See above, the unit tests are run before the node starts within the same image.
+
+### Acceptance instructions
+
+**using Polkadot UI from https://substrate-ui.parity.io/**
+
+This document, except we are using Substrate v2, so we can use the newer version of the UI: https://polkadot.js.org/apps/#
+
+## Milestone 2
+### NFT Tracking Module
+**Note:** If you have destroyed collection, create it again using `nft`.`createCollection` method.
+
+**Note 2:** The order of items in this section is different from the original spec to make the acceptance workflow more natural.
+
+If you did not destroy collection while looking at Milestone 1 deliverables, use collection ID 1 in the further examples, otherwise use collection ID = 2.
+
+#### CreateItem
+Before creating an NFT item, let's read ALICE balance for your collection, which indicates how many NFT tokens ALICE owns in this collection. Read the chain state `nft`.`balance(<Collection ID>, ALICE)`, and it will be 0.
+
+Execute extrinsic `nft`.`createItem` from ALICE account. Set properties to `0x01`. Now if you read the chain state `nft`.`balance(<Collection ID>, ALICE)`, it will be equal to 1. Also, you can read chain state `nft`.`itemList(<Collection ID>, 1)`, and it will return data for the token 1:
+
+```
+templateModule.itemList: NftItemType
+{
+ Collection: 1,
+ Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,
+ Data: 0x01
+}
+```
+
+#### GetOwner
+Reading the ownership is done by reading chainstate `nft`.`itemList(<Collection ID>, 1)`. One of the returned fields is Owner:
+```
+templateModule.itemList: NftItemType
+{
+ Collection: 1,
+ Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,
+ Data: 0x01
+}
+```
+
+#### Transfer
+Execute `nft`.`transfer` from ALICE address to transfer token 1 to BOB and check the ownership again:
+```
+templateModule.itemList: NftItemType
+{
+ Collection: 1,
+ Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,
+ Data: 0x01
+}
+```
+
+Transfer the token 1 back to ALICE to enable further demo actions.
+
+#### BalanceOf
+
+Read the chain state `nft`.`balance` for ALICE address and see that she owns 1 token:
+```
+templateModule.balance: u64
+1
+```
+
+#### AddCollectionAdmin
+Execute `nft`.`AddCollectionAdmin` from ALICE account and let CHARLIE be an admin. Now you can see that CHARLIE can transfer ALICE's token from ALICE's account to EVE and back. Also, you can read admin list from chain state and see that it is not empty:
+
+```
+templateModule.adminList: Vec<AccountId>
+[
+ 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y
+]
+```
+
+#### RemoveCollectionAdmin
+Execute `nft`.`RemoveCollectionAdmin` from ALICE account to remove CHARLIE from admins. Now you can see that CHARLIE cannot transfer ALICE's tokens anymore. If you read the chan state `nft`.`adminList`, the response will be empty:
+
+```
+templateModule.adminList: Vec<AccountId>
+[]
+```
+
+#### BurnItem
+Execute `nft`.`burnItem` from ALICE account to burn token 1, and then read the chain state `nft`.`itemList(<Collection ID>, 1)`. This time the chain state returns default values in fields because token does not exist anymore. You can also check ALICE balance in chain state, now it is equal 0 again.
+```
+templateModule.itemList: NftItemType
+{
+ Collection: 0,
+ Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,
+ Data: 0x
+}
+```
+
+### Economic Model Specification
+[Economic Model Specification](doc/economic_model.md)
+
+### Contracts Module Specification
+https://docs.google.com/document/d/1gDtYjPR9C1VZChxEA-xAdQWQyEvMg245XrZR_MpE3cg/edit?usp=sharing
+
+### Bonus goal
+
+**Basic demo - Cryptopunks representation on the Substrate Chain.**
+
+See this repo, it has running and playing instructions:
+https://github.com/usetech-llc/substrapunks
doc/economic_model.mddiffbeforeafterboth--- /dev/null
+++ b/doc/economic_model.md
@@ -0,0 +1,100 @@
+# Economic Model
+
+## Economy Goals
+
+One of the goals of this specification is to find means to provide for network infrastructure (incentivisation of validators) and development support for NFT Parachain. Transaction fees will be used as the main source of funds. Fees will be distributed among network participants. The distribution of fees will depend on validator contribution to the network (similarly to Polkadot network) and the chosen fee structure (model).
+
+## Summary
+
+We are going to offer several fee models for our users. Some models will be implemented immediately, some will wait until there is a demand.
+
+The fee models are setup by Collection. Every Collection has a fee model assigned to it, which determines how collection transactions are paid. Network users can choose the fee model that better suits their application. The Collection fee model can be changed later as well.
+
+Initially we offer 4 models for consideration:
+
+* User paid fees
+* Pay as you go
+* Prepaid plan
+* Resource purchase
+
+## Token and Accounts
+
+Network Tokens are tracked via standard Balances module, which is included in NFT Parachain.
+
+User Account matches to user address in the network. Among other properties user Account has Balance, which will be used later on.
+
+## Changing Fee Model
+
+The dedicated module call will be added to allow updating fee structure for the collection.
+
+### SelectFeeModel Call
+
+#### Description
+
+Select fee model for a given collection.
+
+#### Permissions
+
+* Collection Owner
+* Collection Admin
+
+#### Parameters
+
+* Collection ID
+* Fee Model ID
+
+## User Paid Fees
+
+This is conventional fee model, when every Account pais for the transactions they sign and send. Transaction fee will gradually increase if the network load is higher to prevent denial of service. The same type of transaction (with the same transaction weight) will result in higher fee if previous block's weight gets close to maximum block weight. The ratio for multiplying fees will be determined empirically. The multiplication will take place until the blocks stop overpopulating, but with certain saturation. If blocks underfill, i.e. block weight is under the certain threshold, then the next block will have lower fees. The lowering will continue until blocks stop underpopulating, with some saturation.
+
+Each module call will have weight annotation that will determine the weight calculation for this call:
+
+* CreateCollection: Fixed
+* ChangeCollectionOwner: Fixed
+* DestroyCollection: Linear of number of items multiplied by Collection Data Size
+* CreateItem: Linear of Collection Data Size
+* BurnItem: Linear of Collection Data Size
+* AddCollectionAdmin: Fixed
+* RemoveCollectionAdmin: Fixed
+* GetOwner: None
+* BalanceOf: None
+* Transfer: Fixed
+
+This model is default and will be set for each collection until collection owner decides to change it to some other model.
+
+
+### Fee Distribution
+
+The network owner will reserve some fixed percentage of fees, and the rest will be distributed among validators proportionally to their contribution to the network.
+
+
+## Pay As You Go
+
+The only difference from User Paid Fees model is that collection owner will be paying for their users. The collection owner must have enough balance on his account in order to pay for user transactions. If balances goes lower than needed, the model is temporarily switched to "User Paid Fees".
+
+
+### Fee Distribution
+
+Same as in User Paid Fees.
+
+
+## Prepaid Plan
+
+Collection Owner makes regular payments to prepay for some planned network load, i.e. some fixed number of transactions, created items, etc.
+
+
+### Fee Distribution
+
+Same as in User Paid Fees.
+
+
+## Resource Purchase
+
+Collection Owner purchases some fixed amount of network resource, which can be measured in number of users and their monthly transactions, for example. This is a one time payment. If Collection Owner decides to switch to a different fee model, the resources may be sold back to the system (with some commission).
+
+Received funds will be converted to DOTs and used in staking (nomination or validation), which will allow to receive the income that will pay for infrastructure and development support.
+
+### Fee Distribution
+
+Fixed percentage of staking income is distributed between validators proportionally to their contribution to the network. The rest is credited to the network owner.
+