More questions about SAFE app development

Hello again. I’ve been doing some more reading about how to build apps on the SAFE network, but i’m still a bit confused about the overall process. I have installed the launcher, created a new project and added SafeNet JS to my project. I’ve created a new site + domain inside the launcher and i’m able to find it using listNames() from my app. I now want to write some test data to my app, validate the data, insert it into the SAFE db, and read it back it. Is that the correct process? In the SafeNet JS docs it says ‘Only SAFE_DRIVE_ACCESS currently supported’. So am i right in assuming that it’s not possible to write to the db yet? Does this relate to ’Unified Structured Data’? Can someone explain this to me please? And what about SAFEPress? How does it store the data? Since there’s no backend, how does it validate the data?



hmmm - okay - i might miss something here but i try to share what i know

calling it “the db” feels kind of strange to me - thought it of course is a huge db …
when accessing safenet via your app you have access to files (private / public) and you can create folder & files “in your account” - make folders public and share them with others

it means that you only can store and retrieve data from safenet - there is no direct messaging between 2 safenet-users supported yet and there is no payment (safecoin and transactions)/farming implemented into the protocol

if you want to create a stand-alone app without any data-sharing with others you program your GUI, take the data you want to process - validate it - and store it in your private safe folder (probably you’ll want to create an app folder first there :wink: ) after that you can read your private data and retrieve that data-file again and use it for whatever you want

maybe having a look at the codebase of safeshare

might help you to see how data can be managed inside safe via JS

Ok thanks @riddim

So i just stored and retrieved a json object…

Safe.nfs.updateFile(myFile, myJsonData...etc 
Safe.nfs.getFile(getFile, options).then(function (file) {console.log(file)}

Since i’m not able to validate the users data (as that would require a backend), what would be the best way to do this? I guess i could read the data back, check if the contents are valid, and then write isValid = true/false into the object. Any idea how i could control the permissions so that users are only allowed to write to that specific value in the object? i.e.

var myJsonData = {
senderID: 'XYZ123',
url: '',
isUpVote: true
isValid: true // is it possible to only allow users to change this value?

NOTE: Perhaps x number of signatures might be better.



argh - sorry i only wrote a very very very simple program with ruby … so … i am not the best one to ask here :wink:

i would assume the only way to control what data can be altered by the user is to put the data that should not be changed into a public folder of one [app-management-account] and the user-specific data in the users private folders … but then you the user wouldn’t be able to enter the data himself … maybe @nice @cretz or @lightyear could help you here - they know way more than me …

ps: oh sorry @Krishna_Kumar - i didn’t want to exclude you xD i just didn’t want to steel to much of your time - cool that you stepped in!

ok np. Thanks anyway :slight_smile:

1 Like

I have not checked SafeNet JS, but I can try to help based on the launcher APIs

The data in the network is stored as Structured Data and Immutable Data. You can create anything that fit your needs using these as building blocks.

The Files and Directories are built using these.

We are still in the early stages of the network. We have exposed APIs for NFS and DNS (file storage and Public shares). For creating a small database, we are yet to expose the low level APIs using which the devs can create their own schemas for storage.

In the next version of the launcher we are trying to simplify the API. This would make it close to the standard way in which the devs build the application. You will find it easier to interface your app directly with the launcher.
We are also hoping to expose the low level APIs for creating structured data in the next version.

If you are talking about validating the ownership of the file, then the NFS API doesn’t provide an option yet. The users can be identified based on their public Id, but those are not yet exposed through the launcher APIs yet.


@Krishna_Kumar thanks for the info. So let’s say i wanted to check that the url entered by a user is valid, how would i do this without a backend? Or is that what the low level APIs will allow me to do?