# Use G$ streaming

**First-step:**

* Superfluid concepts: [What is Superfluid?](https://docs.superfluid.org/docs/concepts/superfluid)

***

### TL;DR (one-minute overview)

Streaming Payments with G$ Token\
GoodDollar’s G$ is deployed as a pure Superfluid SuperToken on the Celo network—no wrapping needed, so it can be streamed second-by-second out of the box.\
Streaming turns one-off transfers into continuous flows, enabling payroll, vesting, or loan payments. \
For other example use cases, see[ here.](https://docs.superfluid.org/docs/category/examples-1)\
For simple second-by-second transfers called **'streaming',** powered by the SuperFluid Protocol, you talk **directly** to the immutable **`CFAv1Forwarder`** contract (`0xcfA132E3…B125) and pass in G$’s address (`0x62B8…C7A\`).\
All flows boil down to three methods:

```solidity
createFlow(ISuperToken token, address sender, address receiver, int96 flowRate, bytes userData)
updateFlow(ISuperToken token, address sender, address receiver, int96 newRate, bytes userData)
deleteFlow(ISuperToken token, address sender, address receiver, bytes userData)
```

Optional next steps:

* **GDAv1Forwarder** → pool-style distribution streams, optimized to work with off-chain interactions. ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/GDAv1Forwarder))
* **Super-Apps** → have your contracts *react* to flow events once you register them with the Host. ([docs.superfluid.finance](https://docs.superfluid.finance/docs/concepts/advanced-topics/super-apps), [GitHub](https://github.com/superfluid-org/protocol-monorepo/wiki/About-App-Registry))

***

### Prerequisites

| What                                             | Why                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Node ≥ 18 & bundler (Vite / Next)                | To build a web client                                                                                                                                                                                                                                                                                                                                                                                                                             |
| **ethers v6** *or* **viem + wagmi**              | Low-level EVM calls                                                                                                                                                                                                                                                                                                                                                                                                                               |
| A wallet on **Celo Mainnet** (`chainId = 42220`) | Only Celo currently has G$ streaming capabilities.                                                                                                                                                                                                                                                                                                                                                                                                |
| G$ token address                                 | <p>(<strong>Recommended for testing</strong>: Development G$)<br><a href="https://celoscan.io/address/0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475">0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475</a><br><br>(production G$) <a href="https://celoscan.io/address/0x62b8b11039fcfe5ab0c56e502b1c372a3d2a9c7a?a=0xe738edd568147d3fc4583894ff0ad19d2ced11f8&#x26;utm_source=chatgpt.com"><code>0x62B8B11039fcfE5AB0C56E502b1C372A3D2a9C7A</code></a></p> |
| `CFAv1Forwarder` universal address               | `0xcfA132E353cB4E398080B9700609bb008eceB125` ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/CFAv1Forwarder))                                                                                                                                                                                                                                                                                                 |

***

### Project Setup

```bash
npm i ethers wagmi viem
```

```ts
// lib/superfluid.ts
import { BrowserProvider } from 'ethers';

export const provider = new BrowserProvider(window.ethereum);
export const forwarderAddr = '0xcfA132E353cB4E398080B9700609bb008eceB125';
export const gDollar     = '0x62B8B11039fcfE5AB0C56E502b1C372A3D2a9C7A';

// paste the CFAv1Forwarder ABI snippet from the tech-ref page ↓
import { CFAv1ForwarderAbi } from './CFAv1ForwarderAbi';

export const forwarder = new ethers.Contract(
  forwarderAddr,
  CFAv1ForwarderAbi,
  provider.getSigner()
);
```

*The full ABI is on the technical-reference page and includes helpers like `getBufferAmountByFlowrate`.* ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/CFAv1Forwarder))

***

### Creating a Flow (React / wagmi example)

```tsx
import { useState } from 'react';
import { useAccount } from 'wagmi';
import { forwarder, gDollar } from './lib/superfluid';

// helper – convert “tokens per month” → int96 wad/sec
const perMonthToRate = (pm: string) =>
  BigInt(pm) * 10n ** 18n / 2592000n; // 30 × 24 × 60 × 60

export default function CreateFlow() {
  const { address } = useAccount();
  const [receiver, setReceiver] = useState('');
  const [perMonth, setPerMonth] = useState('10');

  async function start() {
    const tx = await forwarder.createFlow(
      gDollar,
      address!,        // sender (caller)
      receiver,
      perMonthToRate(perMonth), // int96 flowRate
      '0x'             // userData
    );
    await tx.wait();
  }

  return (
    <>
      <input value={receiver} onChange={e=>setReceiver(e.target.value)} />
      <button onClick={start}>
        Stream {perMonth} G$/mo
      </button>
    </>
  );
}
```

The same pattern works for **`updateFlow`** and **`deleteFlow`**; just swap the method. ([docs.superfluid.finance](https://docs.superfluid.finance/docs/sdk/money-streaming/create-update-delete-flow))

***

### Reading Live Data

```ts
// How fast am I sending right now?
const { flowrate } = await forwarder.getFlowInfo(
  gDollar,
  sender,
  receiver
);

// How big a safety buffer does Superfluid require for 10 G$/mo?
const buffer = await forwarder.getBufferAmountByFlowrate(
  gDollar,
  perMonthToRate('10')
);
```

These helper views are defined in the same contract. ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/CFAv1Forwarder))\
For historical analytics use the **Superfluid Subgraph** or Explorer. ([docs.superfluid.finance](https://docs.superfluid.finance/docs/sdk/money-streaming/subgraph))

***

### Registering Your dApp as a Super-App (optional)

If your contract should *react* to incoming/outgoing streams (e.g. auto-staking or NFT minting), you want your dApp to be registered as Super-App.

{% hint style="warning" %}
For instructions please follow: <https://docs.superfluid.org/docs/protocol/advanced-topics/super-apps/register>\
\
The Celo network requires a 'deployer' to be whitelisted before it can be registered. [Please reach out to us to help you get whitelisted.](https://t.me/gooddollarbounties/1)
{% endhint %}

***

### 6 Next Steps & Gotchas

<table><thead><tr><th width="217">Topic</th><th width="532.39990234375">What to watch for</th></tr></thead><tbody><tr><td><strong>GDAv1Forwarder</strong></td><td>Needed for pool-style “one-to-many” distributions; interface is analogous to CFA but targets pools. (<a href="https://docs.superfluid.finance/docs/technical-reference/GDAv1Forwarder">docs.superfluid.finance</a>)</td></tr><tr><td><strong>Flow-rate math</strong></td><td><code>rate = amountPerMonth × 1e18 / 2 592 000</code>. Keep <code>int96</code> limits (~10^27 total). (<a href="https://docs.superfluid.finance/docs/sdk/money-streaming/create-update-delete-flow">docs.superfluid.finance</a>)</td></tr><tr><td><strong>Buffer deposits</strong></td><td>Use <code>getBufferAmountByFlowrate</code> before creating a stream to make sure the sender holds ≥ buffer + first few minutes. (<a href="https://docs.superfluid.finance/docs/technical-reference/CFAv1Forwarder">docs.superfluid.finance</a>)</td></tr><tr><td><strong>Protocol fees</strong></td><td>G$ applies its <code>_processFees</code> on each streamed “drip”; receiver gets <code>flowRate – feeRate</code>.</td></tr><tr><td><strong>Network support</strong></td><td>Streaming live only on Celo today; G$ on Fuse &#x26; ETH can still use one-off transfers.</td></tr><tr><td><strong>Testing</strong></td><td>Use GoodDollar’s dev contract <code>0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475</code>. You can claim some free dev G$'s by creating a dev wallet here: <a href="https://goodwallet.dev/">https://goodwallet.dev</a></td></tr></tbody></table>

***

### Reference Links

1. **Create/Update/Delete Flows guide** (Superfluid SDK) ([docs.superfluid.finance](https://docs.superfluid.finance/docs/sdk/money-streaming/create-update-delete-flow))
2. **CFAv1Forwarder technical reference** ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/CFAv1Forwarder))
3. **GDAv1Forwarder reference** (for next steps) ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/GDAv1Forwarder?utm_source=chatgpt.com))
4. **SuperTokenV1Library** (Solidity helper) ([docs.superfluid.finance](https://docs.superfluid.finance/docs/technical-reference/SuperTokenV1Library))
5. **Super-Apps concepts** page ([docs.superfluid.finance](https://docs.superfluid.finance/docs/concepts/advanced-topics/super-apps))
6. **Host & Super-App architecture** ([docs.superfluid.finance](https://docs.superfluid.finance/docs/protocol/advanced-topics/super-apps/register))
7. **App-Registry wiki / registerApp** ([GitHub](https://github.com/superfluid-org/protocol-monorepo/wiki/About-App-Registry))
8. **Agreement Forwarders overview** ([GitHub](https://github.com/superfluid-org/protocol-monorepo/wiki/About-Agreement-Forwarders))
9. **G$ token contract on CeloScan** ([Celo Chain Blockchain Explorer](https://celoscan.io/address/0x62b8b11039fcfe5ab0c56e502b1c372a3d2a9c7a?a=0xe738edd568147d3fc4583894ff0ad19d2ced11f8))

***
