git.delta.rocks / unique-network / refs/commits / f847a9e5e48e

difftreelog

source

doc/application_development.md5.6 KiBsourcehistory
1# Building an NFT Application23## Architecture45Both centralized and serverless architectures are supported and application creator can decide which one to use6depending on how much logic and data they intend to manage off-chain and off-line.78### Server-based architecture910In server-based architecture the application creator manually creates NFT collections and authorizes server to perform11operations on each collection. See NFT palette methods that have admin permission level to understand better what server12(or administrators) can do.1314![](server_architecture.png)1516### Serverless architecture1718In serverless architecture the application creator does all initialization and token distribution manually.19Alternatively, smart contracts may be used in order to implement some distribution mechanics such as token sales or20claiming. The dApp has access to all properties of an NFT token, but it does not have any elevated permissions, since it21resides on user site. All operations happen on user's behalf signed by user's private key.2223![](serverless_architecture.png)2425## Custom Types for JS API2627See in root README2829## NFT Palette Methods3031### Collection Management3233#### CreateCollection3435##### Description3637This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of38certain length. The initial owner and admin of the collection are set to the address that signed the transaction. Both39addresses can be changed later.4041##### Permissions4243Anyone4445##### Parameters4647customDataSz: Size of NFT properties data.4849##### Events5051CollectionCreated CollectionID: Globally unique identifier of newly created collection. Owner: Collection owner5253#### ChangeCollectionOwner5455##### Description5657Change the owner of the collection5859##### Permissions6061Collection Owner6263##### Parameters6465CollectionId6667#### DestroyCollection6869##### Description7071DANGEROUS: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose72real money.7374##### Permissions7576Collection Owner7778##### Parameters7980CollectionId8182#### CreateItem8384##### Description8586This method creates a concrete instance of NFT Collection created with CreateCollection method.8788##### Permissions8990Collection Owner Collection Admin9192##### Parameters9394CollectionID: ID of the collection Properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic95of properties’ meaning, it is treated purely as an array of bytes Owner: Address, initial owner of the NFT9697##### Events9899ItemCreated ItemId: Identifier of newly created NFT, which is unique within the Collection, so the NFT is uniquely100identified with a pair of values: CollectionId and ItemId.101102#### BurnItem103104##### Description105106This method destroys a concrete instance of NFT.107108##### Permissions109110Collection Owner Collection Admin Current NFT Owner111112##### Parameters113114CollectionID: ID of the collection ItemID: ID of NFT to burn115116##### Events117118ItemDestroyed CollectionID ItemId: Identifier of burned NFT119120#### AddCollectionAdmin121122##### Description123124NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can125issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.126127This method adds an admin of the Collection.128129##### Permissions130131Collection Owner Collection Admin132133##### Parameters134135CollectionID: ID of the Collection to add admin for Admin: Address of new admin to add136137#### RemoveCollectionAdmin138139##### Description140141Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which142case only Collection Owner will be able to add an Admin.143144##### Permissions145146Collection Owner Collection Admin147148##### Parameters149150CollectionID: ID of the Collection to remove admin for Admin: Address of admin to remove151152### Item Ownership and Transfers153154This group of methods allows managing NFT ownership.155156#### GetOwner157158##### Description159160Return the address of the NFT owner.161162##### Permissions163164Anyone165166##### Parameters167168CollectionId ItemId: ID of the NFT169170##### Returns171172Owner address173174#### BalanceOf175176##### Description177178This method is included for compatibility with ERC-721. Return the total count of NFTs of a given Collection that belong179to a given address.180181##### Permissions182183Anyone184185##### Parameters186187CollectionId Address to count NFTs for188189##### Returns190191Total count of NFTs for Address192193#### Transfer194195##### Description196197Change ownership of the NFT.198199##### Permissions200201Collection Owner Collection Admin Current NFT owner202203##### Parameters204205Recipient: Address of token recipient ClassId: ID of item class ItemId: ID of the item206207#### TransferFrom208209##### Description210211Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method212executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this213owner.214215##### Permissions216217Collection Owner Collection Admin Current NFT owner Address approved by current NFT owner218219##### Parameters220221Recipient: Address of token recipient ClassId: ID of item class ItemId: ID of the item222223#### Approve224225##### Description226227Set, change, or remove approved address to transfer the ownership of the NFT.228229##### Permissions230231Collection Owner Collection Admin Current NFT owner232233##### Parameters234235Approved: Address that is approved to transfer this NFT or zero (if needed to remove approval) ClassId: ID of item class236ItemId: ID of the item237238#### GetApproved239240##### Description241242Get the approved address for a single NFT.243244##### Permissions245246Anyone247248##### Parameters249250ClassId: ID of item class ItemId: ID of the item251252##### Returns253254Approved address