An implementation of the L402 protocol.
L402 is a protocol that leverages the capabilities of the Lightning Network for token minting and service authorization to enable the monetization of APIs through Bitcoin.
Note
Additionally, it offers an implementation of the phoenixd API for integration with a real Lightning node.
Currently, this project does not offer standalone server or client implementations. However, it provides essential utilities and an example setup to get started.
The example available in the ./server/
and ./client/
directories demonstrates using a mocked Lightning node to issue and resolve challenges.
To get started, follow these instructions:
-
Launch the Server
Open a terminal and run the following command to start the server:
go run ./server/main.go # 2024/06/09 09:21:20 Server launched at localhost:8080
-
Mint a Token and Access the Service
In another terminal, run the following command to mint a token and access the service:
go run ./client/main.go # Requesting Token... # {"user_id":"...","caveats": "...","signature":"..."} # Sending Authorization Request... # ...
The following diagram illustrates the domain model for the L402 implementation:
The authorization flow for L402 tokens is depicted in the following diagram:
For more information, refer to the following resources:
This project is licensed under the terms of the MIT License.