Pinata

Pinata is an IPFS pinning service. SimpleID leverages Pinata to make storing content to IPFS simple and to ensure that content is always available. There are two functions you'll need to use when allowing your users to fetch and store data on IPFS.

First, storing data:

const payload = {
email: userEmail,
id: "testing",
content: {
title: "SimpleID Test",
body: "SimpleID docs are great"
}
}
const pinned = await simple.pinContent(payload);

The payload parameters are all required and include the user's email address, an identifier to refer back to the content, and the content itself. The content parameter should always be an object.

When stored and pinned, an IPFS hash will be returned. You are welcome to store that hash somewhere, but as you'll see when fetching content, you won't need it as long as you have the identifier referenced above.

Fetching content:

const payload = {
email: simple.getUserData().email,
id: "testing"
}
const fetchedContent = await simple.fetchPinnedContent(payload);

Pinata takes care of finding the data to be fetched and returning it appropriately as long as you pass the right identifier through SimpleID. It's important to note that this identifier should be globally unique to ensure there are no clashes with other developers.

A clash does not result in another user's data being returned. Instead, it results in a failure to return any data, at which point you can fall back on the IPFS hash.