OpiDoki: Truth Made Easy. Chris DeRose's OPI and Blockchain Beach 2104 Hackathon Submisson

OpiDoki: Truth Made Easy. Chris DeRose's OPI and Blockchain Beach 2104 Hackathon Submisson

OpiDoki is an easy-to-use "Oracle Programming Interface", designed for broadcasting "truth" onto the blockchain. This app enables anyone to easily participate ...


Okay, it's been a long night. We're doing a lot of programming and we have something very usable that is showcase-able and works on production net. And I'm really excited about it. Here's the deal. It is an oracle programming interface. I don't know what else to call it.

That seems like a good enough term. Right now with Counterparty or with any of these smart contract tools, we need to have oracles to tell us when things happen. We can't just shell out to the operating system or have miners do that because when you look at a webpage. Everybody's going to look at a slightly different version of it. So how do we know which one is true? So we do have these centers of truth in the bitcoin ecosphere. So what I wanted to do was create a tool that anybody can create an oracle with.

So that is what I've created and I call it OpiDoki, Oracle Programming Interface Doki. So one of the nice things about this implementation is it's really easy. You go to the main homepage and you see just a couple fields, one of which is a time, and a webpage, and a text area where you can type in JavaScript, or alternatively you can choose to choose a regex, a search string. At the time you specified, a server will load the webpage and it will run the JavaScript that you've typed in or the regex. At that time, what the evaluation is of that JavaScript, the return value will be broadcast onto the bitcoin block chain. That broadcast is a standard broadcast for Counterparty.

That means you can use it as a means of resolving a bet, or as a means of resolving a smart contract. When you create the actual bet before it publishes, there's a feed address that people can look at to register their bets. And from there, you can publish it or promote it. You can send links around, change the tip style if you want. You can create these things for just about anything. So I created a couple samples.

We'll use one reading the Yahoo! sports pages. So what we'll do is there's a football game later on today at 4:00 or something. And we're going to type in some JavaScript that will read that page and determine who the winner is of the game, but it will run six hours after the game when that score's actually filled out, and then it will go ahead and pop it back to the network. But you could just as easily have programmed it to do something. . .

and I think we have some of these examples even in the repo if anyone wants to check it out. Hey, Aaron, what did we do on the other examples? We did stock market? we did nba games, we did stock market. Stock market. And property ownership. So you can see if maybe the S&P closes after a certain time at a certain amount and you could have bets on that, or a smart contract execute on that. Maybe you want to execute your own sort of order.

And we also did the local property appraiser's office. So let's say you had an amount in escrow that was to be delivered contingent upon, let's say, the sale of a property. Well, you would wait until that property has been updated. You knew the time that it would be, and then you would check the property's screen to see who the owner is. And at that point, it'll broadcast on the network and it would relinquish the information. I think what's also really important about this is that we understand that a lot of the betting solutions out there have a lot of culpability in what they're doing.

Like, they know what they're doing. They're facilitating sports bets or something. And when we have a service such as OpiDoki, there's no culpability. There's zero knowledge of what's happening with the transaction. It's merely broadcasting truth and there is no ability for anybody to say that they were up to no good in a regulatory environment. It's just a service that's as culpable as Yahoo! is for publishing the sports scores.

So we think that that's a more sustainable model. Or at least, I think that's a more sustainable model going forward. So all right, let's take a look at the screens and see what you think. Are we recording here? Great. Okay. So here you see the homescreen of OpiDoki.

It's a very streamlined interface. And the core of OpiDoki is to manage truths, and it lets anybody go on and manage truths. You don't need a user account or anything like that. The screen is divided in a couple sections right off the bat. The Create a Truth is where you would go if you wanted to create a truth. And you can also explore truths that are about to happen or truths that have happened from others.

So if you see here, these are some upcoming broadcasts of truth. These are some previously broadcasted truths. You can further explore it by clicking on the links above. These are broadcasts that happened. We'll come back to this in a second. And these are broadcasts that are about to start.

