New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Swarm City: Decentralized Peer to Peer Commerce

DevconSun, Oct 7, 2018, 12:00 AM

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/3/swarm-city-decentralized-peer-to-peer-commerce We will describe the technical architecture of Swarm City. Specifically how we use Whisper to communicate and initiate the payment without having to send a public key. Speaker(s): Michael Thuy, Stefaan Ponnet Skill level: Intermediate Track: Developer Infrastructure Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 3 was held in Cancún, Mexico on Nov 1 - 4, 2017 Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

Transcript

oh ok good morning so swarm city so just as many other interior projects who are trying to as this one thank you we are this is our vision just like many other team projects we want to enable humans to transact create and share value without a middleman or a third party on a global scale generating contextual reputation our mission is to do this in a way where normal people like our parents actually understand what we are doing so we don't want to have people experience the blockchain basically we want to really make it really easy to use today we want to discuss two topics we are trying to solve a Tyrian bite problems that we encounter in creating an app that is consumer facing so the first thing we want to talk about is the IP of s consortium the second one is the gas station so the first thing i PF s consortium so if you want to create an app like we do that's totally decentralized you still need storage we need to find a way do you have data persistence so even if you do it on ipfs you have to make sure that your data is persisted over time the way we came up with that solution is really interesting because it's the way we came up with solution actually is kind of the solution it's collaboration because it's key in the blockchain world so we sat together with givethe in Barcelona and many other people and after a night of brainstorming we came up with this really simple solution open your data if you've been mined for an in-depth or more in that technical overview of that solution I'll hand it over to Spanish okay good morning everybody so the solution we came up with for the IP vest consortium is actually that we created smart contracts so by the way this works on top of another persistency consortium project by Piper Mariam so we try to extend it a little bit and make it more in general for that everybody could use its in like a more flexible way so we created a smart contract the I previous proxy contract and this contract will just emit events so we have true to events like hash added so we have an IP this hash gets edit or needs to be added to the consortium it has a time to live for example and then the IP of s has itself and the hash removed function so if you don't need the data anymore and you want it's out of the consortium so it's not pinned anymore you can do that then in a smart contract itself we implement the two functions add hash and remove hash which basically just emits these two events so it's very low on gas to actually call these two functions then all these members in the IPS persistence consortium they will install a script on there respectively respective ipfs notes which is a proxy listener with just a script that goes and listen to these events on that IP vs proxy contract so that's a general set up now there are a few more things there for example the IPS proxy contract contains a list sort of a white list with all the members of the IPS consortium members so that means that's all this their public keys are in there so it can actually verify if they call the contracts so that only IP this member hashes are pins in the I previous notes itself so there are different ways of adding your hashes to the IPS consortium so first of all if you have a DAP or a script which one - which wants to pin content you can just call the function add hash or remove ash so that's a way of from doing it from your tab itself for the front-end but we also expose these ipfs events as a separate solidity file which you can just include in Iran's contract so if you're the the logic of your DAP actually needs to store IP this content from from Unchained basically they can just create your contracts by implementing IDs ipfs events and then the consortium members can add their contracts to the IPAs proxy suite as a second list in there and if they added to the IPAs proxy contracts then these proxy listener scripts will also start to listen to these same events in all the specific smart contracts that they use now concerning the governance of the IPS consortium so we don't want one single owner to manage the consortium so that's why we added multi-member so that's basically the multi C codes to vote on adding or removing members all the members they pledge to persist each other's data and they allocate an equal amount of disk space or they sort of donate all an equal amount of disk space in the consortium so it's interesting to notice that so we can deploy one of these contracts which has a certain quota m-- and all the members there they say ok we are going to do this like for example with the quorum of 10 gigabytes but it's very easy to deploy a second contract we then has like for example a quorum of 50 gigabyte so you can just choose to set up new of these contracts some of the future enhancements that you want to bring is that we can also do painting via whisper so the ideas attitudes just call or create a data data payload in whisper which has the same commands to add hash and remove hash which is the ipfs edge itself and time-to-live they we create a hash they will actually sign with an elliptic curve signature this payload and you can just send it to a whisper channel and we can have them the script listen to this whisper channel and just pick these things up so to give a round up on the IPS consortium so we have the possibility to do unchained pinning by smart contracts we can do off chain pinning by the tab or the scripts which then perform the transaction we can using the whisper solution also to obtain painting without a transaction so just buy sign it with your with your own key we have the multi-member voting to add and remove participants without a quotient but on top of that we also supports that the network is permissionless maybe I'll give it back to King sir so that's that's a really interesting case so anyone can run this proxy script at home on their own computers and like we saw in Barcelona a couple of weeks ago when the Spanish government tries to block IP FS host names that we think it can be powerful that many people can actually have a voice and run this software just on their own computers currently yep ipfs consortium is of course in kind of prototype or or it's it's like we we proved that it works but of course we are inviting everybody to to join us in to make sure that we can have data persistence in at the central point so the second thing we want to talk about is the gas station so what we do if we want people to abort or project of course we send them some smart city tokens but then we always have to say and you need a little bit of heater to actually do something with it because every transaction and then you have to tell a whole story about gas right so for for a lot of people like my dad for instance he was like wow why do I need two coins now or two tokens so our ideal solution will be that it is a one click solution in the front and in the app where people can actually exchange a little bit of their tokens for gas our design process is it's kind of funny I think because we always use the metaphor of the city so if you drive around the city you of course need gas and what do you do then you go to a gas station oh I'm gonna hand it over to spoon ask for this yeah thank you so the way many of the existing theory projects solve it currently is by just giving away some freak just sending some guests to a certain address which is created in a wallet in the hope that they will actually use that gas to perform transactions in their ecosystem or to use their app but most of the time it can't be sure if they will actually use the gas for debts or to just do some sort of sibling tag and just try to collect as much free gas as possible another problem is also that if your app becomes very successful you have to have a lot of eater somewhere just to provide everybody with some free gas to get started so we tried to come up with a solution where you can actually just do the exchange we have like durable solution that people just are able to pay with our tokens for getting the initial guess so it's always it's also a two-part solution so first of all there's an API which needs to run which is gas station service and next to that we have a gas station contracts that's deployed in lockstep with that so people can actually just run it themselves so first of all you decide which ERC 20 token you would like to support so in our case it's Warren city token and then you send some initial eater which is this one eater because just about providing initial guesses it doesn't need an big amount of feature you send it to the gas station to sort of fill it up with eater so that's the setup if you then have a dab so the use case here is that you have like a new user who someone just sent some a couple of this swarm city tokens but it doesn't have any gas weekend's doing a transaction yet so the thingy can calculate is how much way he will actually need to perform you know do the first transactions that he wants to do to get started so we will ask to the gas station service what is your price for this amount of way that I will need the gas station you will consult a public price API to see what the current exchange rate is for either to swarm city tokens and it will reply to say ok this many way would cost you that many swarm city tokens the next thing that happens is that the device itself for the tap will sign an allowance which is a year C 20 function to the gas-station contracts for that amount of swarm city tokens and on top of that you will create an elliptic curve signature for all these parameters with the amount of swarms EPOC is going to give and all that we're going to adapt one of the next slides so it will send its Cyan's action back to the gas station service and then the gas station service will verify the transaction this will decode it and if it all fits all the prerequisites you will actually send gas to that address so the address of the tap to execute the allowance call when you see that that gas has arrived he will execute the allowance transaction by just putting it in the transaction pool and when that transaction is mined the gas station service will call a function in the gas station which we call push fill so let me quickly show like how it begins it's not a complete function but just to get you to give you an idea about how it works so what is it if we push fill so it provides the token address which is the ERC 20 token it you support or you want to exchange it gives you a validity date which is expressed in a block number so this sort of personal exchange rate is valid as a validity period we had a random number to create some entropy on the but that will come later also you will say how many of these forms the focus you can take from him in exchange for how many way in eater you will give them they also provides the gas tank client which is the address of the taps the wallet address from the tap and then the signature so the thing that the contract will do it will actually recreate that same hash with all these parameters and here he will verify if the signature of all these parameters are actually match up to the address of the gas tank lines if so he does the actual exchange so the code is not here and he will mark that specific would say contracts or that specific configuration to be executed so we can't repeat it twice concerning risk mitigation there's one problem because you have to trust the gas station service that it will actually also perform the second transaction if you give him the allowance transaction you must be sure that he actually doesn't does that's push filled thing so to mitigate that so I told you before that's the API service response with so many way because that many sworn tokens but actually is also going to give a liquor signature on these parameters with his because as a wallet obviously and then we create the second function which is called push sorry pull fill and it will verify the same parameters which will actually just verify if these parameters were signed by the owner and this function can be called by the gas station served by the client who uses the gas station so he has a certitude that if they do the exchange they sort of mutually give the allowance to do exactly that's a transaction so why would you participate or would you run a gas station because we we can define or you can define an uplift for the price you sell your eater for so it means if you would for example say 10% uplift if your gas station sells out because the amount feature decreases the amounts aren't tokens increases you will end up with when you sell over your eater with an amount of swarm city tokens which equals like one point one eater so yeah so the result of that is that anybody can just download that API script deploy its own contract primates we call it with eater then configure it like what ERC 22 do you want to accept in your gas station then tell it how much either markup you want to sell it for and just start it you can find everything we are doing these get up links and also on this is dots farm City you will find more information there's of course one more thing the time you created so as you see the gas station it's at a certain time it needs some maintenance because it's needs to be refilled because like the eater gets depleted in the ends which also try to solve that and we have like prototype code of that which we can you can also find an archetype so we created an integration with eater Delta so the thing is that the gas station serve it itself it contains a wallet so when it's it has a certain amount of swarm city tokens it's almost depleted of eater the gas station service can actually look into the eater Delta and try to find by order for swarm city tokens for eater so when it finds one you will actually purchase it because it's like anonymous I mean you do need an Accounts or registration or whatsoever so we just created like a machine-to-machine trading that actually binds eater in exchange for its worm tokens so the thing is you can actually refill or automatically refill your gas station with easier to start again and closing that loop and so this can be fully automated so you don't actually need to manage the gas station anymore you just can have it run when it does the exchange you will actually end up with more eater than you started to it so you will end up in this situation with like one point one eater instead of one eater so yeah we thought it was appropriate to call that the gift that keeps on giving so basically that is thank you [Music]

Automatic transcript — names and jargon may be misspelled.