# Chapter 3 - Smart Contracts ###### tags: `Module 0` ### Intro Smart contracts are right at the core of building apps on blockchain. In this chapter, let's properly understand what they are. ### Study time Let's start with a situation - You and I place a bet on whose Cryptobot will win in a fight. The winner of the bet gets a reward. Now, there are three possibilities - 1. Your Bot wins, you get the reward. 2. My Bot wins, I get the reward. This seems awfully similar to if..then conditions doesn't it? Simply put, this is a situation where you can properly define the cases - if **x** happens, then do **y**. What if you could express this situation in code? After all, it's just a set of instructions. 1. Check the result of the match. 2. Based on who won, send the reward to their wallet. That is Smart Contracts for you, in a nutshell - agreement written in code. **Smart contracts are simple agreements written in code that are stored and executed on the blockchain.** A bet is simply an agreement between you and someone else, you can literally write a smart contract, put it on the blockchain and the smart contract will take care of all the work(checking who won and sending the reward) for the bet. #### But why codify a situation as a smart contract? When you have an agreement among individuals, there is a need to **trust** the other party. Trust that they'll follow up on their end of the agreement. By putting the bet on the blockchain as a smart contract, we remove the need of trusting each other, and now we **trust** the smart contract and the blockchain. And as we've found out till now, blockchain is much more reliable than humans. Now you don't need to get your palms sweaty worrying if I'll chicken out of the bet if my Cryptobot doesn't win 🤯 A bet between you and me was a rather trivial agreement. Think about the agreements you have with the bank, agreements you have with the government. What if you could make smart contracts for that? Life would be so much better. When your agreements are stored on the blockchain in the form of smart contracts, you can be assured that they will be executed, and also because it's stored in the blockchain, nobody can mess with it. In the next chapter, let's see how smart contracts fit into the picture of decentralized applications(DApps)🔥