hi I'm Charles hoskinson Chief Executive Officer of input output Hong Kong and this is a brief introduction to Smart contracts so what are smart contracts and why should we care how do we even begin to explain them what I found is the easiest way to begin understanding the notion of a smart contract is first to kind of think about Bitcoin to look into Bitcoin itself well the Bitcoin protocol what it really does is it enables push payments uh so you have Alice and Bob and Alice wants to push value to Bob she would do so via a transaction Alice's value is bound to an address as is Bob's value and the receiving address has absolutely no counterparty risk so Alice is able to push value to Bob and after 60 Minutes or six confirmations usually uh ownership is probabilistically uh nearly guaranteed and this is a beautiful very elegant very simple payment protocol most of the design focused and Innovation that we seen over the last 6 years in Bitcoin has focused heavily on improving transactional security as well as robustness uh and so we say okay we have things like multi-party signatures we have things like hierarchal wallets we have things like cold storage solutions and we even have specialized Hardware that allows us to have a great degree of control over who we want to send funds too and the conditions behind that in terms of uh how many signators are required and so forth and as well as how that value itself is going to be stored but one of the big problems is what if I want to broaden Beyond just signatures and I want to actually attach arbitrary rules an instruction manual behind that transaction uh so for example let's say Alice wants to push $20 worth of bitcoin to Bob if and only if Bob mows her lawn well from Bob's perspective he has to know she has those funds and from Alice's perspective she has to know that's been done you see and the Bitcoin cor protocol and any uh protocol derived from the same mechanics really doesn't have enough robustness and its designed to be able to facilitate this type of a transaction and even if it did that's a very specialized transaction just to two parties so this in essence is really the notion of a smart contract the most effective mental model is just a basically view them as a value flow so just like Bitcoin where Alice is sending value to Bob or to another source but were instead going to attach rules to that value flow so in general uh you one cannot use that value unless those rules are satisfied and that's really what a smart contract is and there's two broad categories of smart contracts there are deterministic smart contracts and non-deterministic smart contracts uh the primary differentiator is basically if the network has sufficient information to determine an outcome without the need of outside information uh and we'll go into this in much more detail in a bit in both cases the overall goal of smart contracts in general is usually to take some form of centralized or Federated service and decentralize that service in order to improve transparency reduce the need for trust and in many cases you actually gain a lot of economic efficiency because you no longer have to pay a central actor to do something so this isn't a nutshell what a smart contract is it's just basically a value flow from one party to another with some sort of rules attached to it and you can break it down into two categories a deterministic case and a non-deterministic case so let's examine the deterministic case first because it's simpler so the kocal example that one usually uses for the deterministic case is the idea of a lottery so let's go ahead and examine uh a standard Lottery a lottery without any smart contracts so in a normal Lottery we'll have Alice and Bob and her friends they're all going to send value and select some set of numbers to a central actor who in turn is trusted to store those funds and that's called custodial trust and has to conduct a fair game and that's called House trust so you're trusting the actor to actually do two separate things store the money as well as conduct a game the central actor will run some form of random number generator and then we'll have some form of rule to determine if there's a winner from the people who have submitted numbers now the big issue here is you have to trust that Central actor and there have been many many many many cases of lotteries being fraudulent this is typically why they're highly regulated and also why usually winners have to be identified or else how do we even know the lottery uh uh is actually paying people so this is one of the uh problems with a central Lottery system so what if we could build a lottery with deterministic smart contracts so let's look into that so with a deterministic smart contract Alice Bob and her friends they're going to send value along with chosen numbers so this many ways looks identical to the Bitcoin transaction address model and the address is going to be a special address chosen specifically for a smart contract and so they're going to send value to it and they're going to put a bunch of rules and conditions uh such as the game rules how winter validation is going to work how long funds are going to be pulled and other information and then the network itself is going to execute that Lottery contract and it's going to uh use some sort of mechanism to determined Randomness such as let's say the hash of a block at a predetermined height uh so you could say at height 100,000 take the hash of that block and uh the exor distance to that hash whoever is closest to it will be the winner this can be an example and uh there are many other ways to do this but this is a considered to be a very secure way in any event what we've basically done is we've created a situation where Alice Bob and the other people participating have now sent their value to a specialized address not a central party they've sent it with rules and the network itself has sufficient information to always be able to determine a winner and the payment to that winner is absolutely guaranteed now this is a really powerful idea for some some sort of simple problem what are our advantages well first participants can be anonymous this is generally not the case with most lotteries because usually you'd like to know that a winner has been paid and unless you have some sort of blockchain based system behind it it's very difficult to verify that with a smart contract based Lottery you actually can second the rules and mechanics can very easily be changed just by simply changing the smart contract and that's done in a very transparent way but then it can be done to actually add uh third party payers such as taxes and also add in perhaps some Regulatory Compliance conditions for participants pools of funds can only be spent uh the way the participants intended so all the custodial trust is completely removed and no Central actor has to be paid that's a humongous Advantage uh because many of these Central actors uh take fees and that adds no value to the people participating okay so that's in a deterministic sense and the deterministic sense is very simple it's just Alice and other actors will send their value either to another person or to a specialized address they'll go ahead and attach rules to that transaction and the network itself has sufficient means to determine uh how that value needs to be transacted and spent but what if the network doesn't have sufficient information this is the non-deterministic case so the network facilitating the smart contract doesn't have enough knowledge incumbent to itself to actually say who is a winner uh and so you need some sort of outside party or trusted source and we call that outside party typically an Oracle and these are the types of problems that come uh usually up when you're talking about human behavior you're talking about certain events you're talking about predictions uh so for example if you and your friends have a drinking game and you bet some person uh that he can't drink uh 10 shots of some drink uh without passing out well you and your friends are witnesses to that but how will the Bitcoin or ethereum or other network even know that event so this is an example of an on deterministic Smart contract you need some sort of third-party Source a trusted source to be able to make a value judgment or whether that event happened or some information another thing could be price uh flows so what is the value of Bitcoin in terms of US dollar this is something the Bitcoin Network actually cannot know so these are non-deterministic problems and they require an oracle to sort out so the kocal example is typically sports betting because it's usually the easiest toy example to keep in the back of your mind so I'm a big Denver Broncos fan I love paint manning I love the Broncos hope they win the Super Super Bowl no matter how hard I try or what bip I propose I don't think anytime soon the Bitcoin network will have the ability to determine if the Denver Broncos have won or lost a game or the stats of a particular Broncos player this is just something that is outside of the network and I have to trust a third party source to import it so while the participants can agree in a deterministic way about rules terms and conditions as well as odds and other factors in the non-deterministic case you're always going to have to specify some form of an oracle to give the smart contract the information it requires for those terms and conditions and rules uh to determine who won or how value is going to flow so did the Broncos win or lose I need some sort of feed to tell the smart contract that the good news is however that uh all the rules so the odds and how people are going to be paid contingent on the victory those can all be deterministically placed in similar to the lottery contract but this does have an effect of reducing the security of the system to basically the reliability of the Oracle in many sense so what can we do about that well we can carefully think and perhaps Federate oracles or create an arbitration process and this was kind of the notion of projects like truth coin augur using ideas like principal component analysis where they try to create uh using clever math ways of reducing the overall trust one would have have on a particular feed and increase the overall reliability of information feeds in general it's unfortunate but true the most desirable applications of smart contracts such as creating value stable currencies so that would be a currency that would Peg itself to the let's say the price of the US dollar or to the euro um or building a decentralized autonomous organization they usually do require some degree of non-determinism but in any event even if the oracles are centralized it's important really understand that one of the godsend of smart contracts is that they will in all cases Oracle or otherwise remove custodial risk from Capital pooling so even though you may have to get information from a third-party Source uh that Third Party Source in no way has to whole custody of the funds and this dramatically reduces liability and does reduce a lot of bit a lot of Fraud and there's also it's important to mention there already are services that provide trusted price feeds and trusted information feeds uh you don't have to look any further than Bloomberg terminals uh so non-determinate smart contracts do actually map well into Legacy systems okay so let's put it all together smart contracts are composable and what that basically means is you can actually take fundamental units of behavior such as a random number generation or an escro contract or a lottery contract and you can actually combine these things together to create highly complex behavior that is emergent from standardized components so you know all the compon opponents behave in a certain way and if they're put together like Lego bricks they actually can produce something even better and that's an incredibly desirable characteristic of any system second your trust model is always uh understandable uh prior to the flow of value and so that's a very powerful characteristic as well generally when I send value to a third party usually there's a lot of stuff happening behind the curtain and I just kind of have to hope that their reputation is good or I have to hope that regulation is good for them to behave in a certain way uh but with smart contracts one of the most powerful characteristics is generally I have some degree of control over that trust model or at least I understand it prior to even sending a single piece of money a single flow of funds the cost of changing rules is also very low so there's no menu cost here you can just simply rewrite some of the code or change some of the modules that you're using and now you can have completely different outcomes and custodial risk can always be taken by the network hosting this smart contracts that's a very powerful characteristic because now we're separating concerns and allow people to specialize and uh have uh much lower liability um and the other wonderful thing is that none of the communication or transactional anonymity techniques that have been developed for Bitcoin uh have to be sacrificed to use Smart contracts so you can use Smart contracts in tandem with mixing services or if zero cash was implemented they could actually be used together and there's many compos abilities characteristics of that so uh this is an example of running an anonymous lottery or perhaps an anonymous voting system for example where you can actually have deterministic and predictable outcomes however you do not need to reveal someone's identity for that um one of the downsides unfortunately is that oracles are needed and they do present theoretical problems as well as practical problems and there is a lot of additional research that's going to be required to reduce those downsides and luckily for us the augur and Truth coin projects and others hopefully will come up with all kinds of cool ideas to uh make these systems a bit more standardized and robust so here's some helpful resources probably the starting point for most uh should be Nick sabo's paper on uh smart contracts uh this came out in 1997 and it is often considered to be the first academic work on Smart contracts Nick sto is considered to be the father of smart contracts and uh there's an H ml version of it on the Nakamoto Institute website uh here the ethereum project uh is the largest and best fended smart contract project in the world and uh there's their web address I'd highly recommend going there and looking at some of their documentation and actually ethereum has developed a smart contract language called solidity and the ays industries Corporation has actually been kind enough to create a series of tutorials explaining how to use stolidity and write your own smart contracts so if you're interested in this and you actually want to start exploring how these things work in more detail uh there's a link to the very first tutorial which in turn links to the other four there's also a great book by Tim Swanson uh called the Great chain of numbers or something like that and there's the web address to it and I believe he's released it under a Creative Commons license so I'd highly recommend reading it okay well that's all I have to say about smart contracts you can reach me on Twitter at _ Charles if you have any questions at all feel free to send me a direct message or tweet to me um or leave me a comment in the YouTube uh thank you so much for listening and I hope this helps you understand a bit more about how smart contracts work and what they are as well as perhaps why they can be useful