Skip to content

NFTKred/Kred-NFT-Documentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 

Repository files navigation

Building an App With the Kred NFT API

This guide shows how you build your own app using the Kred NFT API.

Home Page

Our home view is the Explore tab. We've created this with three calls to the /coins method, sorting respectively by likes, creation date, and circulation. Each of these calls can be paginated, so that the groups of coins are bound to individual carousels and can be browsed by the user.

The Marketplace tab is created using a single call to a specialised method /marketplace. This call merges, filters, and sorts active sales and auctions to present a single unified view. We use pagination again to provide infinite scroll, preloading pages on desktop to ensure smooth loading of additional coins.

The Collection tab shows the user's own collection of coins - coins they have created, bought at sale or auction, claimed from giveaways, been gifted by other users. This view is another call to /coins, simply specifying the user, and supporting infinite scroll.

The same call can be used to embed the user's collection in other pages - their Engagement Profile, blog, or other home page.

The Newsfeed tab combines several functions: A feed of coin activity related to the user - coins created, requests from other users, coins received and sent, sold and auctioned. This is provided by the /messages call, requesting the user's timeline. The /messages call can also be used to view messages relating to any single coin (or batch of coins if the coins are in a mesh network).

The Pending widget uses /remind to list reminders for actions started but not yet complete.

The Search Contact widget uses the SocialOS Contact API (documented separately).



Batches and Coins

Clicking on a coin that is part of a batch brings up the batch view. We use the batched parameter in /coins and /marketplace to show a single entry for each batch along with the number of coins available (total in the Explore tab, and just the number on sale in the Marketplace tab).

From the batch view we can edit certain details for all coins in the batch:

Add and edit tags using /tag Hide or show the coins using /hide and /show Make the coins private or public using /private and /public Showcase the coins (if the user has showcase privileges) using /showcase and /unshowcase Update metadata such as the coin description and link using /meta

Specifying the batch on these API calls allows you to update all the coins in the batch that you own.

We can give a coin from this screen, either directly to an on-platform user using /send or to any user via Email, SMS, or Twitter using /hold.

/hold uses a two-step processes, reserving the coin, creating a secure code, and notifying the recipient via the designated method. The recipient can then log in to the app, which will use the /claim method to accept the sent coin.

Clicking on an individual coin brings up the coin popup using /coin and /messages. We can see the full version of the coin images here, and play videos if it's a video coin, and add comments to the message stream using /comment

The image viewer can show the front and back images in full, play videos, and also show images included in the coin metadata. No separate call is needed to retrieve metadata; it is automatically included in every call that returns coin details.

Clicking on the More button brings up a dedicated coin screen. The coin is retrieved by a single call to /coin.

The coin carousel at the top of the page is generated by a call to /coins for the wallet containing the specified coin. The client code find the current coin in this list and uses that to center the carousel on the right coin.

The message stream is again retrieved by a call to /messages.

We have additional buttons to auction, sell, and give coins using /auction, /sell, and /hold or /send respectively.

We can modify coin tags, settings, and metadata just as we do with batches, simply by specifying a coin parameter in place of the batch parameter.

Add and edit tags using /tag Hide or show the coin using /hide and /show Make the coin private or public using /private and /public Showcase the coin (if the user has showcase privileges) using /showcase and /unshowcase Update metadata such as the coin description and link using /meta

You can generate a public giveaway URL /giveaway or a code for use requests /request.



Designing and Minting Coins

From the menu, we can select Create a Coin to start the design and mint application flow.

This brings up the coin designer.

We use a JavaScript library to crop and scale the uploaded images at the client, to avoid direct uploads of very large images.

The design tool allows users to set the name, images, colours, and background pattern of the coin, set the value of the coin and the number of coins in the batch, and choose whether each coin in the batch has its own message stream, or if all coins are combined in a mesh. Coins can also be marked as private and/or NSFW at this point.

These parameters are passed to /draft or /mint to either save the design or mint the coin.

The design is rendered immediately using SVG.

Users can also specify royalties to be accumulated each time a coin is sold. These are calculated as a percentage of the sale price. Royalty collection takes place automatically once configured with the /royalties method.

By saving the coin using the /draft method the design is stored without immediately creating a coin, and the details are saved for retrieval by the /drafts method. Users can page through existing designs, modify them using the coin designer, and save them again using /draft or mint a coin using /mint.

Users can add metadata to coins that is included with every API call that returns coin data. Unlike key data (the name, appearance, and value of the coin) which is bound to the blockchain, metadata can be updated at any time via the /meta call.

Additional coin types can be defined with different sets of metadata fields. These can be simply informative, as in the case of an artist coin intended to showcase an artist's work.

Or they can be active fields such as one-time redeemable offers in marketing campaigns. These can be implemented using callbacks.

When a coin is minted, it is immediately listed on the blockchain. With Stellar, this only takes around five seconds, and multiple coins can be batched and listed simultaneously.

When minting a coin to the Stellar network - and with all Stellar operations - the API will wait for confirmation from Stellar before returning. If the operation cannot be completed (insufficient funds, for example, or an issue with the network itself) the API will return an appropriate error status and no transaction will take place.

When operating on the Ethereum network, transactions are recorded first in the local database, and then submitted to the blockchain and monitored for success. The API will return immediately and note the details of the transaction in progress.

A coin with an incomplete Ethereum transaction pending will have the transaction details included with the coin data and cannot have further transactions applied until the pending transaction either completes or fails.



Sales and Auctions

Listing a coin for sale is simple: Just call the /sell endpoint with the coin and the price. Your coin will immediately be listed in /sales and /marketplace, and a message will be sent notifying users that the coin is for sale. (The notification is automatic, but a separate message can be sent with /post if desired.

Auctioning a coin is only slightly more involved. The default auction process is a reverse auction, also known as a Dutch auction. You specify a starting price and a minimum price, and the price ticks down every second until a buyer takes the offer or the auction expires.

Auctions are listed in /auctions and /marketplace. If an auction expires without sale, it is automatically removed from the listings.

Sales and auctions can be cancelled at any time using /cancel.

The /marketplace call will automatically group coins for sale and auction in a given batch, showing the lowest price available from that batch.



Tagging, Sorting, and Searching

Users can specify an arbitrary set of tags against a coin, to help others to find mutual interests.

Coins can also be grouped by audience and topic. These can be pre-defined or user-defined as needed. Audience and topic are defined as special tags, and can be filtered alongside any other tags. A typical tag scheme would be audience:bloggers or topic:science.

Calls returning multiple coins, including /coins, /marketplace, /sales, and /auctions support flexible sorting options to zoom in on the most relevant content.

Users can search quickly by tag, using the tags parameter on calls like /marketplace and /coins. As a developer you can refine the selection using the any_tags and all_tags filters, which are applied in combination with user-specified tags. This saves having to generate a complex AND / OR search query.

Searching in a collection simply adds the user parameter to the same /coins call.

While search links are public and shareable, a search within your own collection will of course vary between users.

Tag analytics methods such as /toptags, /trendingtags and /populartags can be used to provide search suggestions. Top tags are relative to the current user (based on coins they have minted or collected), while popular and trending tags are global.

About

Kred NFT Developer Documentation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published