---
# System prepended metadata

title: Superfluid Protocol
tags: [superfluid, flow, payment stream, solidity, polygon]

---

Superfluid is a DeFi (Decentralized Finance) protocol that introduces a novel concept of money streaming, or "flows". It automates recurring transactions and monetizes Web3, providing a framework for creating and managing continuous, real-time streams of tokens from one account to another. This is a significant departure from the traditional transaction model, where tokens are transferred in discrete, one-time transactions.

![](https://hackmd.io/_uploads/rkwriuIi3.gif)

**How Superfluid Works**

1. **Creating a Flow**: When a flow is created, the Superfluid protocol records the details of the flow, including the sender, receiver, and flow rate (how many tokens per unit of time). It also records the current timestamp. However, no tokens are actually transferred at this point.

2. **During the Flow**: As time passes, the number of tokens that should have been transferred increases according to the flow rate. However, these tokens are not actually transferred on the blockchain. Instead, the protocol calculates how many tokens should have been transferred based on the current time and the time the flow was created. This calculation can be done at any time, but it's typically done when someone queries the balance of the sender or receiver.

3. **Closing a Flow**: When a flow is closed, the protocol calculates the final number of tokens that should have been transferred, updates the balances of the sender and receiver, and records that the flow has been closed.

This system allows the Superfluid protocol to simulate continuous, real-time streams of tokens while only making actual transfers on the blockchain when a flow is created or closed. This is much more efficient in terms of gas costs and allows for a much higher volume of flows.

**Real-Time Balance Updates**

The real-time updating of the receiver's balance in Superfluid is not due to actual transactions happening on the blockchain every second. Instead, it's a result of the way the Superfluid protocol calculates balances. When you look at the receiver's balance in a Superfluid-compatible wallet or interface, what you're seeing is not the actual balance of tokens in the receiver's account on the blockchain. Instead, you're seeing the balance that the receiver would have if all the flows into and out of their account were to be closed at that moment.

**Lightning Network**

The Lightning Network is a layer 2 payment protocol that operates on top of a blockchain (most commonly associated with Bitcoin). It enables fast transactions between participating nodes and has been touted as a solution to the Bitcoin scalability problem.

Superfluid, on the other hand, is a protocol built on the Ethereum network (and its layer 2 solutions like Polygon/Matic) that introduces the concept of money streaming or "flows". It does not rely on the Lightning Network for its operations. Instead, it uses smart contracts on the Ethereum network to create, manage, and close flows of tokens.

**SuperApps**

A SuperApp is a smart contract that is designed to interact with the Superfluid protocol. SuperApps can respond to changes in token flows in real-time, enabling them to implement complex logic that reacts to the state of ongoing token streams.

For example, a SuperApp could be programmed to perform a certain action when a token flow starts, changes, or stops. This could be used to implement subscription services, where a user's access to a service is tied to an ongoing flow of tokens. If the flow stops, the SuperApp could automatically revoke the user's access to the service.

SuperApps are a key part of the Superfluid ecosystem, as they allow developers to build complex, automated systems on top of the basic functionality provided by the Superfluid protocol.

:::info
:bulb: The Superfluid SDK and examples are provided in **JavaScript** and **Solidity**.
:::


**Recources**

- For more information please see the [Superfluid Documentation](https://docs.superfluid.finance/)
- [EVM Contracts](https://github.com/superfluid-finance/protocol-monorepo/tree/dev/packages/ethereum-contracts) 