git.delta.rocks / unique-network / refs/commits / 708aba4e2741

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 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## Custom Types for JS API2021See in root README2223## NFT Palette Methods2425### Collection Management2627#### CreateCollection2829##### Description30This 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.3132##### Permissions33Anyone3435##### Parameters36customDataSz: Size of NFT properties data.3738##### Events39CollectionCreated40CollectionID: Globally unique identifier of newly created collection.41Owner: Collection owner4243#### ChangeCollectionOwner4445##### Description46Change the owner of the collection4748##### Permissions49Collection Owner5051##### Parameters52CollectionId5354#### DestroyCollection5556##### Description57DANGEROUS: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.5859##### Permissions60Collection Owner6162##### Parameters63CollectionId6465#### CreateItem6667##### Description68This method creates a concrete instance of NFT Collection created with CreateCollection method.6970##### Permissions71Collection Owner72Collection Admin7374##### Parameters75CollectionID: ID of the collection76Properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties’ meaning, it is treated purely as an array of bytes77Owner: Address, initial owner of the NFT7879##### Events80ItemCreated81ItemId: 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.8283#### BurnItem8485##### Description86This method destroys a concrete instance of NFT.8788##### Permissions89Collection Owner90Collection Admin91Current NFT Owner9293##### Parameters94CollectionID: ID of the collection95ItemID: ID of NFT to burn9697##### Events98ItemDestroyed99CollectionID100ItemId: Identifier of burned NFT101102103#### AddCollectionAdmin104105##### Description106NFT 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.107108This method adds an admin of the Collection.109110##### Permissions111Collection Owner112Collection Admin113114##### Parameters115CollectionID: ID of the Collection to add admin for116Admin: Address of new admin to add117118#### RemoveCollectionAdmin119120##### Description121Remove 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.122123##### Permissions124Collection Owner125Collection Admin126127##### Parameters128CollectionID: ID of the Collection to remove admin for129Admin: Address of admin to remove130131### Item Ownership and Transfers132This group of methods allows managing NFT ownership.133134#### GetOwner135136##### Description137Return the address of the NFT owner. 138139##### Permissions140Anyone141142##### Parameters143CollectionId144ItemId: ID of the NFT145146##### Returns147Owner address148149#### BalanceOf150151##### Description152This method is included for compatibility with ERC-721. Return the total count of NFTs of a given Collection that belong to a given address. 153154##### Permissions155Anyone156157##### Parameters158CollectionId159Address to count NFTs for160161##### Returns162Total count of NFTs for Address163164165#### Transfer166167##### Description168Change ownership of the NFT.169170##### Permissions171Collection Owner172Collection Admin173Current NFT owner174175##### Parameters176Recipient: Address of token recipient177ClassId: ID of item class178ItemId: ID of the item179180#### TransferFrom181182##### Description183Change 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.184185##### Permissions186Collection Owner187Collection Admin188Current NFT owner189Address approved by current NFT owner190191##### Parameters192Recipient: Address of token recipient193ClassId: ID of item class194ItemId: ID of the item195196197#### Approve198199##### Description200Set, change, or remove approved address to transfer the ownership of the NFT.201202##### Permissions203Collection Owner204Collection Admin205Current NFT owner206207##### Parameters208Approved: Address that is approved to transfer this NFT or zero (if needed to remove approval)209ClassId: ID of item class210ItemId: ID of the item211212#### GetApproved213214##### Description215Get the approved address for a single NFT.216217##### Permissions218Anyone219220##### Parameters221ClassId: ID of item class222ItemId: ID of the item223224##### Returns225Approved address