Augur

Devcon 1 · November 2015 · 15:24

Dr. Jack Peterson presents Augur, an open-source, decentralized prediction market built on Ethereum. The Devcon 1 talk explains how a market in which traders bet on the outcome of real-world events can run without a central operator, with smart contracts handling trading and settlement.

Speakers

Topics

From Devcon 1, hosted by Ethereum Foundation.

Transcript

thank you so this is a short talk so I'll go ahead and just jump into it I was going to give a you know basic how prediction markets work introduction I thought we put together this really nice video and lead up to our crowd sale so I'll just show you the video and we'll have time for some actual technical stuff auger is a prediction market platform that rewards a user for correctly predicting future events prediction markets allow users to purchase and sell shares and the outcome of an event the current market price of a share is an estimate of the

probability of an event actually occurring the prices of each share adds up to one dollar so if you buy a share and even odds in the cost you fifty cents if you end up being right you'll receive $1 for that share these markets rely on a scientific principle known as the wisdom of the crowd which states that if you ask enough people something their average answer is far more accurate than any expert this allows us to create one of the most powerful forecasting tools the problem with previous prediction markets is that they were centralized allowing them to be easily shut down another problem is that with any prediction markets someone

has to report what actually happened after the event occurred in centralized markets one person does this which means there could be mistakes or outright manipulation with augur will have thousands of users reporting on these outcomes using something called reputation using augur anyone anywhere in the world can create a market asking a question about anything market makers provide some initial funding for the market and in return receives some trading fees anybody can freely buy and sell shares in the outcome of that market in the current share prices provide the best estimate of that event occurring imagine

being able to Google questions about things that haven't happened yet and receiving accurate odds of their occurrence that power the power dat glimpse into the future is what we believe everyone should have access to okay so that's the sort of a high-level overview of just what what are we making we're making a prediction market platform now so we've learned a lot of sort of low-level stuff about etherium and how you make decentralized applications over the past few days and so you might be wondering how the heck you make something like that on aetherium just using smart contracts and I know this is a fairly technical

audience so rather than going through my usual sort of high-level augurs feel I thought I'd actually go through the details okay so so this is the augur interface now the first thing I want you to notice is that all you have to do is go to a website so you go to client augur net and the way this works is we want this to be as much like just using a regular web site as possible even though it's decentralized on the back end so you don't have to be running a local etherium node although you can and if you are it will talk to it but if you

aren't it talks to one of our hosted nodes so I have to do is go to client augur at and you'll be presented with our interface so there's three trending markets you can see here in the middle and so one thing we'll notice is that there's one market that says will the Sun turn into a red giant and engulf the earth by the end of 2015 and it sits at 18% so now that seems maybe well that seems maybe a little high right because I mean the Sun is probably not going to turn

into a red giant and engulf the earth by the end of 2015 so we could probably make some money off that because the this says of them in the market price there's an 18 percent chance of that happening so so we need to create an account to do that now you so you can use your existing etherium accounts you can use this using a local node in which case it'll just automatically connect to your account by talking to by talking to the node by talking together or you can create an account using our system and so you'll notice in the top right hand corner we have sign in and register buttons so again looks very much like a regular website so if you click on

register well I'm gonna I'm gonna walk you through the steps of what happens after you click on it so you click on register and type in your username and password and I've got the two inputs there you'll see whether like that and through May we made a tool called which we called key theorem we're fairly proud of that name and it's basically just the key man it's a standalone JavaScript key management tool for etherium and what it does is it is it's it's JavaScript code that creates the the same key store or files that get natively uses so what happens is it generates a private key which is just a random 256 bit number it

also generates random salt and neutralization initialization vector puts those through it puts the password and the salt through I think we're using 10,000 rounds a script to generate an encryption key and this so this is a symmetric encryption key and it's used to it's used to encrypt the plaintext private key so this is this is your new accounts private key and we and we do the encryption using AES 128 which is just a strong symmetric cipher and so one one interesting thing here is that

this is by design the exact same process that that get uses right and that means that this encrypted private key and the the JSON file that can be exported from this can just be used natively in Gath and so you actually can export this and just copy it into your key store directory and you can just you can use it you can you'll even use the same password because it knows how to read the encryption parameters right out of this file now what happens with this encrypted JSON file is we store it in ipfs and this so this file is assigned a

