Money Streaming 101 Working with Programmable Cashflows Samuel Flamini; Francesco Renzi
Ethereum Denver·Sun, Oct 9, 2022, 12:00 AM
Transcript
hello everyone i'm francesco i'm the founder of superfluid and uh we're gonna basically give you an overview of what the system is and then i'll customize sam who's gonna explain how to actually build stuff and that's the exciting part at least for me i'm interested who is a developer and is going to be hacking lift your hands wow okay see you later all right let's start so where is this oh it's there okay all right well hello everyone so what is superfluid superfluid is a d5 protocol for digitally native programmable cash flows you can use it to stream money with no upfront liquidity requirements and with fully on chain programmability so you can use it to build applications exactly like any other d5 protocol so what is money streaming money streaming is this idea of sending funds over time rather than making a simple lump lump sum payment you can send funds every second to your counterparty now money streaming is basically a continuous payment it's the frictionless transfer from one account to another over time in an open-ended fashion so streams stay open once you open it it stays open until you close it this means as a user the ux is very good you can open a stream to pay an employee and until you fire them you basically leave it open without having to touch it again now why is it important because it links value transfer with service provision you don't no longer have to work for a month and then hope for your employer to pay you at the end you get paid for every second that you work and what this means is that not only there's no delays in payments but there's also no counterparty risk so you can completely eliminate counterparty risk in any kind of ongoing service so how do we get streaming well we have a concept of super tokens super tokens are a new token standard it's erc20 and erc777 compatible it's plugged into the superfluid protocol and it's usable anywhere in web free so it's completely you know usable as a money lego now there's two kinds you either have native token which means you create it directly through superfluid and in this case all the tokens are streamable in the other case so you know you want to use a token that already exists what you have to do is wrap it and then you can stream it and at any point in time you can unwrap it and basically just use it like you would normally so basically any erc20 token is compatible now how does money streaming work well we have a primitive called agreements which are basically ongoing peer-to-peer financial relationships so there are open-ended relationships between accounts which allow you to transfer funds in new ways now money streaming is one of them there's more you can find more information on our website but the important thing is that this is all happening on chain which means all the agreement information is available to use in applications and what this means is for example your business you're receiving streaming subscriptions you can now build a lending application which knows exactly how much that address is receiving every second so you can build all sorts of landing applications that use this data on chain and the agreements are built into the user's token balance and what this means is that the balance that a user has is updated in real time so user's balance becomes a real time balance where all the information that is stored on the blockchain is computed with the current timestamp to give you your current balance and that will change every second so imagine you're a business you have you know hundreds of incoming subscriptions you're paying your employees and all of this is updated in real time in your balance and the number you get there is exactly how much you can spend so what this means is effectively it's a real-time balance sheet you can operate a business with very little cash because all your funds are moving in real time every second now what happens when businesses start adopting this they start paying their employees they start accepting subscriptions and all of this is interconnected we have what we call networked cash flows so funds streaming through the economy every second from one account to another without any friction and we we can do this all on chain and you know at superfluid we're very excited to bring about payments right webfree is supposed to be about payments as well right we've kind of forgotten about that but it's important because it brings a real world adoption we can get businesses to plug all their financial information on chain we can then you know build uncollateralized lending with that so how do you do this well through programmability right we're all in an ethereum conference we know that payments alone don't kind of not going to make it right you need programmability so programmability in the case of superfluid means you can build applications that react to streams you can manipulate incoming and outgoing streams and by doing this you can create these financial applications that kind of move funds in real time without needing to make multiple transactions and that's the key to superfluid once you open a stream the money just keeps flowing without having to ever touch it again now for each number we have 25 000 dollars in bounties for top applications we have some integration bounties up so if you want to build something you know integrating with other applications and as i said you know it's very programmable it's very composable so you can pretty much build anything and if you're lacking ideas which is often the case just think of what what exists in d5 and then say why not stream it right you can build a streaming exchange you can build streaming lending you can build streaming derivatives we have all sorts of crazy ideas for you so just come at us now if you want to try it out you can go to our dashboard it works on i think a dozen networks at the moment including all the test nuts and you can just open a stream very quickly and sam will help you open a stream later and uh that's it from me now i'm gonna pass it to sam who will show you how easy it is to actually build with superfluid and yeah hopefully some of you will hack with us over the weekend cool well thank you fran um yeah so i'm sam i hope lead developer experience here at superfluid um so i'm sure if you're hacking in the hackathon you'll see me again throughout the weekend um but as friends said if you want to just visually get started you can go to the dashboard there at app.superfluid.finance on the developer side though we've built a lot of high quality tools to let you interact with the protocol as well so you can see a nice little list here the first of them being a javascript and typescript sdk called the superfluid core sdk to just really create flows with a couple of lines of code in javascript or typescript we also have a subgraph deployed on every network we're deployed on right now so you can write your own custom subgraph queries we also have some solidity libraries that help um with just writing code and solidity interact with protocol and we have a nice list of example applications in our examples app repo that you're welcome to take and fork and use there as well and as fran mentioned if you're looking for ideas uh we do encourage you to think of your own things because we're excited about what you guys build that we might not even be able to project yet but if you want some free ideas you can go to hack.superfluid.finance and see some there typically i've found that giving hackers some ideas to start with is usually pretty useful but you know i mentioned those as the the four kind of main developer tools but the one that i'd actually probably start with as a developer is the superfluid developer console so you can get there at console.
superfluid.finance and from there you can easily write your own custom subgraph queries without having to go to the graph explorer and do some other things like you can have an address book for different streams you're working with you can store addresses there so you don't have to constantly be copying and pasting addresses as you're developing which is always a pain so getting on to the the specifics here of how you'd actually go about building with superfluid as fran mentioned the first kind of primitive that you need to understand with superfluit is super tokens so a super token allows you to do anything within the super fluid protocol so you can send streams with it and to get super tokens you can either use a native super token so we have some protocols in our ecosystem that have deployed native ecos native ecosystem tokens like ricochet exchange for example who is uh who is here in the attendance but a key aspect of defy is interoperability so if you have any erc20 token that you'd like to stream we've deployed an erc20 wrapper token that you can just call upgrade on to deposit that erc20 or just wrap that erc20 token in and get super tokens that will just map to a one to one equivalent of how many tokens you just wrapped so if i have die i can upgrade that die and get super token die in return which is just die x and then if i ever want to downgrade that so meaning i just want to unwrap it i can call downgrade and get those erc20 tokens back and the super tokens are just burned and the the advantage here is that we have a the real time balance is always calculated like fran said so you can always be assured that the number of erc20 tokens you have wrapped here will be available to you to downgrade at any time so in terms of actually opening a flow as you can see this is just one line of code this is very simple with our sdk or with some of our solidity libraries you can create a flow just by passing in the receiver address it could be an eoa or a contract address you just pass in the token address which is a super token address and you pass in the flow rate and the flow rate is in way per second so i'll show you an example it doesn't look great on a slide but to give you an idea what that would look like if you wanted to send a thousand tokens per month you'd send that a kind of nasty looking number there as your flow rate and that would send 1 000 tokens per month so that's kind of our create update and delete pattern right if you want to update a flow you basically just swap out create for update here and you can update a flow if you ever want to delete a flow you just pass in the receiver the sender and the receiver and you don't even need a flow rate you can just pass in sender receiver token and you'll be able to delete that flow that way the last thing in terms of all the crud functionality we're used to is uh reading data so if you need to get data about a flow you can just call git flow pass in the sender pass in the receiver passing the token um and we'll return to you the flow rate and the start date of that flow so with that information because you know tokens are being sent in real time every second you can always calculate how many tokens have been sent between two addresses at any given point in time so that's basics of you know working with flows there are some more advanced things you can do if you want and one category of kind of advanced things you can do with these cash flows is build super apps so a super app is a smart contract that has specific callbacks on it that listens for actions that happen within the superfluid protocol so if i were to deploy a super app contract and send a stream into it i can have callbacks that will run every time that stream is opened into the contract and i can have them run any time the stream is updated or deleted so one really cool example of this that's in our examples repo if you're a hacker and you'd like to check it out it's called the tradable cash flow so if i send funds into the tradable cash flow contract it's an nft that will send 100 of the flow that it receives to the owner of the nft and then any time i update that flow it will then update the outflow to the owner and then anytime i need to transfer the nft it will just transfer all of the outflow from the nft to the new owner so you can imagine some kind of really interesting revenue-based financing applications default applications things building on top of just like either subscriptions or standard payments that get really interesting with super apps but that's a quick crash course on building with superfluid like i said if you have any questions if you're a hacker i'm sure i'll see you at some point this weekend um we'd love to help you guys out so with that i'll pass it back to friend all right guys so i hope you've seen that streaming is simple right like we we see streaming as a natural evolution of tokens right you shouldn't just be transferring them like we've done for thousands of years you should be able to also stream them because blockchains are supposed to do things we couldn't do before right so what i would like everyone to do is to get your first stream so whip out your phones and you can scan this qr code after first connecting to metamask on arbitrary and there you'll find a button which will give you a stream now the stream is in the bgt super token bgt is the the token you need to get lunch during the event so the streaming bgt will start coming to your uh to your wallet and you can then just access it every second you'll have a bit more money to spend on lunch so they said there's no free lunch but if you came here you got free lunch so uh but that's not funny enough right so what we did is we built a bit of a game you'll be able to see more of this during the event but what i'd like you to do is buy someone lunch so we're streaming you funds right we're streaming you uh some tokens but don't don't keep those you know stream them to someone else the person with the highest flow rate at midday on sunday is going to get some exclusive nfts that we've developed just for this event and all you have to do is basically be a nice person meet every whoever you meet just offer them lunch send them a stream whoever has the highest flow rate wins now there's some tricks the game is not perfect it's gameable but the game to game it you need to learn more about the protocol so you can come by our booth if your stream is still open we'll send you a pull up and we'll teach you a bit more about the protocol all right well if you if you couldn't do it in here i know the reception's not very well we'll be we'll be outside afterwards and i think we we still have some time so if anybody has any questions uh for me or sam um yeah
Automatic transcript — names and jargon may be misspelled.