How to Stream Payments with Superfluid on Polygon Network
A step-by-step guide to streaming payments with Superfluid on Polygon (Matic) network.
Ever had to make multiple small payments and got frustrated with Ethereum gas fees? Or had to distribute funds but did not have enough liquidity? You may have resorted to different solutions to tackle this, but there wasn't a seamless way to deal with frequent micropayments until recently. Enter Superfluid.
What is Superfluid?
Superfluid Protocol is a smart contracts framework on Ethereum that allows you to transfer tokens using a new primitive called agreements. In a single transaction, you agree on the amount to be streamed and the period over which to stream it, and gasless smart contracts take care of the rest. Once a stream is opened, it keeps flowing every second as long as there is sufficient liquidity for the stream, without having to lock-up the entire amount upfront. This makes Superfluid an excellent option for paying salaries, distributing rewards, managing subscriptions, and a whole bunch of use cases yet to be discovered.
Why Polygon (Matic) Network?
If you just want to test Superfluid, you can use a MetaMask Wallet set to the Goerli Test Network and stream test tokens. I decided to be more adventurous and use the Polygon (Matic) Mainnet instead. While many interchangeably refer to Polygon as an Ethereum L2, it is technically a sidechain with its own validators and security properties. Nevertheless, it does help alleviate the current scalability issues with Ethereum, namely high gas fees and slow speeds.
Before you start, you'll need an Ethereum wallet connected to the Polygon network with some $MATIC tokens. Both MetaMask and WalletConnect with Trust Wallet work just fine. If you don't already have the tokens, head over to Binance, Gate.io or Coinbase (or use a crypto exchange of your choice), buy and send the tokens across to fund your wallet first. If you use MetaMask, remember to configure and change the default network from Ethereum Mainnet
to Polygon
.
Stream Payments using Superfluid Dashboard
While token streaming may sound complicated, Superfluid has made it really easy to set up via their dashboard. Connect your wallet using the Matic Mainnet
.
Deposit a few $MATIC tokens - doing so wraps and upgrades the legacy ERC20 tokens to get access to Superfluid capabilities. These SuperTokens are ERC20 and ERC777 compliant, and always redeemable 1:1 for the underlying assets. Approve the transaction in your wallet to continue.
Once deposited, the wrapped $MATIC tokens are shown in the dashboard as well as the Currencies
tab.
Now comes the fun part. Click Send
to start the stream. Provide the recipient address, choose the wrapped token and decide the streaming parameters (monthly/weekly/daily/hourly and tokens). The streaming rate per second is automatically calculated.
Once you click start, you'll be shown a warning to highlight the security deposit and streaming mechanics. Select Ok
and click Start streaming
. Approve the transaction in your wallet to start the process. The dashboard will update immediately to show the stream in progress.
If you have multiple streams in progress, you can see them in the Streams
tab. You can also cancel a stream in progress, which I will do momentarily once a fraction has been streamed over.
As a recipient, you can connect your wallet to the Superfluid dashboard and view the incoming streams. In the example below, I had already closed the stream.
Finally, if you wish to withdraw the tokens, you can go to the Currencies
tab, choose the amount and click Withdraw
. Approve the transaction in your wallet to continue.
When you withdraw, the wrapped tokens are redeemed 1:1 for the underlying $MATIC tokens, which will show up in your wallet upon finalization. You'll just need a bit of $MATIC in your wallet to pay for gas fees.
Bonus: Level up on RabbitHole Skills
If you haven't heard of RabbitHole before, it is a platform to learn about and try out Web3 technologies. You get points and even NFTs to try out new projects and complete quests. Effectively, it helps you build an on-chain resume. If you find this interesting, I highly recommend you connect your wallet to RabbitHole, start the Stream with Superfluid task, and then proceed with the steps in this post.
Well, that's it. It was oddly fascinating to watch the tokens stream in real time. Streaming is very likely to open up a previous inaccessible design space, and I'm stoked to see the downstream (pun intended) opportunities that arise.