DEV Community

Cover image for Build an NFT Wallet with OutSystems & Filecoin
sydneylai
sydneylai

Posted on

Build an NFT Wallet with OutSystems & Filecoin

Author: @sydneylai

You hear about NFTs as collectables or images, but how do we store or collect them? Today we will build an NFT wallet and host them on IPFS as a unique NFT.

We host the images in IPFS because this a peer to peer and a decentralized form of storage, rather than a centralized solution like AWS or Google Cloud. Therefore if AWS goes down or you forget to pay your Cloud subscription, you still have a hosting solution that assigned a unique identifier or content identifier (CID).

Once you have a unique image, you can either distribute your NFTs on a marketplace, put it on a smart contract or turn it into a game. I'll include resources below for how else you can continue to build. This tutorial is for beginners who want to learn how to create and host their NFTs.


Start Here

Exposing a REST API for NFT Storage and OutSystems 
Enter fullscreen mode Exit fullscreen mode

Tools you'll need:

OutSystems IDE https://outsyste.ms/developers
Filecoin's NFT Storage https://nft.storage/

Filecoin and IPFS Explained

Vocab 101

CID - content ID
Pinning - asking the node to keep the data, so that it's not trashed, if you pin it hte data presists
Quede vs Pinning - next deal brokered to get on the Filecoin network


Making an NFT Wallet and Hosting NFTs

https://nft.storage/

Here is your hosted image, with a CID

Hosting NFTs on marketplaces or wallets typically request ETH and gas. NFT developers who want free decentralized storage, you will be able to host your images on-chain with NFT.storage.

Just upload your data and you'll receive an IPFS hash of the content (a CID) that can be used in on-chain NFT data as a pointer to the content.

How it works:

  • Upload your data, get back an IPFS hash of the content (a CID) that can be used in on-chain NFT data as a pointer.
  • Storage + Retrieval is free!
  • Metadata is returned in proper formats!
  • Fetch it back via IPFS (pinned redundantly >3x)
  • Backed up to Filecoin (stored redundantly >5x)

Filecoin provides long term storage for the data ensuring that even if nft.storage is attacked or taken down the NFT data persists.

Consume API

You can upload either a single file or consume the API to upload multiple files in a directory. The API follows a typical POST and GET Method.

**/Upload** - Consuming the API / Post Method
Enter fullscreen mode Exit fullscreen mode

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/

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

Right Click on REST and consume REST API

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

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"

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.


in Request headers values, Authorization, include:

Bearer[KEY TOKEN]

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

click on "Test" to see an

"ok":true value

  1. Copy to response body
  2. Click on Finish
  3. Hit the green Publish button

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

On the "List" method,

Include a future date for the before parameter

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"

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

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

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

Assign the variable with "Response"

💡 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"

In the upper left-hand side there is a 🔌 icon where I will manage my dependencies. I want all the modules that I've created before, to be referenced.

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).

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.

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"

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:

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.

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

Success ⭐

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

Continuing Education

Listen to Patrick Collins, developer advocate at Chainlink explain securing blockchain oracles on Decoded Podcast.

Video Tutorial

https://youtu.be/3Zy7XfDnev0

Image description


Discussion (0)