cineberisso.com.ar

chainlink crypto pngIntroduction to Smart Contracts, Blockchain, & Solidity - Chainlink Hackathon Workshop


Crypto Expert Reveals Ethereum Price Prediction AFTER Merge Will ETH price go up after merge? Will cryptocurrency rise again in ? Today we are joined by veteran trader Gareth Soloway to talk Cardano vs Polkadot. In this article I set out to…by Li Feb 14, · Cardano vs Polkadot In this article I set out to investigate Cardano and Polkadot, the two most promising blockchain usability platform proposals for DeFi and Dapps. I will analyse the differences between the two based on the issues that have the greatest impact on the development and operation of the networks. chainlink crypto png Introduction to Smart Contracts, Blockchain, & Solidity - Chainlink Hackathon Workshop
chainlink crypto png VeChainThor Wallet and VET Token Swap AMA A8:... Introduction to Smart Contracts, Blockchain, & Solidity - Chainlink Hackathon Workshop
hello hello how are you doing everybody just waiting for a couple people to jump on and then we can go ahead and get started we are going to be doing the introduction to smart contracts were going to talk about blockchain were going to talk about solidity were going to talk about remix and what is all this stuff oh i gotta not duplicate myself yeah and what is all this stuff so im going to be um checking the comments as well uh would love to keep this interactive so we can all kind of learn um learn and grow uh awesome scenes people jump in the chat hello hello theres a little bit of a delay between where im recording in the chat but i will get to the comments here so im just going to wait uh give it a few minutes um let a couple more people join hello hello really excited for this one if youre brand new here this is this is perfect this is exactly where you should be wanna learn about smart contracts solidity blockchain were gonna go over everything um make sure to ask questions make sure to ask questions because uh everyones starting off on a different pace so we are going to just make sure everyone is up to speed here all right great im gonna start jumping in a couple more people its a couple more people starting joining welcome welcome let me share my screen here hopefully that looks okay i wish there wasnt this delay between youtube and soon hello hello welcome welcome yeah that looks good cool all right guys so uh lets go ahead and jump in now so everything that we want to go over um is basically going to be in this this doc this beginners uh the basic documentation in the chain link doc so this is docs.chain.link slash docs slash beginner tutorial so this is kind of where if youre like im totally lost i dont remember anything from that that workshop you know this obviously its gonna be recorded you can come back to it later but this is really where um uh you can kind of get started for for everything um so im going to explain some stuff im going to give some demos but again please ask questions um so lets talk about you know what is a smart contract and and before we even do that we need to talk about what is a blockchain right so a lot of a lot of people here this is like brand new stuff people go what is a blockchain well a blockchain is literally just a massive kind of linked list database of transactions right um and its this its this distributed thing and theres all these all these pieces to it lets lets kind of break it down so the first thing that makes blockchain work is cryptography so whenever we have a piece of data we can actually um hash it and we get a unique hash of this data so this is called the shade 256 hash um its basically a unique algorithm that takes this this piece of data which right now its you know like cat well have the data be cat right it takes this unique piece of data this cat and it hashes it and we get this kind of unique identifier for the data so according to the shape 256 hash this hash right here represents cat and then if we do like dog this hash represents dog and so its a great way to get unique um its get get unique data right so and this is really important because uh once we learn we can hash data we can actually start to um uh figure out blocks of data right so were gonna take cat again um heres an example of like a block in a blockchain um and we want to we want to mine it so basically mining is when we do that same exact hashing thing but we do it with the intent to um to find like a solution so you see how at the beginning of this hash it has four zeros so um what the computer what these computers are doing when theyre mining is theyre theyre theyre doing this exact same thing as we were doing here theyre theyre hashing this cat but theyre doing it in a way in combination with in combination with whats called a nuns where if the nuns plus the data um makes the hash have four zeros at the beginning now that doesnt have to be the problem it could be kind of whatever um it could be any problem but um uh what the comp uh what the computer needs to do is it needs to keep trying different nunses until it figures out a hash that has four zeros with uh with this data right here so when a a blockchain is mining stuff theyre just trying different nunses to get this down here so theyre saying you know the nuns plus the data equals a hash that starts with four zeros and so they just the computer just has to keep trying its just a huge trial and error and this is why when you hear about mining and you hear about blockchains mining um they have to theyre doing just a ton a ton of trial and error until they can finally eventually get um get to this answer where you know it has four zeros at the at the beginning again thats not always what the challenge is maybe its ten zeros maybe its two zeros or whatever um right but um some sort of challenge that the computers can reach some sort of challenge so so this is hashing this this right here is hashing when you you you take this algorithm you apply to this data and you get this hash and then this is kind of mining where you hash a nunce and the data to to get this hash anybody have any questions so far and yes and and this is kind of this is the proof of work um algorithm uh e2 will be proof of stake good point um but yeah this is kind of the basics there now uh what is cool obviously in um in solidity and with ethereum you can actually add like um like function you know do something public you can do the same thing with like code so this is a way to to store code on chain um and then we can actually have these these things do things for us which is really uh really powerful so what is a nuns so a nuns is just kind of this um this number that they use in combination with data to to get the hash to kind of uh to solve the puzzle basically so data um so basically you add this nonce to your data to try to get uh your hash to have you know four zeros at the beginning or whatever challenge it is eight zeros a hundred zeros two zeros whatever you want it to be known suggested number yeah exactly none suggested number so once you have the hash once you have the block we kind of go to the blockchain um and you can see if we do this many times every every new block is going to be include the hash of the previous block right so and you need to hash everything in here the nuns the previous and the previous hash right so were going to get a new hash for this one you see it takes some time for us to um it takes some time for it to actually mine but so this hash right here is the combination of the previous hash the data and the nuts right and so this is what makes blockchain so powerful too because lets say you know lets lets go ahead and mine this one lets mine this block and this is what makes it so immutable is if i go back to you know this this block right here and i change something the hash is going to be different so now the rest of the blockchain is validated right and so once you get into whats called the distributed part well have all these blockchains that match up if i change one now this blockchain on on this pier a which could be anybody in the world whos running it theyre no they no longer match everybody else so everybody else says okay peer a is wrong and kick them out basically so thats kind of the basics of blockchain and and how um how kind of mining and how these the cryptographic part works its actually uh simpler than uh that a lot of people kind of make it out to be so um and and this is this is just kind of like what what is what is all this cryptography stuff its kind of less important in in my mind to really understand you know the the math behind this and and how it really works the cool part for me is really the solidity stuff in the smart contracts which well get to in a minute um but for those of you who are like i dont even know blockchain this is kind of the simple um explanation of what it looks like and i will even post a link in the comments right now and well add it to the description um if you guys want to visit this and check it out yourself and kind of play with it a little bit so but this is really blockchain in simplest form so im looking at the comments now its four zeros for nuns no so the four zeros is like the the challenge right so uh if cat is the data the challenge is how do you get four zeros at the beginning of the hash using some nuts right so again if we hit mine the answer is if we do 14 um 14 132 as the nuns and we hash that with the cat then we get a hash with four zeros right so um the nuns is this is is is what were using to combine with the data to get to beat the challenge and the challenge here is have four zeros at the beginning of your hash who defines the nuns the um uh the blockchain so so when youre mining you define the nuts but if the question is who defines what the challenge is the challenges actually debate uh based on the blockchain itself all right cool so thats blockchain and basics now this is really cool because like i was showing you it allows you to actually store code on the blockchain so you have this you have a mutable code um that will permanently you know be there and itll be run in a decentralized manner right what does it mean when were run in a decent centralized manner so actually back to the blockchain demo if we go to this distributed second section we see that these blockchains are actually run by different peers or different people right so these blockchains are distributed meaning multiple people run the software that has all this stuff right and um yep exactly the nuns is the right answer the miner discovers and waves around to the other minor servers get the reward and it pushes the block but um yeah thats spot on so so all these peers are running these um are running these these programs uh and they all execute this code and run these transactions at the same time and you can see if somebody you know reports something wrong you see how this this lights up red it doesnt match what all the other blockchains have said and so this ones now um disqualified or kicked out basically right so this is how blockchains run in a decentralized way you dont have to trust a centralized point of failure right because there are all these different individual entities you know running the code and producing data and if one says oh im going to screw it up im going to say you know you know patrick actually has zero to actually lets lets even do this and say patrick has one dollar patrick has one dollar lets just mine this real quick lets mine this save this ones patrick has zero well its its green actually because all the hashes match but um this blockchain will say patrick has zero dollars well all these other ones will say patrick has one dollar um you can just check the hashes well well see the hashes of these two blockchains are different than this top one and this top one will get kicked out basically saying oh youre clearly doing something malicious um you are lying were going to kick you off so thats how it stays decentralized and stays trust minimized if you will which is really really powerful so so thats blockchain and thats kind of the the um the simple level blockchain now what can we do with this well okay now that we have a way to provably and in a decentralized manner run code and store data um this is how we can build whats called smart contracts so these smart contracts are you know on these blockchains pieces of code and again its going to show red because i you know im changing stuff we can write code like you know function do something and you know maybe like you know give patrick money obviously this is pseudocode but we can we can have these functions and theyll get executed in a decentralized manner so each one of these nodes each one of these individual peers will run um and it will execute the code and they will all check to see if they all match up and if they do itll execute and and move forward so um a couple questions in the chat cant the user set the nuns as well as something like metamask um cant the user set the nuns uh as well as something like metamask theres a couple of question doesnt quite um so a minor can set the nuns right but if i try to do like one you see the hash doesnt have four zeros so this nuts would be wrong same thing with two this notes are still wrong three this nuts are still wrong so you gotta keep trial and erroring to get the right nuns and then again you know were hitting mine which is just the computer trial and erroring it until it gets you know thirty thousand eight hundred and seventy four so that the hash is correct nuns cones okay uh nuns comes from proof of work simply just a number any number incremented by one until the node finds it its proof that the new block was created in a legitimate way by using proof of work method spot on yep thats spot on since metamask user is not engaged with mining activity so metamask is not a uh its not a minor meta mask is a its kind of like a wallet thats built on top of the blockchain that tells you what your balances are and stuff so again like in some of these blocks theres going to be like you know patrick uh has like one you know one usd or something right thats going to be in a block its going to be like dawn has for usd so metamask is basically just a way to kind of read and be connected to the blockchain in this manner so what are we going to do in the hackathon so so code has many copies in different peers or does it have copies in all peers so yes so it has copies in all peers right each one of these each one of these peers each one of these different chains and it could be like me running a blockchain note in my house you running a blockchain node in your house um its all its going to have everything every transaction thats ever occurred otherwise you know like we saw right here um its not going to be a valid chain right because it the hashes arent going to be equal across all chains so if im missing a hash or something um i cant add to the chain i cant i cant move forward because im going to be missing crucial data should do should i do yield farming lets not for this this this demo if data is high demand running a chain link notice something like that as well thats it okay cool great so lets move on to um to smart contracts so now that we have a way to store data in this way we can also write smart contracts that are stored on chain as well and these smart contracts are going to get executed in this decentralized manner and this is kind of really the power of that blockchain has is executing these transactions um in a decentralized manner executing the code that we wrote on chain across all peers right so thats really thats what a smart contract is a smart contract is just code on the blockchain thats being executed in a decentralized manner so smart contract obviously you know a contract is like any agreement between people uh another um another way to save smart contract is dap or decentralized application because its an application where all the computation is run in a decentralized manner and this is obviously highly beneficial because we dont have to rely on a centralized intermediary i for those who were here when sergey was giving his talk yesterday you know having these trust minimized agreements and applications thats highly favorable and highly important um for uh for a lot of things and one of the biggest examples is with you know everything that happened with with robin hood and gamestop and and all that so so smart contracts are these these decentralized applications that we can build and we can run and they can do a lot of really cool stuff and theyre written in solidity solidity is the language of the smart contracts at least on the ethereum chain and every evm compatible chain dont worry about what that means right now but solidity is incredibly powerful um and its what were going to be working with today so this is what a really simple slowly smart contract looks like lets even lets even play with it and go to remix so this is remix once it once it pulls up so this is remix remix is a web ide or a web integrated development environment its a way for us to test deploy and visualize our smart contracts that we deploy and again were deploying them to the blockchain thatll get executed in this decentralized manner so well come here uh were gonna hit solidity so that it knows we want to work with solidity uh i i have a bunch of stuff in here because ive um ive been i use it a lot um but were gonna go ahead and create a new file and well call it uh chain link workshop dot sol oops my fat finger at the end there call it chain link workshop dot sol so um and im going to i just pasted the code in here right so the code that uh so to kind of explain what this is is uh this is some really basic um solidity syntax here so first we need to define the version of solidity that were working with so were going to work with 0.6.6 the current version and this is how you do a comment here which doesnt get executed i think the current version is 0.8.2 we like to use 6.6 for now because a pretty stable stable version but yeah solidity moves pretty quick more versions are coming out quite often and they all have very very nice features and improvements then we have contract hello world this is basically how you do a class in selenium so um you can think of contracts as classes um if youre familiar with like java um java javascript really any object-oriented programming language so were gonna do contract hello world this is the equivalent to doing like class hello world and then we have uh and this this whole thing is what gets deployed when we specify like a contract to deploy we we take this and we drop it into the blockchain like i was showing in that demo um string public message this is um this is how you define a string basically its a string its public visibility there are four different types of visibilities theres public private internal and external you can learn about those later and were calling this variable message so this is a global or contract variable called message its initialized to an empty string unlike other programming languages when you um when you define a variable it just gets initialized to whatever like the empty version of it is which in this case its like an empty string so then we have a constructor and this is whats called when the when this contract is deployed uh a constructor the constructor is always called you dont need a constructor but its usually good to have one and we add the constructor parameters so when this contract gets deployed it calls the constructor function for those of you who are brand new to programming um that might be a long conversation what a function is this something that you can call to do stuff um a constructor is called we we add the initial message into the our constructor uh and we set this global variable message to initial message so were just setting this global variable here and then we have update message which is a function that takes a a a string as a parameter its a public function which means anybody can call it and then were just going to set message to new message so lets go ahead and compile this so well come to the compile tab well hit compile and did you intend to add public yes i did sorry so this ones also public so were going to compile this and then were going to go to um to this deploy tab this button right here is deploy and run transactions were going to stick with javascript vm for now but for the for a lot of these were actually gonna use injected web3 but for now were just gonna stay with with vm ill tell you why in a minute um but were gonna deploy our our contract and you see here it takes a parameter called initial initial message um so lets just do lets say the initial message is you know hello this is our initial message and were going to deploy it what youll see down here is we get deployed contracts and youll get the functions that we have you can see we have update message which is one of our function and we also have message here which is a function that calls this this message variable so we can read what the message currently is the message is currently hello right and this is this is going to be on the blockchain theres going to be a string called hello and this message contract and then if we want to update it with goodbye a message now we click message and it now says goodbye so im going to look at questions for um real quick here hey patrick is solidity backwards compatible um kind of uh yeah so if im using like compiler you know um 6.12 um and i im using like a like a like a carrot 6.6 or carrot 0.6 then yes so so kind of so you dont have to rewrite all your contracts um whenever you update versions so yeah youre okay is it recommended for you six point six seconds on then yeah to be honest i i would recommend using 0.6.6 for the hackathon theres theres a lot of good tutorials and workshops with 0.6.6 can we get rid of real estate with smart contracts um really really vague question i mean i feel like people are always going to buy and sell property um can a smart contract help uh okay interesting um fun fact initial message is stored memory when the function is called thats right then the data is copied into message property the contract which is stored on chain thats how data is persistent correct what is memory in the code and why is it needed good good question actually so strings um they need this memory so theres theres two different things you can have here you can have memory or storage uh i wouldnt worry about it too much for now um because like for example if you if this was like a uint or an integer you wouldnt need memory here but its basically saying um this data is only going to persist for um for the time uh being that this is executed so initial message only exists uh while this function is called and then then you cant call it again um were setting it to message though and message is a storage variable so message does stay on chain permanently but um yeah just know for strings you need to have pre for for functions you pretty much need to have memory uh that might be uh the real full explanation might be a little a little longer there memories keyword that specifies where the variables are yep do you envision uh is it just memory computation yep there is yeah exactly this memory is in computational stack exactly and then storage um so storage is yeah storage is another one you can specify um this one is defaulting to storage basically what do strings do strings are um like text so when it says like string memory initial message its like text here like this isnt a string this is a number this is a string cool good questions all right now were actually going to do something a little bit more interesting now were going to actually move to injected web 3. so injected web 3 i know a couple people were asking about metamask how does that fit in injected web 3 says we want to connect to a real blockchain the javascript vm is basically pretending were on a blockchain when we deploy contracts with with javascript vm were pretending were saying ah this is what it would look like theres a theres an algorithm on the back thats running and says yeah if you were to deploy it this is what it would look like but when we do injected web 3 this is were actually going to deploy to a real network and were saying were taking whatever web3 provider that we have were sticking it into the browser so the web3 provider that im using is metamask excuse me um can you guys see this here theres like a delay on my youtube so im hoping you guys can see my metamask see myself okay cool yeah you guys can see it great so were sticking it in and uh were actually going to interact with whatever blockchain that weve defined on our web3 connection so uh you can see here this is metamask if you dont have metamask um we highly recommend getting it um its just a web browser like you kind of saw there make sure you youre at metamask that i o um you can hit download now and then it will bring you to hey download bro you know install it to your browser install it to chrome install to you know whatever youre working with and this will this will get you set up this will get you um get you um okay this here also on the chain link youtube we have a chant we have a video um that kind of shows you how to do it a little bit uh a little bit step by step if you if you get totally lost um and yeah everybody whos here like definitely check out the engineering tutorials theyll put you in a really good good spot but this one right here install configure and fundamental mask its a really good video um just just switch from it mentions using roxton switch to coven ill show you that right now so anyways um yeah so smart contract smart contract smart contract deploying well get into oracles in a second well just take you through remix or metamask real quick so once you actually get this this browser extension um now you can actually start interacting with the blockchain so we have uh here you can see this is the coventest network so a test network is is a way to to deploy your smart contracts in a realistic environment um but not cost you any money which is really nice because we dont want to spend any money so the reason we need to have ethereum in here is because whenever we uh make a transaction uh on chain we actually have to spend whats called gas or ethereum gas so doing computation on ethereum or any smart contract platform again we have we have a whole bunch of different sponsors at this hackathon that arent ethereum you have to spend a little bit of eth to deploy your smart contract so if i go ahead and hit deploy deploy now that i have that im connected to um coven whats going to happen is metamask is going to pop up actually yeah what happens is metamask is actually going to pop up and ask me if id like to id like to deploy so it says hey see youre looking to deploy this thats great heres how much its going to cost you its going to cost you 0.001251 eth to deploy the smart contract because we need to pay the miners a little bit of money to to store our data properly basically so the miners are taking this fee here um to actually deploy this so we can go ahead and hit confirm and whats going to happen then is down here we get this it says creation pending and we get this little link and it looks like it already oh great so we get this link to the transaction um and its being mined right remember how on that that example before that we the wheel had to turn this the miners are trial and erroring creating that nunce for this and thats whats whats happening behind the scenes um when its mining so it looks like it has been included and it will be reflected in a short while its usually a few seconds but great so we can see this is the transaction hash that defines us deploying this contract this is who its from its from my unique wallet address and ill talk about that more in a second and then heres who its two you can see some more more cool stuff so etherscan is a really popular block explorer which kind of goes through and shows us all these all these all these different all these different things so now that its deployed we can see down here again we see that its deployed we can see the message string hello and if we want to update the string since were actually updating the blockchain when we update update this string because remember when we hit this update message function were actually setting this message variable to something else we actually have to we actually have to what we have to pay gas again so im going to set it to chain link is the best update message and again metamask pops up it says i see youre looking to do some computation i see youre looking to change state of the blockchain heres how much gas its going to cost so we go ahead and hit confirm we get another transaction hash and you can see again its pending the miners are going to i got to figure out that none so i got to figure out the nuns and once its done which which is probably probably now once its done we hit message again and we see the string is updated to chain link is the best so and again this is this is um mimicking what would happen on a real blockchain so so this is metamask like i said were on the coven test network if we wanted to switch to ethereum mainnet um this is my test account so im broke here uh we could actually deploy stuff on mainnet as well so theres a ton of different test nets uh and theres even like mumbai which is matic you can run a local test net um but well well stick with cove and test that for now because its really simple so um so change that link the way we can get some some cove and test net um in our uh in our meta mask is actually we can just go to come to a faucet again because i you know i said this is free stuff its free to run this stuff um this is the if you go to the chain link documentation on the link token contracts there are some some faucets for different test nets here uh which is really helpful so for my crypto just it says hey give us your address pop my address in here oops excuse me its connected to your metamask account so ill pop my address there request assets ill do l n n c submit and success the testing theory has been sent so its going to send tested so send test ether and same thing again because were changing state uh of our balance we get a um we get a transaction hash that says hey were going to update your balance heres how you do that so before i continue im going to look at look at some questions so i know im going through a lot here are smart contracts being executed by the miners or is it executed by a separate group of servers its all by the the nodes so um the miners are validating what every other node um for simplicitys sake yeah the miners are are executing the uh the transactions do the not equal test nets implement not equal features which one should be should i use im not sure what that question means im sorry um will gas always cost the same amount does it fluctuate so gas thats a good question actually so the gas costs again like when were in here um actually when we even hit this and metamask pops up we can change the gas price so the gas amount um is how much how much computational effort it takes um to to run and then every unit of computational effort we can kind of set the price uh as many of you have seen for example we would check out like etherscan so thats covens either scan lets go to mainnet etherscan or east gas station you can see here kind of the current prices for uh for ethereum oh look at that help build chain link look at that thats awesome um we can see kind of the different uh the different prices here of how much it costs to make a transaction on the chain and these prices fluctuate depending on how much network demand there is right because only so many transactions can get processed by so many miners so gas prices do change thats a good question if gas prices are higher than when you test but the smart contract is deployed does the amount you pay for each execution change it can yes actually so if gas prices super spike the amount of gas or your total computation will still be exactly the same but the gas price might actually change thats a good question all right cool great questions um keep them coming keep them absolutely keep them coming what does deploy mean deploying is when we actually put it on chain and then were going to go into oracles do i need to go over anything else oh um the other thing actually that were going to need were going to need a chain link token from the chain link faucet so what were going to do is same thing were going to come place our address in here hopefully im human send me a 100 test link now ive already added it to my metamask but they actually dont show up right away what you actually have to do is hit add token custom tokens and then add the the link token address i already have it but were going to go ahead and show you anyways in order to see your actual balances again you know i already have mine here we have to add token custom token add it here token has already been added because i already added it but normally like link will will show up here youll hit next and then youll be able to see the assets down here so we need this to interact with chain-link or holes which we probably wont get to today but um having both eath or ormatic or moonbeam or bsc or whatever whatever token that you want in there thats really important so all right cool so now so why are oracles important so as we see here you know we can kind of interact with this smart contract we can do stuff we can have fun its gradual time but what we cant do is we cant actually get access to the real world um and im going to be going over why oracles are so important and why chain links is so important um later today in our uh everything chain link um workshop which is tonight at 4 30 eastern i believe so im not going to go into that too much now but we will um go over it later today so i do want to do i do want to show you guys this though so heres kind of a bigger smart contract that were going to work with right here well ill probably also go over this later today so a few other things with this is that were actually importing now so importing were importing this this aggregator v3 interface dot sol from the chain link smart contracts and what this does is it takes another contract and sticks it at the top of our solidity contract here so that way we can use the different functions we can use the different variables in this other solidity smart contract and plopped it right at the top of this this literally smart contract so um so this is incredibly useful for us so lets lets talk about whats happening in this smart contract so this is an example of a smart contract that actually if we use this um excuse me if we use this javascript vm this fake virtual environment we actually wouldnt be able to do any we want to be able to interact with them in smart contracts wouldnt actually we wouldnt be able to interact with any smart contracts that are actually on chain and this is an example smart contract that we do want to interact with things on chain so if we go ahead and try to deploy this sorry lets compile real quick if we try to deploy this to the javascript vm were going to get our function and its not going to do anything and its going to be like what what are you trying to do you are crazy so uh we we are going to have examples of smart contracts that need to be connected to other smart contracts um somehow so we actually do need to deploy them to the test net thats specified so this one obviously um is for coven right so now if we deployed to coven like i just showed you now we hit get latest price we actually get a response here so uh its important to know kind of the difference between injected web 3 javascript vm again injected web 3 youre employing to youre deploying to a real chain you know whether its a test net or a maintenance chain and then its defined by whatever whatever youre on here javascript vm is kind of like a fake pretend environment which is really good for testing stuff quickly but if your contract specifies that it needs to connect to things it wont work and then web3 provider is is kind of your own um your own web3 provider like its not its not injected web 3s again its coming from metamask and then web3 provider is kind of like whatever you specify which were were going to go ahead and not do that but lets look at some of the other things in in this remix oh actually let me ask a couple questions answer a couple questions whole proof of stake validate um that might be a longer conversation what is gway okay this is actually a good question um its actually a really good question so ether or eth um is divided well the smallest amount of one ether is one way so this many ways equals one eighth you can think of it at like a hundred pennies equals a dollar um this many way equals an eth and gray is just kind of like the midpoint basically so this many way equals this much way which equals this much ether so you know one way is equal to 0.0001 ether the reason that this is important though is because uh solidity and smart contract cant understand decimals so when when we specify like an amount we actually need to specify it in way the reason that you hear way so much is because often times like the cheapest gas price is going to be in guay so for example if we go back to the east gas station we have 137 way 160 gway 161 gway so we can even copy this oh excuse me so when we say the price is 170 137 gray were really saying the gas price is point zero zero zero zero zero zero one three seven and the way that i i kind of remember this like how many how many things is uh how many zeros to put in so i usually just count eighteen zeros so ill go one two three four five six seven eight nine ten one two three four five six seven eight and i go oh okay so this is one eighth uh so its 18 zeros eighteen zeroes is something to remember gray has one two three four five six seven eight nine but like i said its the halfway point so 18 zeros nine zeros no zeros um thats actually a really good question okay wheres the link for the documentation reared from itd be helpful to follow along the way good point so i bounce all over the docks because i live in the docks let me point let me post all right i just posted the uh the documentation this is kind of the beginner tutorial itll take you through literally everything that you need to know so um and it will do this first um chain link smart contract which is really really powerful here too so uh lets actually even go back to that other translate workshop. so um so lets go ahead and write a new function right lets do a function called add do function and then we have 12 minutes left so good time so well call function add right so were going to create a new function and well call it add and well do this well do this on the um well do this on the javascript vm because were not going to interact with any other contracts so um so we dont need to use coven or anything we can spend we can be a little bit quicker so we have our function add if we go ahead and hit save now and actually its even just lets even just start scratch start from scratch so we have a function add if we hit save control s or compile youll see we get this error syntax error no visibility specified did you intend to add public yes it is thank you so much so public means that anybody can call this if we have this if we go ahead and deploy this now well see we have this function add here if we were to go ahead and make this like private or internal and then we deployed it excuse me and then we deployed it you see we have nothing here now right so public means that people can actually interact with it theres also external internal um you guys can read more about those so what do we want our ad to do were gonna were gonna create a global number a uint 256 public number so were going to create a global variable called number uint256 stands for unsigned integer which means its uh its an integer that isnt signed so its not like a um like a negative or positive 256 this is uh we could also just do this 256 this is kind of like the size of the answer so its u in 256 public number and if we go ahead and deploy this now well see that we have this number which gets initialized to zero and well have our add function which doesnt do anything right now so we have number which is zero lets go ahead and make this add nothing do something so well do number equals number plus one and then you need to add this semicolon at the end of these lets go ahead and compile this compile lets delete our old contract here lets deploy it now we have number which is zero and now add should do number equals number plus one so if we hit add this should be one after we hit it add one add two add three boom and so now we have a really simple smart contract that can add stuff which is nice all right a couple comments now all right cool there is 18 zeros yep one gray is 10 raised to the ninth what would the closest language to solidity um b so i think its java or javascript i think those are both pretty good but its really any kind of object yeah java javascript um its really any object oriented programming language though i mean um even python is pretty similar its just you know this has like semicolons and stuff um i i i dont i think you know i think even go is similar probably java javascript though a good question do smart contracts support vectorized operations um thats a good question i mean you could probably build build stuff to do that um thats a good question im not entirely sure slity is strict type system yes so solidity is a static statically typed language i cant do like i cant do public number right i have to specify the type would you recommend learning java before solidity um no um i think having some object-oriented programming experience is is definitely good um and definitely really important um what i recommend learning job before solidity i think having some some object-oriented experience is definitely going to be helpful but its not required what is external public view and solidity um good question so public means anybody can can read it actually we can just do is ability actually lets go to lets go to the docs so the slitty docks are really good lets do the latest version private and then it kind of says everything right here functions have to be specified as being external public internal or private for state variables external is not possible external functions are part of the contract interface which means they can be calls from other contracts via transactions an external function f cannot be called internally ief does not work but this dot f works external functions are somewhat more efficient when they receive large arrays of data because the data is not copied from call data to memory public public functions are part of the contract interface and can be either called internally or via messages internal oops these functions and state variables can only be accessed internally without using this private functions and state variables are only visible for the contract there to find it and not derived contracts so hopefully that answers that question so this is really kind of the the really simple like welcome to smart contracts welcome to solidity um we have some really fantastic tutorials in here this beginners tutorials the basics if you dont know anything and you want to deploy a smart contract that uses chain link like follow this this is going to get you set up really quickly um were going to teach you about remix you know this is the this is really the place that everyone uh i well i think everyone brand new space should start um it lets you kind of visualize and work with everything really easily once you get comfortable here then youll want to move to like a hard hat a truffle a brownie these are smart contract deployment frameworks which you can use in your in your your code editor thats not kind of in this online ide but i think if youre just going to start out this is definitely where you want to start out you can even build pretty much your whole project here um obviously you want to do a front end as well putting up putting a front end would need to be done kind of in in your in your in your environment but you can really build you know entire blockchains entire projects and remix if you want but i think the more sophisticated environments are going to be once you move to hard hat or truffle or brownie whatever what if ethereum thats a super biased question what would you recommend as an id to check your programming errors bug fix um so i think remix is a decent place to start even though i just said uh you know you really want to move off of it um but you can also um i use visual studio code a lot i really like visual studio code i think atom has an interesting plug-in that you can use if youre familiar with atom um that works really well with solidity but i think visual studio code is good i mean they have solidity plugins as well and then you just you know you just do you know uh hard hat compile or browning compile or truffle power whatever itll show you all your errors too good question thanks for sharing uh yeah for sure so um yeah so i mean thats most of what i wanted to bring you guys through what is the blockchain what are smart contracts you know introducing intro to remix uh yeah im here for questions now for the rest of the the time here what is an abi um good question actually so every smart contract has two really important things for interacting with them so they have an address and actually i didnt talk about this they have an address for example right here actually lets lets deploy something to covens ether scan so injected with three were going to deploy this to coven and were going to get our coven transaction here cool it looks like its done weve got our transaction so um each contract has an address and we can its this thing its obviously truncated we can copy it by hitting that copy button but then we can we can see all the interactions with our trans uh with our contract here we see theres only one transaction which was the contract creation we can go ahead and do this add thing now confirm and well see in our contract address on etherscan if we refresh theres a pending transaction going on right now so the address is the first thing we need to know we didnt know where this thing is right so this is where this smart contract is the other thing that we need to interact with it is we need the abi if you go to like the contract since this isnt verified right now its just a ton of jar bowl right like a human can i dont know what that means like if someone was like hey can you uh can you call a function in the smart contract and they send me this im gonna say i dont know what we talking about that looks thats theres nothing to me i dont mean anything to me so what we need and and computers uh do the same thing they come to here and they go uh okay cool oh what so so how do i work with this what do i do so what we need is the abi so the abi is the application binary interface um and i believe remix actually has a way to grab the abi unless they got rid of it oh is this a nope im drawing a blank i forgot how to get the abi here abi boom right here so this is an example of an api well commented it out its basically um applicate like i said its the application binary interface and its um it defines how to interact with this contract right so we we see we have this function called add it takes no inputs no outputs it doesnt have a return type its non-payable uh and and this is all we need to know to interact with with this add function we also have this number variable right and we see it does have outputs it returns a unit uint256 which is really cool its a view function um youll learn about that youll learn about that a little bit later but to interact with with contracts you need their um their address and their api um remix already kind of handles that for us and youll see having the api is really important when kind of moving off chain when working with you know visual studio code and whatnot so thats a really good question stands for the application binary interface this is one what looks like and it defines how to interact with your smart contract and its really important for um building really cool stuff thats that last part isnt a great explanation but yeah what if i already and somebody else calls a function in that contract to modify it wow thatd be horrible right we dont want that um so we can actually add on whats called access controllers so um theres this thing called a modifier in solidity um one of the most popular modifiers to make is called only owner and im not going to go ahead and make it right now but you do like modifier oh actually yeah im not going to make it right now and what it does is it means only the owner of this smart contract can call this function so these are called access controls and you can make access controls on your function you do an easy way to do it would be require this is something that runs in solidity require message.sender equals equals owner and then we would set like address public owner i guess i am going to make it then constructor public message.sender equals owner okay i guess i am just going to basically make it um so backwards um so what this would do i know i just kind of coded a whole bunch of stuff and i know were were at time uh is it would set this owner variable to message.sender so this is a keyword in solidity were saying whoever whoever called this function its going to be the message.sender and were going to set that person up to be the owner then in this add function we have this require method which says this needs to be true in order to keep moving forward were requiring whoever calls this add function again this is the new message.sender has to be the owner so this is a way to add access control so that only the owner of this smart contract can actually call the add function good question isnt chain link blocks trading gnostic uh yes its very blockchain gnostic so i cant imagine that migrating to a different chain would it be impossible yep its its blockchain agnostic you can uh work with any chain um where chain link is i would say check out the docs to kind of see where where stuff currently is is there a good end-to-end course for solidity whos already familiar with java i think theres a great one on udemy um the ultimate guide is solidity or something like that i think that ones great i think crypto zombies is very good dap university has some good stuff as well theres a lot of good courses out there what are events logs and states i dont have enough time to go over that but that is a great question is dap university offering some deals they are theyre actually offering some winning prizes if you uh if you win so um if youre looking to learn more about celebifieds hackathon definitely apply to the depp university prize is it possible to make curl requests through chain links on a smart contract yes go to our workshop tonight and we will teach you how do i implement an erc20 token that is a longer question than what this has um time for but i would say check out open lets say check out opens up ones erc20 check this out this will pretty much give you what you want to know if you can do a walkthrough of what does a link node usually do that will be tonight to 4 30. so we are past time uh everyone thank you for your questions thank you for coming um thank you for asking such fantastic questions uh if you have more questions feel free to leave them in the um in the discord as well really looking forward to seeing what you guys built if youre just getting started here um youve come to the right place we didnt go too deep into solidity or smart contracts we really just kind of showed you the main tools um that youre really going to want to use and again if youre brand new if youre like what is going on check out those those chain link engineering tutorials on the chain link youtube that will walk you through step by step some really easy ways to do so they are on uh they are using roxton we will be using coven for most of the examples so if you want to stay easy stick with coven um but uh the docs here also walks you through step by step everything you need to know so feel free to just start with this beginners the basic this will also get you going so awesome thanks everybody so much and well talk to you soon once i learn how to turn this off i hear The Chainlink Fall 2021 Hackathon kicks off October 22. Sign up today: In this developer workshop, learn the basics of smart contracts, blockchain, and Solidity from Patrick Collins, Developer Advocate at Chainlink Labs. Chainlink is a decentralized oracle network that enables smart contracts to securely access off-chain data feeds, web APIs, and traditional bank payments. Learn more about Chainlink Website Twitter Telegram If you’re a developer, visit the developer documentation or join the technical discussion on Discord ChainlinkDeveloperWorkshops,