Blogging with IMIM and Safe Network

I’ve written an article about my new open source blogging app. I hope you like it! Obviously, it mentions Safe Network rather a lot! :grin:

Censorship resistant blogging on the Safe Network is coming to the clear net too. Enter IMIM, the WWW portal to your Safe Network blog.

Photo by author — IMIM blog in action

What is the Safe Network?

I’ve discussed the Safe Network¹ previously, so to be brief, it is an autonomous data network that overlays the traditional internet. It provides immutable and perpetual data access and storage. Everything is encrypted in transit and at rest. It uses a decentralised and distributed design to ensure data is held securely, ready to be accessed whenever needed.

The technology deployed is something to behold. Development started before blockchains were a thing and has taken a completely different route towards the goal of decentralisation. The network is currently going through a series of test net iterations to iron out the bugs and ready it for prime time.

Awesome! How can I use it?

The latest test nets have a CLI (Command Line Interface), which is great for testing core functionality. A CLI isn’t the last word in usability though and many will be put off. If you’re technical though, it is a powerful tool to bend the Safe Network to your will.

What about for everyone else? It can’t just be secure access for nerds. It needs to be granny proof. Maidsafe (the team leading Safe Network development) have plans to complete a native browser, which is much like a regular clear net web browser. A proof of concept was completed in a prior test network, which will be tailored for the latest test nets once they are stable.

Shame! I hate CLIs!

Wait! All is not lost! There will be many people who won’t have the Safe Network client installed. There will be even more who don’t have the native browser installed. Only a handful will be brave enough to try the CLI. That’s okay. We can bridge the gap with hybrid Safe Network apps.

By creating hybrid Safe Network apps, we can help to deliver the core tenets, without sacrificing accessibility. These hybrid apps can be reached via the clear net, but access data from the Safe Network. In short, they can have two interfaces — one which uses the native safe browser and another which uses a regular web browser.

An app can sense what type of browser it is being opened from. If native browser access is not available, it can talk to the Safe Network via a gateway. These gateways provide a standard HTTP interface, which all web browsers can talk to. They can also store or retrieve data to or from the Safe Network.

Great! But aren’t gateways centralising?

It depends. If there is only one gateway to access specific data, it will be centralising. If any gateway can be chosen to access specific data, then less so. If the specific data can also be accessed natively without the gateway too, then hardly at all.

Hybrid apps should maximise access to data. They should provide more ways to access data, not fewer . They should try to free the data, not seek to monopolise access to it. Anyone should be able to run a gateway too.

We want gate ways , not gate keepers .

Photo by Nikola Knezevic on Unsplash

Okay, so what is ‘ I am Immutable’ ?

I am Immutable (or IMIM, for short) is a blogging application, which can retrieve articles from the Safe Network. Initially, it interacts with a IMIM server (the gateway) via HTTP, which in turn communicates with the Safe Network. Specifically, IMIM is a WWW portal to access blogs stored on the Safe Network.

The application can read articles stored in Markdown² format. IMIM retrieves the Markdown text and converts it to HTML on the fly, to allow a web browser to render it. Markdown is a simple formatting syntax which is human friendly. You can create links, include images, format text, and so forth. This gives us all the ingredients we need to write elegant articles.

When the articles are stored on the Safe Network, a unique, immutable URL is generated. This is known as an XOR URL. These XOR URLs always point to the exact same data, as they are a product of a hashing algorithm. This means they can be mercilessly cached, as the content is guaranteed to be as expected.

XOR URLs are great, but they can be hard to remember — they are essentially a hash digest, a random looking string of digits and numbers. Using NRS (Name Resolution Service), these XOR URLs can be given a more friendly NRS URL, much like DNS does on the clear net. Both XOR and NRS URLs are a subset of Safe URLs. In other words, a Safe URL can be an XOR or NRS URL and will resolve to the same underlying location for the data.

To link the articles to a blog, their Safe URLs can be added to a configuration file. These configuration files are in JSON format and are also stored to a Safe URL. Armed with an IMIM configuration Safe URL, the browser can download the associated articles.

Example URL types:

XOR URL: safe://hy8oyeyq7ohh8r78s5jietuo4oecdfrkopy1ig8g798fi6ucgk14jzijm9w

NRS URL: safe://friendlyname


Photo by author — IMIM server retrieving Safe Network data

How can a web browser read a Safe URL?

When ran from the clear net, the IMIM app converts Safe URLs into IMIM server URLs. It then sends these URLs to the IMIM server to retrieve the data. Any Safe URLs within the article are converted to IMIM server URLs on the fly, including images. This allows the IMIM app to render the article and all its images seamlessly from the Safe Network.

