pull down to refresh

How are internet-native paywalls implemented?
For a detailed flow chart, you can check the main page but here's the TL;DR version:
  1. The client requests an HTTP resource.
  2. The server checks if the client is authorized to access the resource (authentication + authorization + payment).
  3. If payment is required, the server responds with a 402 (Payment Required) error code, including credentials and a challenge in the HTTP response headers.
  4. The client solves the challenge and obtains proof of completion.
  5. The client requests the same HTTP resource again, this time including the credentials and proof of completion in the authentication headers.
  6. The server validates the client's credentials and the completed challenge.
  7. The server processes the request and serves the HTTP resource.
Currently, the credentials are Macaroons (a type of cookie), and the challenge is a Lightning invoice (proof of completion is the preimage).
You can check out the full flow with code in our notebook tutorial:
reply