hash by ipfs according to the data in the file and because we want to associate this data with a username which is sort of an arbitrary string rather than the ipfs hash which is you know it's sort of a hard to remember 256 bit number what we do is we have well we have an etherium contract that is just it Maps the username that the user typed in onto the ipfs hash and their way think if I've been at at me so I need to move faster and so one thing I want to comment about this is that because when you look up the hash it is broadcast to

the DHT and ipfs this is not as secure as it could be and I'm talking to one I P FS guy about this and we are because of this we're going to also have an option of just storing it in local storage okay and so the the converse of this is when you log in you supply a username and password is sort of the reverse of this magic happens you have the decrypted private key which you can use to sign transactions in the browser using the etherium J s TX library and so we so we registered for an account and because right now we're on just the

augur private chain while we test we give all new accounts just 100 free ether it's not real either so I got my hundred free either and you can use the faucets to get cash and reputation so you actually place bets in the prediction markets using using cash and so now we're finally at the point where we can bet on this absurd event and as the comment says Yahoo so yeah so you can see we have like a price series and comments comments are still a little finicky right now and so we want we want a bet on no right because we think that

man this is this is really under price given that we know this isn't going to happen so I'm gonna say we're gonna buy 485 shares of no this will bring the probability up to 100% because we know this isn't gonna happen since it's all profit and click buy now we have 485 shares pending about 12 seconds later it clears and now we have that many shares so you can see the price now has moved up to 100% okay so what just happened here well so want to click the Buy button but what happens after that so the your buy order gets serialized bundled into a transaction and on the augur trading contract there's a by

shares method now this the transaction actually gets signed in the browser right so this I said that you don't need to have a local guest node running in fact you can sign this just using javascript in the browser then you submit the signed raw transaction to the etherium node that way and in that case the etherium node does not ever need to see your private key it just gets the encrypted it gets the signed transaction then we send it to Jeff Jeff cross broadcast the transaction to the network and then we just pull get see when the transactions been incorporated into a block and this is what our architecture looks like so we've got our very happy

user and this interface that I've been showing you is so that's the sort of pinkish purple blob where it says auger client and because a lot of the nice tooling that that has been talked about here basically didn't exist when we got started we're mostly just working with our own stack so we have our own middleware and and that's the way it talks to aetherium which here would be on the user's computer in the example I just showed you it's actually running on our remote server and that talked to the decentralized network so let me let me walk you through if I have time two minutes they walk you through exactly

what happens when you when you buy shares so so that this is this is sort of a simplified version of our markets data contract so there is there's a so all of our contracts are written in serpent and we all information about shares and bets that people have placed they're stored as data on contracts all right so the set of contracts is fixed and the the trades that you make and who has made them and the events that are incorporated in markets these are just data on the contracts sort is basically a big dictionary and we have a modify we have a modify shares method so this

method gets called so if Alice so Alice buys two shares of outcome 1 and market em so we invoke modify shares and basically this is what happens right so this is that data structure up top then we can say okay now she has two shares of point now I've described this sort of somewhat complicated system and it's augers really it's too big for one contra originally had it all in one contract there are some nice things about that but basically it's way too big to upload so we actually have it split into 26 contracts and so our contracts are we have data contracts which basically are there they have things like this market

data structure and then they have setter and getter methods and these can be imported into the function contracts which sort of make use of them and the reason we have it set up like that is so that most of the functionality is in the functions and the function contracts and because of that we can we can make changes without having to throw out all the data which is even when we're testing is really nice so I want to give you an example of how multiple contracts work together just very quickly so this is in the little walkthrough I just gave you so many use are what are called our faucets

so this is is your free cash and free reputation so these are methods on the faucets contract which is it's one it's one of the function contracts and it has to import the cash and the reporting contracts to do this so that's the syntax to do this in serpent and actually don't know the syntax and solidity but the syntax in serpent actually requires you to it's somewhat verbose and requires you to actually specify the address of cash and that's somewhat inconvenient because that will change if cash contract changes and that if you have you know multiple dependencies that can be a real pain so what we did is we have a dependency

resolution script that takes care of this for us so we can use this sort of pythonic syntax import cash as cash and it inserts the externs as needed and then we can just use it that way okay and I also just wanted to say all our code is open source I know this was just sort of a whirlwind tour it's all at on our github so if you want to pitch in please do yeah that's it