# Become a solidity developer: Intro to blockchain & DeFi -  0xPoland S01E01

- Channel: [ETH Warsaw](https://streameth.org/eth-warsaw)
- Date: 2021-10-07
- Duration: 33:32
- Watch: https://streameth.org/watch/yt-YIRsQ5O2Aro
- YouTube: https://www.youtube.com/watch?v=YIRsQ5O2Aro

## Description

👨‍🏫 Marek Kirejczyk, CEO of EthWorks, gives his famous presentation on blockchain, Ethereum and DeFi. You can also get a behind the scenes scoop on the #OxPolandHeist.

0xPoland is an initiative to build an active community of blockchain developers. If you want to improve your coding skills, make sure to join our monthly meetups, workshops and a hackathon in May 2020!

➡️Sign up for our events here: https://www.meetup.com/0xpoland
➡️Follow us on Twiiter: https://twitter.com/0xpoland

## Transcript

welcome everyone it's great to see so many of you today joining and let's talk about what zero exponent is so we started zero exponent with a goal to promote programming skills around etude ecosystem and uh blockchain ecosystem as well we want to growlish polish ethereum community and we want to invite as many people as as possible to join this great adventure which is which is being a blockchain developer being an interim developer and building this wonderful stuff so roughly a month ago we put this billboard in one of underground stations on politica on politecnico metro station here in warsaw there was a puzzle to be sold there was an address of the contract there was some code there was an award to be won and i'm gonna explain all about it by the end of presentation to everyone who would like to know and understand why we put the puzzle there and how to solve it so our goal with the with creating this puzzle to raise attention of developers community and tell people hey there is something very interesting going on in the blockchain space and we're super happy to tell you that it raised we did succeed in raising this attention and we've been described in many places and we've been mentioned on spider's web on just giant t beat hypal but also not only in poland but through in different in different places in different news outlets in the world by very popular deck trip there was uh ongoing discussions on reddit on cryptos even on porchan or weibo which was completely which was a complete surprise to us so what's coming what's your exponent so we're starting the season one today with the first meet up with uh episode one we plan seven meetings in upcoming months up uh uh on second tuesday of every month we're gonna have one meet up so december january all the way up to june and we're gonna discuss all stuff regarding blockchain and specifically programming and coding and everything that relates to blockchain so it's going to be strictly technical meetings and we especially invite everyone who's interesting to join the space everyone who is interesting okay how is that exactly working what is this blockchain or about all about what are the smart contracts all about and so on and so forth so more than that we're gonna have a workshop so we're gonna have in january on 22nd and 23rd we're gonna have a weekend workshop so for everyone who would like to spend two days and get the initial understanding how to build smart contracts that's a perfect workshop and we're going to have a student workshop that's going to happen in march and april and then we're going to have another workshop in may and in the season final finale we're gonna have a hackathon with um awards today of two days of hackings that's gonna be may 29 and 30 and you can already subscribe to the first workshop the january workshop and i think the yeah here it is you can see where to sign up there's going to be a limited amount of places so uh make sure to subscribe as soon as possible so uh if you want to stay up to date with us go to xerox poland.def or just follow us on twitter on zero under the uh handle0x poland and i would like to shout out make a shout out to our media partners cryptodevtv and the zoomed bitcoin those are also great places to learn more about blockchain and e2 and today we're gonna have uh two presentation first one is gonna be i'm gonna be doing the first one it's gonna be called down the rabbit hole we're gonna explain blockchain basics we're gonna write our first smart contracts and most importantly we're gonna solve the puzzle uh that was uh posted in underground uh on the underground station uh last month and that's gonna be a beginner track we're gonna have we're gonna try always have beginner and advanced tracks so there's something attractive for people who want to join the space who want to start learn more and there's going to be an advanced track for people who already know a little bit know how to code but would like to extend their skills and learn more today the second presentation gonna be done by uh log and um he's from maker dao and he's gonna explain you the basics of defy and uh especially we're gonna explain how to build depth in code how to code depth and how does that compare to that driven by our legal system so without further ado down the rabbit hole let's start with explaining what the blockchain is to understand what the blockchain is one have to understand a little bit more about the innovation cycle about disruptive technologies and how technologies are being born they have their springs they have their summers they have the falls and eventually they land on the graveyard of technology so the disruptive technology notion was introduced by in the book called innovator's dilemma what the book says is that innovations go through the cycle and the disruptive technologies go through the cycles and those disruptive technologies tend to change the world chain tend to change the um like empire is going to grow and empire is going to fall when new disruptive technology gonna show up and one great example that everybody knows and is very familiar with is a smartphone so a smartphone was one of the very first smartphones were created in nokia and was called nokia communicator and when it was created it didn't make a lot of sense for many people in the sense that nokia was really nokia communicator was really big and heavy and was not really portable and if you want to edit your spreadsheet you had a spreadsheet application but you know the screen was small so you didn't really could do a much editing of your big old spreadsheet on your on your small heavy phone so so for many there was very few people who would actually spend tremendous amount of money just to buy this weird phone but as so in general one could say it didn't make sen a lot of sense for for the mainstream market for for smartphone initially but then as a as technology started improving it was cheaper and better the screens were bigger and the battery way it was smaller uh the battery battery was better and so on so forth it turns out that suddenly everybody had ever now everybody has uh has an iphone and i can tell you that iphone is only 12 years old so it was like 15 years old that people were like i remember myself because i was having a chat with my friend and he said yeah smartphone's gonna be everywhere and i'm like dude this is heavy this is expensive my mother never gonna have a smartphone and he says no no no it's gonna change the screen is gonna get bigger and that's exactly what happened the funny and ironic fact is that nokia was the company to bunker because of the smartphone revolution and the funny thing is that uh that happens a lot that happens a lot for example kodak was the company that was the first one to create a digital camera and digital camera was the reason why uh kodak eventually went bankrupt so but empires fall but empires come to power google or apple are great examples so if we look at these trajectories of how the products get developed over time and get better and get better performance we can see that initially it doesn't make a lot of sense for the for the for the consumer for the mass market and as it gets better it suddenly when it crosses the line and it makes sense for a customer for for my market customer uh then suddenly the adoption happens very quickly in just a couple of years everybody got enough the smartphone and i think it's very important to understand that blockchain is getting really close in my in my in many people opinion blockchain is getting really close to this position to make a lot of sense for mainstream market which is a huge difference between just a couple of years ago when i was doing similar presentations and i was saying yeah this is still a couple years ahead and finally those technologies progress up to a point there are more than good enough like smartphones we don't know anymore what's the difference between iphone 10 and 11 if i would ask you hey what's the difference most of you wouldn't be able to tell the difference between iphone x so when those disruptive technologies come those uh and there is a especially interesting category of disruptive technologies called computational platforms so smartphones not only disruptive technology but a new computational platforms it was slower by many means and you know the screen was smaller but it was not important that there were problems regarding you know that it was not ready for the mainstream market what was important that it was handy there was a camera and gps so you could build new things that you could never be built before you could build instagram you could build uber something that wouldn't make any sense with uh with previous generation of computational platforms like desktops and the same was they would internet right to give you another example there was a in in in the 90s the internet slow it was mostly used by academics by uh by the army and you know like people will say yeah the internet is full of pornography you know it's you should probably not use the internet and in fact there is an article about amazon in 2002 i think or 2003 it might have been half that says amazon is a scam it's losing money there is no future in the internet business but what was not important is that the internet was not so good at the beginning it was not so important that there was a bubble in the late 90s what was important is that it has this instant access to information that allowed to build amazon and google and netflix and all the other stuff and here we finally come to cryptocurrencies and blockchain what is the new feature that they have that nobody else has it has a trust it has a building trust you don't have to trust any institution you don't have to trust a person you don't have to trust a judge you don't need to build a law it's enough that you trust the code and economy and the protocols and you can build new stuff that you could never build before what you can build is digital gold you can build cash you can build money on the blockchain how does one do that well let me explain a little bit more how the blockchain works an easy way to think about blockchain is think about it as a great spreadsheet like a google huge spread google spreadsheet and it has only three columns from to and value and every time you every time you issue a transaction it's just a new row so you can only add rows to the spreadsheet you cannot delete rows you cannot change things that are already in the in the spreadsheet and there are some rules about the roles you can add let's call it consensus rules so for example in the spreadsheet you cannot add a row that would represent a transaction that would be spending money that you don't have or more money than you have you cannot add a transaction that would uh spend the same money twice and um you know there is a rule that if i make transactions from person a to b then the same amount of money is subtracted from one account another to the second account and that's very simple and even with that simple notion even with that weird weird new database distributed database you can build something pretty interesting you can build digital gold how does one do that well throughout the history of standardization it was always the thing that was the hardest to produce that would be used as a store of value the way we see gold the primary purpose of the gold today so it was the stones in rye that was super difficult to mine and then and then made into what what they look like and um and people will use it as a currency up until there was a great progress in civilization and someone want to buy and someone had a business in producing more of those more of those stones and with the new technologies and mining they would basically destroy the economy of rye stones and they would stop being currency but they would be used for uh hundreds of years before and similar story comes about seashells in in africa and today gold is still we call it gold as a golden startup we even say things are golden star because gold is super difficult to mine and in fact in fact it's such a good store of value that you could buy 200 years ago with a similar amount of gold you could go and buy a dinner in you can buy lunch in in the restaurant or you can buy a flat in the center of london like it look like it's such a good store of value that you know you can buy kind of the same things even with all the progress that we have in technology in civilization and the fun the other funny thing about gold is that there is a progress in mining gold their technology is getting better but all the easily accessible gold is already mined so it's harder and more expensive to mine gold because with better technologies you need to access a harder gold that is harder available so it's it's amazing amazing property of gold that is there is nothing ever that has a better there was nothing ever before that has a similar property and in fact there is something called stop to flow ratio and stop to flow ratio is a is a measure how difficult how difficult but also how many of the new thing is being produced versus what already exists and gold up until this year gold has the best stock to flow ratio in the world there was nothing in history of humankind that would have a better stock to flow ratio up until this year when we have a half an inch in bitcoin meaning that less bitcoin is produced and the best flow to stock ratio today is uh the best uh stock to flow ratio has bitcoin and it's gonna get even better in uh four years and it's gonna surprise goal by far and if you look at the at the rate of bitcoin throughout the time you can see that generally bitcoin is growing in value and it's this is not by the way by any means investment advice but you know like you hear about bubbles bubbles pop and so on so forth but but but if you look at the logarithmic scale if you look at the long term you can see the general trend is growth so this is very very unique and thing that you know the economical properties that we didn't see before now so that was very simple that was first blockchain that was bitcoin now we're gonna start trying building something more advanced let's talk about smart contracts well to extend our analogy on the blockchain you can think about smart contracts as a new addition to our spreadsheet now we can still add transactions but we have a new kind of transaction we can make a transaction that we don't understand a particular person there is no two value of the in the two column and but instead of value we're sending a little bit of computer code let's call it a smart contract and what happens is once the transaction is mined it goes into a blockchain the code stays there and it gets its own address like other users in the network and once we have the address we can send money from user to user like we could in bitcoin but we can also send money to a smart contract to a piece of code and code can send money to us and we can also send a transaction to code that's gonna trigger execution on any specific function so in other words now we have two kinds of animals in our blockchain zoo we used to have just wallets well let's have their addresses i can send money to an address like i can to a bank account number and each wallet has a balance in ether which is a cryptocurrency that runs on ethereum which is a blockchain that introduced smart contracts for the first time but now we have a new animal called smart contracts it's a piece of code executable code it can store information on blockchain and it's too incomplete meaning you can write any program you can write in any language you can write in a smart contract it's deterministic meaning every single time we're gonna execute a little bit of code on the smart contract on any computer in the world it's gonna work exactly the same and gonna give exactly the same result and here is a here's another detail you need to pay for every line of code for every instruction of assembler you need to pay for execution of the code and you pay with gas and you buy gas with eater that happens automatically so you can think about paying for transaction you need to and how you write those smart contracts where you use solidity how you do solidity well here's an example smart contract a very simple one it's basically the simplest smart contract you can think of it's a simple storage it just have one variable stored data it's of the type integer and sign in in detail and what it allows to do is just set the data where the data is stored where the data is stored on the blockchain so every single full node every single full node of ethereum gonna store the data and this data can be said by anyone and can be read by anyone and even such a simple smart contract a simple simple gather if you know if you program in any language in your life you probably understand what does this contract do well the contract you can think about contract as basically a class an object-oriented programming and you can think there is a space of object that every single contract can talk to any other contract on ethereum blockchain and even such a simple contract have a very interesting property i can leave a message for someone on the smart contract and anyone in the world who have access to internet can read this message it cannot be deleted like the whole history of what was said on the contract is ever available to anyone at any time so that's very interesting property because it would be super hard to be done without blockchain like any information i can put on the server it's going to disappear the moment that the server goes down this gonna stay forever until the last ethereum node is still running now let's try something more complex what could else i want to write on the blockchain well there is this cryptocurrency called ethereum and we can use it to you know do stuff run execution of program we can we can use it to trade if i want to create my own well creating a blockchain is pretty difficult you would need to do things like hire cryptographic programmers hire networking programmers and you would need to build all the blockchain but now with ethereum you don't need to do that you can just create a smart contract that represents your new coin your new currency well how does one do that again it's very simple let's examine the contract called coin it has two variables two information stored on the blockchain one is minter so the person who is um allowed to create new coins and there is a mapping or or in other languages you could call it map or dictionary or hash that simply stores a very simple information for every single address in the tuner network we store the balance of the of that of that uh account counted in of course in of course our new newly created coins now if we go with our eyes a little bit lower into a constructor all we do in constructor it says whoever deploys the contract where creates the first transaction that puts the contract on the blockchain is the minter and only mentor as we remember will be able to meet new coins and if we look a little bit lower again there is a transaction there is a function called mint it has two arguments the receiver the guy who's gonna get the money and amount of money that he gonna get it's a public method but if you look at the so anyone can call the method but if you look at the first line of the matter method you will see of the function you can see there is a required message sender to a call mentor so if it's gonna be called by someone else then then the meter the person who originally created the smart contract it will revert and the transaction will not succeed and therefore the money will not be printed the function will fail and there is a requirement like we cannot mean too much money but other than that the program is very simple we basically add the amount to the receiver balance and that's it and once i uh if i am not a mentor if i'm a user of the contract i need to use a function called sent to send money to the uh to other people all all that is required is that i'm not sending them more money if you look at the first line of the code of the function you see that it is required that i have at least the amount of money that i want to send and then it's very trivial the logic of the smart contracts is very trivial i'm just subtracting money from my account and adding the same amount of money to another person account and additionally i'm emitting an event to inform the world that something had happened good so this was this was a funny smart contract i can create my own coin why would i do that why would i create my own coin well here is an idea how about i create a coin that is packed to us dollar or any other really currency uh in the real world and in fact there is a company called maker or maker foundation that created die die is a is a dollar is a it's a cryptocurrency it's a token here it's called erc token it lives on ethereum and it's packed to us dollars and the funny thing about die is you don't need to you don't need to trust them you don't need to trust the foundation you don't need to trust institution you don't need to trust you as treasury the way it is built around smart contracts is there is our economic incentives to make one die worth one dollar so it works without anyone looking and how does that how does that happen exactly all about that gonna be explained by leon in following presentation the one after mine so how does it how does that uh why would i have a why would i have a dollar on the blockchain one might ask well it's easy to transfer it's easy to manage that's one reason another reason is there is the whole new thing called the centralized finance that happened also defy called justify for and there is a lot of things you can do with those coins and one thing you can do is you can lend them to other people and again you don't need to trust that people you don't need to know that people you don't need to trust the bank or anyone else how does that work exactly we're gonna learn soon but by lending those tokens i can earn money so i can use my dollars buy my diet tokens and put it in the smart contract and this is a screenshot made couple days ago so it's pretty current and it says i can earn 2.91 annually uh by doing that so that's almost three percent in comparison if you go to any bank today i have a premium account i have an information from the bank that they have this super premium account for me saving account with 0.01 sorry 0 0.1 interest rate percent so one pro mile a new interest rate annually right so it's really not very attractive here in this blockchain space we can see that you can he has three percent on die there are other stable coins like you as the coin tether that gives even more so it's very interesting that there is this alternative economy this new financial system happening in parallel to our existing system that offers very interesting services that you don't get to get in traditional financial system and the whole def i think didn't really existed three years ago you can see it was basically worth zero maker is actually the first defy that was ever created and it was it i think it was around three years ago and then you know it was for a year didn't really raise a lot of attention and then two years ago it started growing like crazy and today we have 14 billion dollars value lot again it's a screenshot from just a couple days ago so i think it's pretty current we have a tremendous amount of money locked in the system but super important is like with bitcoin we are on exponential growth meaning that it was zero just three years ago close to zero two years ago it took forever to get to one billion and now i just checked a couple months ago it was i think two billion and now it's 13 billion so it's small but it's growing really really fast good so as the last point for today uh i would like to tell you how to solve the puzzle why we put this puzzle well we as i said we put the puzzle because we want to raise people attention we want to say hey come to xerox poland there's something extremely interesting happening in the blockchain space there's this whole deaf i think happening so you know maybe it's something you want to do maybe it's something worth a little bit of your attention so for that we did this small pr stunt that was the that was the poster uh so you can see there is an address of the contract and we can now that we know a little bit of solidity we can examine the contract the contract called puzzle you can see in the comment that there is a hint find all four clues to solve the puzzle and claim the reward the balance on the contract is seven if seven if it's worth i think a little bit then a little a little bit more than ten thousand zloty as of today i think more like thirteen fourteen maybe and here's the contract so to solve the puzzle all you need to do if you look at the line 33 all you need to do is call reveal function and provide the solution solution is of a type string so uh you know it's basically it's basically just a string just a sentence that you need to provide to solve it and if you look at the line 41 the if you provide a proper solution we're gonna tell the contract have a winner variable and we're gonna set it to message sender and in line 42 we have a withdrawal function that just checks if the winner if the missive sender is the winner and if so it's transfer all the money that it has to to the winner now there are some complications so first of all we cannot we cannot show in the smart contract what the answer is because if we would then obviously then obviously we would not be able to uh then everybody could see the answer and provide the answer so instead of storing the information about the solution we stole the ha we store the harsh and the way the hash worked uh and the way the hush works i guess every programmer knows but it allows you to store the information without revealing what the information is well or uh store information about the information so that when the information is provided we can verify if it's the right information so so and then if you look at if you look at line 34 in reveal function we calculate the hash of the solution and then we look in uh in in line 39 we look if the solution is in fact the one the one that was hushed in when the contract was created additionally there is a attack on smart contracts called front running so if i create a transaction and it has a solution and i send it to the network so that it can be mined and when it's going to be mine the function is called and the money is transfer or the winner variable is set other people can look at what is being propagated on the network they can look at what's called mempool so they can look you know what transactions are waiting to be mined but are not yet mined therefore we require the winner to first commit a hash of the solution and a couple couple blocks ahead of to prove they know the answer and only when they provided a commit the hush and then the reveal the actual they would win the reward now if we pro if they provided a hush then uh then other people could front under their hush so they have to hush both the answer concatenate it with their address so that other people cannot frontrun them and and finally we couldn't store the hush because you know people could could see the hush so we need to store the double the double hush good so this is it so there was a bunch of different tips there was a doubt uh a bunch of um different clues so that was the first clues it was it was published on our twitter it's uh it's a lyrics from the song the song is called uh dark forest and you know dark forest could be capital it could be differently spelled so we make sure that there is a reg x in um there is a small reg x in the tweet that helped people to format correctly the answer and you can see there is a small hexadecimal string at the bottom that one was used for checking if you get the right answer if you calculate the hash of the answer you you could check if that was right by seeing the hush and there would be another clue that one was um reference to hitchhiker's guide to the galaxy very classic science fiction novel and the third one would refer you to a newspapers if you find a newspaper there would be a phone number and the last clue was you could get the last clue by calling the phone number and just i think 20 minutes after we post the last clue there was a transaction coming with a solution the solution was with zero exponent into the dark forest down the rabbit hole where adventure awaits good so adventure awaits uh if you have any questions please let me know i wanna let you know that i want to remind you that there is a workshop coming and feel free to subscribe to that
