git.delta.rocks / unique-network / refs/commits / 31df97788a92

difftreelog

source

doc/application_development.md5.5 KiBsourcehistory
1# Building an NFT Application23## Architecture45Both centralized and serverless architectures are supported and application creator can decide which one to use depending on how much logic and data they intend to manage off-chain and off-line.67### Server-based architecture89In server-based architecture the application creator manually creates NFT collections and authorizes server to perform operations on each collection. See NFT palette methods that have admin permission level to understand better what server (or administrators) can do.1011![](server_architecture.png)1213### Serverless architecture1415In serverless architecture the application creator does all initialization and token distribution manually. Alternatively, smart contracts may be used in order to implement some distribution mechanics such as token sales or claiming. The dApp has access to all properties of an NFT token, but it does not have any elevated permissions, since it resides on user site. All operations happen on user's behalf signed by user's private key.1617![](serverless_architecture.png)1819## NFT Palette Methods2021### Collection Management2223#### CreateCollection2425##### Description26This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner and admin of the collection are set to the address that signed the transaction. Both addresses can be changed later.2728##### Permissions29Anyone3031##### Parameters32customDataSz: Size of NFT properties data.3334##### Events35CollectionCreated36CollectionID: Globally unique identifier of newly created collection.37Owner: Collection owner3839#### ChangeCollectionOwner4041##### Description42Change the owner of the collection4344##### Permissions45Collection Owner4647##### Parameters48CollectionId4950#### DestroyCollection5152##### Description53DANGEROUS: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.5455##### Permissions56Collection Owner5758##### Parameters59CollectionId6061#### CreateItem6263##### Description64This method creates a concrete instance of NFT Collection created with CreateCollection method.6566##### Permissions67Collection Owner68Collection Admin6970##### Parameters71CollectionID: ID of the collection72Properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties’ meaning, it is treated purely as an array of bytes73Owner: Address, initial owner of the NFT7475##### Events76ItemCreated77ItemId: Identifier of newly created NFT, which is unique within the Collection, so the NFT is uniquely identified with a pair of values: CollectionId and ItemId.7879#### BurnItem8081##### Description82This method destroys a concrete instance of NFT.8384##### Permissions85Collection Owner86Collection Admin87Current NFT Owner8889##### Parameters90CollectionID: ID of the collection91ItemID: ID of NFT to burn9293##### Events94ItemDestroyed95CollectionID96ItemId: Identifier of burned NFT979899#### AddCollectionAdmin100101##### Description102NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.103104This method adds an admin of the Collection.105106##### Permissions107Collection Owner108Collection Admin109110##### Parameters111CollectionID: ID of the Collection to add admin for112Admin: Address of new admin to add113114#### RemoveCollectionAdmin115116##### Description117Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.118119##### Permissions120Collection Owner121Collection Admin122123##### Parameters124CollectionID: ID of the Collection to remove admin for125Admin: Address of admin to remove126127### Item Ownership and Transfers128This group of methods allows managing NFT ownership.129130#### GetOwner131132##### Description133Return the address of the NFT owner. 134135##### Permissions136Anyone137138##### Parameters139CollectionId140ItemId: ID of the NFT141142##### Returns143Owner address144145#### BalanceOf146147##### Description148This method is included for compatibility with ERC-721. Return the total count of NFTs of a given Collection that belong to a given address. 149150##### Permissions151Anyone152153##### Parameters154CollectionId155Address to count NFTs for156157##### Returns158Total count of NFTs for Address159160161#### Transfer162163##### Description164Change ownership of the NFT.165166##### Permissions167Collection Owner168Collection Admin169Current NFT owner170171##### Parameters172Recipient: Address of token recipient173ClassId: ID of item class174ItemId: ID of the item175176#### TransferFrom177178##### Description179Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.180181##### Permissions182Collection Owner183Collection Admin184Current NFT owner185Address approved by current NFT owner186187##### Parameters188Recipient: Address of token recipient189ClassId: ID of item class190ItemId: ID of the item191192193#### Approve194195##### Description196Set, change, or remove approved address to transfer the ownership of the NFT.197198##### Permissions199Collection Owner200Collection Admin201Current NFT owner202203##### Parameters204Approved: Address that is approved to transfer this NFT or zero (if needed to remove approval)205ClassId: ID of item class206ItemId: ID of the item207208#### GetApproved209210##### Description211Get the approved address for a single NFT.212213##### Permissions214Anyone215216##### Parameters217ClassId: ID of item class218ItemId: ID of the item219220##### Returns221Approved address