🥤Soda Machine
Money flows in, soda flows out
For this example, we will create a Super App for purchasing soda in real-time. The soda will only flow while we are paying, so we'll be in charge of how much we want in our cup!

$1 DAI = 1 SODA

To make things simple, we'll sell our SODA for $1 DAI
However, instead of discrete payments, like handing a single dollar bill to a cashier, the machine will only dispense SODA while we are actively paying.
Stream DAI to the machine- it turns on. Stop streaming DAI- it turns off.
Streaming 100 DAI per minute means you'll have a lot of SODA very quickly

Operating the machine

When we deploy the contract, we can automatically mint 1M SODA tokens. This should be enough for many happy customers. We also set the accepted token we wish to earn, which in this case is DAIx (Superfluid DAI).
Customer can start flowing DAIx to the Soda Machine contract address using any available interface- such as the Superfluid Dashboard. Once they've received the desired amount, they can cancel their DAIx stream.


Before starting you should:


Click this link to load the contracts in Remix:
Remix - Ethereum IDE
Select and deploy Example.sol on Goerli network using the following parameters:
If you want to deploy on a different network, use the 🔗 Network Directory
During deployment, several things will happen:
  • Deploy and initialize a Custom Super Token "SODA"
  • Deploy the Soda Machine, and register it as an ERC777 recipient (so it can receive SODA)
  • Mint 1M SODA and send them to the Soda Machine

Stream some SODA

Now that you've deployed the example contract, you can check the values for _sodaMachine and _sodaToken and load the appropriate contracts in Remix. Keep in mind that the interface you should use for _sodaToken is ISuperToken and not the proxy interface NativeSuperToken.
Once you have the address for the Soda Machine, start sending it some DAI (accepted token) using the dashboard. Once your DAI stream begins, SODA will immediately begin flowing back to you! To stop the flow of SODA, simply stop your DAI stream.
You can check you balance of SODA using the contract in Remix, since the token won't appear in the dashboard.
Last modified 7mo ago