git.delta.rocks / unique-network / refs/commits / 0062945d0128

difftreelog

source

doc/application_development.md6.0 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##### Permissions4243-   Anyone4445##### Parameters4647-   customDataSz: Size of NFT properties data.4849##### Events5051-   CollectionCreated52    -   CollectionID: Globally unique identifier of newly created collection.53    -   Mode: Collection mode54    -   Owner: Collection owner5556#### ChangeCollectionOwner5758##### Description5960Change the owner of the collection6162##### Permissions6364-   Collection Owner6566##### Parameters6768-   CollectionId6970#### DestroyCollection7172##### Description7374DANGEROUS: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose75real money.7677##### Permissions7879-   Collection Owner8081##### Parameters8283-   CollectionId8485#### CreateItem8687##### Description8889This method creates a concrete instance of NFT Collection created with CreateCollection method.9091##### Permissions9293-   Collection Owner94-   Collection Admin9596##### Parameters9798-   CollectionID: ID of the collection99-   Properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties’ meaning, it is100    treated purely as an array of bytes101-   Owner: Address, initial owner of the NFT102103##### Events104ItemCreated105ItemId: 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.106Recipient: Address, owner of newly created item107108#### BurnItem109110##### Description111112This method destroys a concrete instance of NFT.113114##### Permissions115116-   Collection Owner117-   Collection Admin118-   Current NFT Owner119120##### Parameters121122-   CollectionID: ID of the collection123-   ItemID: ID of NFT to burn124125##### Events126127-   ItemDestroyed128    -   CollectionID129    -   ItemId: Identifier of burned NFT130131#### AddCollectionAdmin132133##### Description134135NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can136issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.137138This method adds an admin of the Collection.139140##### Permissions141142-   Collection Owner143-   Collection Admin144145##### Parameters146147-   CollectionID: ID of the Collection to add admin for148-   Admin: Address of new admin to add149150#### RemoveCollectionAdmin151152##### Description153154Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which155case only Collection Owner will be able to add an Admin.156157##### Permissions158159-   Collection Owner160-   Collection Admin161162##### Parameters163164-   CollectionID: ID of the Collection to remove admin for165-   Admin: Address of admin to remove166167### Item Ownership and Transfers168169This group of methods allows managing NFT ownership.170171#### GetOwner172173##### Description174175Return the address of the NFT owner.176177##### Permissions178179-   Anyone180181##### Parameters182183-   CollectionId184-   ItemId: ID of the NFT185186##### Returns187188Owner address189190#### BalanceOf191192##### Description193194This method is included for compatibility with ERC-721. Return the total count of NFTs of a given Collection that belong195to a given address.196197##### Permissions198199-   Anyone200201##### Parameters202203-   CollectionId204-   Address to count NFTs for205206##### Returns207208Total count of NFTs for Address209210#### Transfer211212##### Description213214Change ownership of the NFT.215216##### Permissions217218-   Collection Owner219-   Collection Admin220-   Current NFT owner221222##### Parameters223224-   Recipient: Address of token recipient225-   ClassId: ID of item class226-   ItemId: ID of the item227228#### TransferFrom229230##### Description231232Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method233executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this234owner.235236##### Permissions237238-   Collection Owner239-   Collection Admin240-   Current NFT owner241-   Address approved by current NFT owner242243##### Parameters244245-   Recipient: Address of token recipient246-   ClassId: ID of item class247-   ItemId: ID of the item248249#### Approve250251##### Description252253Set, change, or remove approved address to transfer the ownership of the NFT.254255##### Permissions256257-   Collection Owner258-   Collection Admin259-   Current NFT owner260261##### Parameters262263-   Approved: Address that is approved to transfer this NFT or zero (if needed to remove approval)264-   ClassId: ID of item class265-   ItemId: ID of the item266267#### GetApproved268269##### Description270271Get the approved address for a single NFT.272273##### Permissions274275-   Anyone276277##### Parameters278279-   ClassId: ID of item class280-   ItemId: ID of the item281282##### Returns283284Approved address