So I did a couple just to get started. The sports broadcasts are really easy. They're tied to, basically the Yahoo! pages. So, in this example I guess this was one on Dallas Cowboys there, something like that. Here you can see that this has not actually occurred yet and there's an @ sign there, indicating that the Green Bay game today is going to be populated with a number of something. So in that case, that's an upcoming broadcast that will be resolved at this time, six hours after the game.

And when it resolves, the output will then end up in the broadcasts, and it'll be in the expired screen. In addition to that though, I have some things like the Broward County Property Appraiser's office. Excuse me. Here, you can see that there's a brief little JavaScript segment that'll look and see who owns this property. So you could use this for a smart contract or some such thing, whereby the outcome of that broadcast would indicate, does this property belong to Chris DeRose or does it belong to the person who purchased the property? So in that way, you could facilitate a great smart contract without having to deal with a middleman or an escrow agent, or something like that. So those are some easy cases.

There's also, of course, the stock market examples here. Here's one. This is a pending prediction of whether or not the S&P will go up by the end of the day or down based on the number that's here that was entered at the time. These are the types of things that you can do. So let's go ahead and create our own broadcast to demonstrate the feature. I've created some easy clips here so you don't have to watch me figure this all out in my head.

Here's the title of the truth. All this is optional but it helps to tell people what the numbers will mean. In this case, this is the New York Jets game. Now I'm actually doing one in the past because I want to show everybody what happens when it resolves. So this will execute as soon as I'm done creating the truth so we can see what the output looks like. And that happened in the past.

So similarly I'm going to set this as also having happened in the past. I'm just going to set it to the early beginning of the day today, so that when it goes in my processing queue, it's immediately marked as overdue for evaluation and it'll get processed quickly for the purpose of the demo. And then here is the URL. So in this case this is the URL. It's another one of those Yahoo! pages. I'm going to paste that there.

And lastly, here's the JavaScript. This JavaScript was similar to all the other games for Yahoo!, but in this case it evaluates the values of the home team sell and the away team sell, and then does a comparison there on whose score is higher, and that would be the output of the broadcast. So here I'm going to hit create, thus entering it into the system. Now I need to fund my truth. Because as we know, the block chain has intrinsic value, because there is space that is limited and we need these things for smart contracts. So I'm going to go ahead and scan this QR code right there.

I'm going to send it. In this case, I need some flake in order to record. And the flake I'm sending it is $0.20. Now if we were monetizing this, we could use a greater value and keep the difference ourselves. But for the time being, I kept it nice and cheap.

And so I'm going to go ahead and send that amount. I hit the send button on my phone. I'm going to type in my password so you can't see it. And it is sent. It is now broadcasting. And at some point, there we go.

The broadcast was registered. So you can see that now that it's sitting here in the pending queue and it is pending execution. But you can also see that the broadcast is open. The feed has been published on the Counterparty system. It is available for execution at the time that it is going to execute. Again I said in the past, so it's probably already executed by now but I'm not going to update the page just yet so you could see what happens.

If you want to look at the transaction block chain, here it is in the mempool right here. It's unconfirmed. That's the link to that transaction. And you could similarly look at it in, which is the Counterparty scanner. However the Blockscan is behind by about a block, so it'll have to confirm it for that to show.

But that link is valid and it'll show up here soon. So I'm going to refresh this page because the backend has probably executed this broadcast at this point. And I hit refresh, and in fact, it has. We see that the resolve was won, that the New York Jets won. And we can see there's a screenshot here as well of what the page looked like at the time of execution. The job score is nice and highlighted.

This a reference for me to use. And that's that. Now if you were to set up something that was going to execute later on today, what you would probably want to do is circulate the link to it. And you could send that link and comments, or you could circulate the link on Twitter, whatever you wanted, so people could bet on it. Or if there's a contract or something that people wanted to make on it, then they could. And then again, just for the sake of showing the judges, this is in the block chain.

This is the transaction for closing. And this will resolve in Counterparty as soon as the next block interval goes. So that's it, that's the program. That's what we did and I hope everybody likes it. And maybe we can make this happen and put it in use on the greater Internet.