Because the data is stored in a combination of Markdown and JSON, via Safe URLs, they are available to other Safe Network apps too. You can download them directly via the CLI, for example. In the future, a native safe browser will be able to access them directly too. This enlarges the audience for the articles, securing access for everyone .

How is IMIM designed?

The IMIM client³ is an Angular⁴ app, which will be familiar to any web developer. Angular supports reading JSON and Markdown easily, while being highly extendable. It is mature, battle tested and should be compatible with any device capable of running a web browser. This includes smart phones, tablets or laptops.

The IMIM server uses sn_httpd⁵, which is based on Actix⁶, a web framework and HTTP server written in Rust. This links directly with the Safe Network client library, which is also written in Rust. Using Rust throughout the IMIM server reduces complexities and incompatibilities. Actix is one of the most popular and high performance Rust based web frameworks, which will provide a strong platform for hosting IMIM services.

The life-cycle to retrieve an article goes something like this:

  1. IMIM client sends a request for an IMIM configuration to the IMIM server.
  2. IMIM server parses the request, retrieves the IMIM configuration data, then returns it to the IMIM client.
  3. IMIM client parses the IMIM configuration, then sends one or more requests for the associated articles.
  4. IMIM server parses the requests, retrieves the IMIM article data, then returns it to the IMIM client.
    a. If the request was for an NRS URL, the CacheControl headers are set to briefly cache the data.
    b. If the request was for an XOR URL (immutable), the CacheControl headers are set to cache aggressively/indefinitely.
  5. IMIM client formats the articles as HTML and renders them to the user’s browser.

How do I view blogs and add articles?

To access an IMIM blog, the URL looks something like this (hosted locally):


The blog_name should be an NRS URL that points to an IMIM configuration. While an XOR URL could be used, it would be impossible to add or update any articles to the blog. Using an NRL URL allows the IMIM configuration to be updated with new or modified articles, uploaded to an XOR URL, then linked to the blog’s NRS URL.

The article_xor is an XOR URL without the safe:// prefix. This references the Markdown article at the associated XOR URL. It is recommended that XOR URLs are used as they can be cached indefinitely, due to their immutable nature.

For more information on setting up an IMIM blog, take a look at the i-am-immutable-client README³.

What features are planned for the future?

IMIM is currently a read only client app. To add content, it must be done via the CLI. This is sufficient for the initial prototype version, but adding write access would be desirable.

Publicly hosting an IMIM server is also too open, currently. While the Safe Network does not charge for retrieving data, a traditional cloud host will. This will need tightening up to make public hosting feasible.

Both of the above can be tackled by using Safe Network wallets, which could be created and topped up by the blog owner. This wallet could then be used to pay indirectly for hosting fees and directly for writing data. A user experience familiar to other clear net blogs would then be possible.

Creating a native browser client is also desirable and once the Safe Network Browser is operational again, this shall be done. The same IMIM client will simply be updated to sense which platform is being used, then retrieve the blog configuration and articles using a tailored module.

What if you only have access to the Safe Network CLI? Well, you can always pipe the Markdown article through pandoc and lynx !

safe cat safe://hy8oyeyqyrgwdy3jkhmgm67id4hdtc8ymnozoi8x95cjr4gazqrawx9pqoe | pandoc -t html | lynx –stdin

Wow! I’ll give it a whirl!

Thanks for reading and please do! The files in the IMIM client³, server⁵ and docker⁸ repositories below will help you get started. There is also a Safe Network community forum thread, which may help.

At the time of writing, we are between test networks, so only local test networks can be used. When the next public test network goes live, I’ll be sure to create my IMIM blog to test it all out though!

[1] Safe Network Home Page

[2] Markdown Guide

[3] I am IMMUTABLE (IMIM) Client

[4] Angular Framework

[5] SN_HTTDP Framework (for IMIM Server) GitHub - traktion/sn_httpd: Safe Network httpd gateway server

[6] Actix Web Framework

[7] IMIM Safe Network Community Forum Topic

[8] IMIM Docker setup and local Safe Network Scripts

[9] Pandoc — a universal document converter

[10] Lynx CLI web browser


I’ve added full article in OP now. Hope you like it!


I will read this carefully Paul cos I’m still failing with index.json

Who added /blob/ BTW cos the raw .json looks like

It looks like you are using the config url as the article url. Try changing ‘myblog’ with ‘hyfey…’ url.

E.g localhost:8080/blog/hyfey…

It should then list those 3 articles.


Yep that gives me a preview of two articles and the raw image file - getting there - thank you :slight_smile: