NFT Storage with IPFS

Start Here

Exposing a REST API for NFT Storage and Outsystems
Author: @sydneylai


CID - content ID
Pinning - asking the node to keep the data, so that it's not trashed, if you pin it hte data presists

Paying for image storage

Quede vs Pinning - next deal brokered to get on the Filecoin network

Consume NFT Storage API

Step 1: Start with a mobile app
When you launch Service Studio, you want to create a mobile application by clicking on "From Scratch" and then "Phone app".

Name your application.

Here you can design your application however you'd like. In this process, I'm creating an NFT wallet with a simple scrolling mechanism similar to the Instagram layout.

Step 2: Consume the NFT Storage REST API

Click on Service, as we are building a service to consume the REST API

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Right Click on REST and consume REST API

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Add Multiple Methods

Find the YAML file here
https://nft.storage/api-docs/

Convert the NFT Storage YAML file to a JSON
https://nft.storage/schema.yml

Convert with
https://www.convertjson.com/yaml-to-json.htm

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Check and address any errors and warnings

Step 3: Create and map out your REST API
Add Authorizations to your Methods

Double-click on the orange REST API Method titled "Click" > "Heads and Authentication"

In the Request headers dropdown select "Authorization"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Click on the "Test" tab and include a CID in the URL parameter values. You can find your CID HERE if you are logged in.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

in Request headers values, Authorization, include:

Bearer[KEY TOKEN]

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

click on "Test" to see an "ok":true value

Copy to response body
Click on Finish

Hit the green Publish button

Now repeat Step 3 for the rest of the REST API Methods titled "delete", "list", "status", "store" respectively

at "List"

Include a future date for the before parameter

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Copy over and match the fields

While you're creating an Authorization input parameter for both "Status" and "Store" you may get an error or empty payload, just click "Finish"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Hit the green Publish button

Step 4: Create a Service Action
Right Click on "Service Action" and title your action "List"

The logic flow will visually appear

In the Logic tab,
Integrations > REST > NFTStorageAPI >

**
Drag the "list" Run Server Action into the logic flow and click on the icon until you see the "Authorization" dropdown
**

It's empty

in "list" Run Server Action, copy all four input parameters, and paste in the "List2" Service Action

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Now include the Before and Limit within the List Run Server Action you just created on the Logic Flow

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Assign the "list" Run Sever Action by dragging an "Assign" blue icon from the left tray into the logic flow, below the "list" icon

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Assign the variable with "Response"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’
You may get errors asking to make your structures public

Step 5: Integrate your API wrapper

To integrate your API, head to Interface > Home Screen and "Fetch Data from Other Sources", which I've named "ShowStorage"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

In the upper left-hand side there is a

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’
icon where I will manage my dependencies. I want all the modules that I've created before, to be referenced.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Head to the Logic tab and locate "List" Service Action, click on and drag the icon into the logic flow.

Head to the interface tab and double-click on the Output Parameter we've named "Response", set the Data Type to a ListResponse matching the Response Output Parameter in the Logic tab.

On the logic flow, drag and drop an Assign into the logic flow. In the drop-down, assign Response and List3.Response (or whichever number list you have show up).

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

In your Run Server Action titled "List", set

before: "CurrDateTime()"
Authorization: " "Bearer TOKEN" "

Your Authoization Bearer TOKEN is a string so must close in quotes.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Step 6: Connect the database and images

On the Interface tab in the Mainflow UI Flow, add a Block widget and add an Input Parameter titled "CID".

Double-Click on the "Home" Screen icon and select "Widget Tree" on the top right.

In Content, drag and drop a Block widget and set the sources:

Source Block "MainFlow\Block1"
CID "ShowStorage.Response.value.Current.cid"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Include three "x.y Expression" widgets within Content

In the first Expression, map the expression to

ShowStorage.Response.value.Current.cid

Folder structure is seen here:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

The second Expression, can be expressed as follows:

FormatDateTime(ShowStorage.Response.value.Current.created, "d MMM yyyy HH:mm")

The third Expression, we can showcase the pinning service.

The Images

In the Interface tab, click on the Block1 widget. Drag and drop an Image widget from the left.

Set the Type to "External URL"

"https://" + CID + ".ipfs.dweb.link"

In the API wrapper that I've titled "IPFSNFTStorage", create an Input Parameter within the "store" REST API Method. The Input Parameter will be named "Binary Image" and set the Data Type to "Binary Data".

Now copy the three input parameters in store and create a Service Action titled "Upload" within the Service Actions folder. Paste the three input parameters within the "Upload" Service Action

Double-click on "Upload" Service Action and drag the store REST API Method onto the logic flow

The "Store" Run Server Action is like requestion something from someone, in this case asking someone for the image.

Timestamp: 01:25:46

Therefore the Assign widget in the logic flow will be the response to the request:

Success
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

You have integrated your NFT Storage API and your mobile application can now display hosted NFTs


IPFS

Bearer
When things are stored in, there is a storage deal made, what each API call is doing in the background

/Upload - Consuming the API / Post Method

Explains uploads, throws it on some IPFS nodes, available over the network, not just centralized, it's free, the storage providers
https://nft.storage/api-docs/

CID

API Keys

Potential CTA:

  1. How to set up free VPS?
  2. Fork & Go, between storage and app

Feedback

  • include slides, demos to set up the demo, go into the context (the audience has maybe bought NFTs but never used it)
  • What's an NFT, what kind of meta data is important, why IPFS is important, why the CID, how can this demo inspire you to build interesting things
  • How do we raise up the quality of apps, how do I iterate through hundreds, how do I incorporate into a challenge design
    • think about the context

Ending Slide/CTA

  • one slides, think of the things, Rights management, royalty payments, beyond the gallery view, each NFT represents an input to music and 8 tracks, showcase music players for decentralized music hosting, Movie royalties, decentralized land management,

Demo

Go in, and recreate the Method, do one for you to see how it works "List" method