Building a Paywall Infrastructure on Top of Raiden

Raiden Network
Raiden Network Blog

--

Raiden provides the means to build a fast, cheap, and decentralized infrastructure for token transfers. Therefore it can easily serve as a means to monetize online content like newspaper articles efficiently without the need for user accounts or a subscription-based payment model.

We have constructed a demo to inspire you to build a paywall infrastructure on top of the Raiden Network. It demonstrates how frictionless, fast, and accountless pay per use paywalls can be easily implemented:

Watch the Full Video Below

Paywalls in the Online Newspaper Landscape

In today’s online world content providers struggle to fund the creation of quality content. Since the rise of ad blockers, ad revenue often can not subsidize the free provisioning of content to the consumers. Therefore many content providers moved to asking directly for money one way or another.

On online newspaper sites, fencing the content by a paywall became a widely adopted means of revenue creation. Often, paywalls require account creation, as well as the involvement of a third party payment provider (e.g. PayPal or VISA).

The content providers often choose to have monthly subscription-based paywall models instead of offering more fine-grained pay-per-view payments.

Currently, the pay-per-view payment method requires the involvement of payment services which leads to more centralization and higher fees for users and more dependency on third parties for content providers.

The Raiden Network can solve those issues by providing cheap, near-instant payments while still profiting from the decentralized nature of blockchain technology.

Assuming that participants already have access to a funded Ethereum account, content providers, as well as consumers, can join a payment network in an ad hoc fashion and immediately receive or send funds without the involvement of an additional third party.

This will also allow for other scenarios, where the boundaries between a content provider and consumer are fluid: a newspaper site could for example reward their readers by sending back payments for the involvement in the comment section.

The First Building Block: A Paywalled Web-API Framework

As the first step in building a paywall infrastructure, we designed a programmatic way that a content provider can expose content to the web and receive payments for each individual access to the endpoints of the provided content.

For this, we connected a typical web backend application to a Raiden node and designed a simplistic protocol on which the content provider can communicate the payments that are required to access the paywalled content. Briefly summarized, on an incoming request for a resource, the content provider checks if a request contains a reference to a valid payment on the Raiden Network for that resource.

If the request is associated with a reference to a Raiden payment, the paywalled resource is properly returned and the reference will no longer be usable for repeated access to the paywalled resource. If no reference to payment is associated with the request (the requester might not even know that the resource is paywalled), the content provider will respond with information on how the payment should be conducted as well as optional information on what will be provided at the resource.

This process is comparable to acquiring an API authentication token that is only valid for a single request and that has to be renewed after each successful access to an API’s resource. Effectively this results in a pay-per-use paywall that does not require any login or time-based subscription in order to access the content.

We build a reference implementation of this protocol as a Flask extension, which can be easily used to create dynamically priced APIs by yourself. The `raiden_paywall` extension is used as middleware by wrapping the `Flask` app:

Then the definition of individual routes can be done as usual, with the possibility to configure the paywall parameters for each route from inside of the function:

Apart from setting up the Raiden node and providing some configuration parameters to the paywall, this is all it takes in order to expose a paywalled resource and be ready to get paid for it. Above, the amount for the content has a fixed price, but you could easily implement dynamic pricing, e.g. based on the byte size of the article.

Once you make a GET request to the resource `/article`, you will get back a payment request in conjunction with the specified preview:

After initiating the Raiden payment with the given parameters, the same endpoint will return the resource as soon as the correct payment identifier (`id`) is provided in the request header:

A successive GET request with the same X-Raiden-Paywall-Id will require another Raiden payment since the payment that was originally associated with the `id` was already used to access the content once and therefore ‘invalidated’.

To get more information and a more detailed description of how the protocol works, please see the code or consult the documentation.

Building a Paywalled Content Platform

So far we presented only the backend application of the content provider. Since content needs consumers, and content consumers usually don’t want to manually initiate Raiden payments based on some JSON data in order to read an article, we also created a frontend application.

For this, we implemented a prototype of a simple HTTP middleware in JavaScript that provides web developers with a tool that easily handles all the paywall logic transparently in the background.

The HTTP middleware is integrated into a Vue plugin, that provides an easy developer and end-user experience out of the box: the plugin will handle the user interaction as soon as an HTTP request encounters a response requiring a Raiden payment. It will forward the user to our light client application that runs a Raiden node in the browser, using MetaMask for signing transactions. No long-running Raiden node on the user’s machine is needed.

With this Vue-plugin we ultimately built a simple website where paywalled blog articles are queried from an instance of our content provider implementation. Articles will be shown as soon as the user finalizes a successful payment with the light client and the content provider returns the resource behind the paywall:

Look at the code or consult the documentation of the content provider framework to get more insight into the technical details.

Make sure to stay up to date by following us on Twitter and Medium and joining the conversations on Reddit and Gitter!

The Raiden project is led by brainbot labs Est.

Disclaimer: Please note, that even though we do our best to ensure the quality and accuracy of the information provided, this publication may contain views and opinions, errors and omissions for which the content creator(s) and any represented organization cannot be held liable.

The wording and concepts regarding financial terminology (e.g. “payments”, “checks”, “currency”, “transfer” [of value]) are exclusively used in an exemplary way to describe technological principles and do not necessarily conform to the real world or legal equivalents of these terms and concepts.

--

--