What’ll Happen When 18M ETH Hits the Market? Maybe Less ,2 days agoAbout 18 million staked ether are set to be available for withdrawal once Shapella happens. Market analytics company Glassnode said on Tuesday that the firm expects traders to sell a scant 170,000 ETH “immediately after the Shanghai upgrade.”. Because there are Ethereum protocol-level limitations on how much staked ETH is Ethereum.org,ETH is the currency of Ethereum – you can use it in applications. Illustration of a doge using a computer. Use a dapp. Dapps are applications powered by chainlink development Hardhat, Truffle, & Javascript Development Framework
okay and i think we are live whoops let me need that cool awesome hey everyone welcome to this changing hackathon workshop today were going to be talking about javascript development environments more specifically were going to be giving an introduction to hardhat talking a little bit about truffle and were going to do some some coding along fun stuff as well so hope you guys are ready its going to be a fun one today im just going to share my screen now so she okay can everyone see that okay okay awesome lets go cool so yeah my names harry im a developer advocate for chaining labs and as i said today were going to be talking about javascript development environments hardhat and truffle so first of all lets just go through what were going to be doing today so were just going to give a brief you know one minute overview of javascript development environments in the context of you know blockchain development were going to talk a little bit about truffle were going to talk a little bit about hard hat then were going to do a demo with hard hat and then were going to introduce our hard hat starter kit and then were going to do a demo of our hard hat starter kit so lets go so development environments most of you probably already know this but essentially just set of software tools to to help you in your development process to help you to to build the the stuff that you need to build right pretty simple um and yeah designs designed to maximize productivity and efficiency so lets start off by talking a little bit about truffle so truffle is probably one of the most mature and oldest web3 javascript based development environments that means that its really popular its got a lot of support its got a lot of um if you have issues and youre looking for for a solution for something chances are someones come across this issue before because truffles been around for a while uh so its a javascript-based development environment and its got integrations with ganache for running local blockchains and and drizzle for front-end stuff and yeah its really mature and and lots of support available online um for our demos today were going to be focusing on on hardhat as opposed to truffle uh because hard hat um its a little bit faster with doing things such as tests and things like that and the hard hats not as mature however it is very popular at the moment however if you want to see some examples of truffle in action in the context of chain development you can head to our github repository and have a tropical starter kit here so recommend you check that out have a look at the instructions for for getting that going all right but for now lets continue so lets talk about hard hat now so hard hat is formerly known as builtler is a javascript development environment as well for basically creating deploying and interacting with smart contracts on any evm chain its got some cool features such as tasks which are these kind of reusable set of scripts basically which well go through in a minute its got a local hardware hat network to simulate uh running a local blockchain on your computer to save you having to deal with gas and things like that when you do your development its really well maintained um and theres great support for it as well if you have issues and you go to the discord youre always going to get help there its also got support for typescript actually so you can find hardhat at hardhat.org here and were going to be doing some stuff in the documentation today as part of our demo so moving forward lets talk about tasks and plugins so hard hat has what are called tasks and tasks can be thought of as kind of like a script but kind of more modular and flexible right and they can be called from with within other tasks or scripts etc so an example of a task is maybe funding your contract with link right and um anything you can do with a script you can generally create a task for um and you can kind of interoperate between the two i personally like using tasks more than scripts because i feel it provides slightly better ux when youre executing a task you just have to specify the task name you dont have to specify the file extension or the path or anything like that and i think its got better integration into the the magic of hardhat as well under the fluid however you can use tasks or scripts whenever you need to basically do stuff with your contracts so a plugin is basically packaging a task into something that then can be imported into other projects basically so um if you go to hardhat.org plugins you can see theres a whole bunch of um a whole bunch of plugins that are officially supported im not sure why the page isnt loading here but anyway um yeah so lots of plugins and um you can create tasks to basically uh do do certain things that you find yourself doing often as part of your smart contract development such as you know interacting with contracts calling certain contract function names etc so hardhat also has also whats called the local ethereum network local hardhat network sorry and this allows you to run uh and test your code without having to deal with a live public network such as you know the coven test net or mainnet etc so you can run this in standalone fashion on your computer and you can connect it to external clients you can do a whole bunch of stuff with it basically so you can kind of think of it as just like another network like you know coven or mainnet basically another cool feature of hardhat and the hardhat network is that you can fork the main net right so basically what this means is when you create a local hardhat network its generally a blank slate that has zero blocks zero transactions and every time you add uh do stuff um it will get added to the chain however um there are certain scenarios where you might not want a blank slate you might want to have all of the mainneck contracts available for you to interact with and do stuff with so you can do whats called forking the mainnet which basically takes a snapshot of the mainnet at that point in time and that becomes the starting point for your local hard hat network so when you deploy your contracts those contracts can then even interact and do stuff with main net contracts on this local fork so yeah really cool really cool functionality there all right lets lets get into a demo now so in this demo were going to create a new hard hat project from from scratch were going to set the configure were going to create a basic smart contract were going to create a script to deploy the smart contract and were going to create some tasks to interact with the smart contract were going to do that on a local hardhat network and the cover network as well so let me just bring up my vs code cool so the first thing we need to do is we need to install hardhat so im going to go to the installation section of the docs here at hardhat.org and heres the npm command so for hard hat you need to install have no js and npm installed so if you havent done that you can head to nodejs.org and install the latest version so im going to create a my first hardhat directory and im going to install hard hat here and that might take a minute while thats loading well go to the configuration section here so hard hat has a config file called hardhat.config.js this is the file that basically has all the the global settings that hardhat needs it it has all the networks that youre going to be deploying to it has the solidity versions that youre going that you want to compile contracts against et cetera so um theres a good uh template one here in in the config section so im actually gonna grab that one and copy it okay it should be finished any second cool so im just going to open my vs code to that folder now that i created cool so now that weve installed hardhat into this folder im going to run mpx hardhat there we go and what were going to do is were going to create a an empty hardhat.config.js file here and as you can see we have a package.json a nodemodules folder and an empty hardhat.config.js here so now im going to paste the contents of that template hardhat.config file that i had and were going to use this as a basis for setting our own config right so the first thing im going to do is im going to change the version of solidity to 0.8 there we go the next thing im going to do is im going to change ring to b to coven and im going to change this url to cliven rpc url ill explain this in a minute and accounts to private key cool so we need to create a couple of environment variables to basically set um the variable for our account that were going to deploy and interact with contracts right so we need to basically store the private key or grab the private key from somewhere for that account and also a connection to ethereum clover network so were going to be using um infuria for that so im going to create open rpc url and im going to grab that from an environment variable oven rpc url and private key and weve got private key cool and the the way in which we do this is were going to use a library called uh docent right um which allows us to store those sensitive kind of things in a emv file so im going to run npm install dot umb to basically install that library and while thats running im going to um import it here so you go require emb dots config so that basically will allow us to store these variables in a dot emv file and then they should be obtained from that env file and we can then use them in our config file here so emb example so the way you do it you should go private key equals then you get your private key from your wallet whether its metamask or whatever and put it in there and rpc url equals and you grab your um you go to infuria or any other ethereum provider if youre not running a node on the network that youre connecting to and you grab the the url string for connecting to to that network and you kind of plug it in here right um ive got a pre-filled one of this with my private key and and if youre a key so im going to just um quickly copy it into my local folder so that should be good to go oh all right so what is next so were gonna were gonna use uh a plug-in to to basically connect to ethereum and do stuff so were gonna use ethers hard hat ethers plug-in so if we go down to the docs and go to hardhat ethers uh in the plug-in section you can see here is a command to install that basically so im going to go back to my cli here and im going to install that so while thats installing were going to then were going to set some more details here cool all right thats done so weve set our emv file weve said that we want to use the hard hat network the cover network using this connection url and this private key and now we should be able to create our smart contracts sorry theres one more thing so once weve installed hardhat ethers were going to um import it here in our hard hat config file there we go oh so set our config lets create a smart contract so were going to create a new folder called contracts and were going to create a file called my first contract dot sol okay this is going to be a basic uh smart contract that just sets a value to salute you version eight contract my first contract joint number number uh integer were gonna set the number to zero initially in our constructor and then well have a segment number function number public and we say number equals num and then we have a data view returns you went and will return number very simple contract um i think that is all we need here now the next thing we need to do is um we need to oh oops like slightly press enter um the next thing we need to do is we need to compile this right so to to basically compile it we run a command basically mpx hardhat compile and what that will do is it will take a look at the config here and just quickly im going to change the default network to hardhat actually shouldnt be ring could be because thats no longer a no longer a network in our config here um so what that will do is it will go into our config file here and it will find our version um our specified versions that weve specified here and its going to see that weve specified version 0.8.0 here which basically it will then take and it will compile our smart contracts with with that version right so um lets clear this and go mpx hardhat compile or skin like something lets see solidity 0.8.0 oops lets try again okay we have a compiler error here um ah there we go wasnt closed okay lets try again okay lets take a look at this okay ah there we go one too many of those this is what happens when you code live on the fly quickly you int not unit this is how you know its not pre-recorded and its a live workshop and public all right that should hopefully be it cool compilation finished successfully so um once its compiled you can actually go into the artifacts and encage and you can kind of see um all the metadata associated with with the contract so you can see the abi and you can see the byte code and things like that so hardhat actually uses this swing when you kind of do deployments um so once thats done were going to now deploy our contracts so if we go to the deploying your contracts section you can kind of see a basic script for deploying a contract using ethers.js so were going to use that as a template and were going to go back to our project and were going to create a new folder called scripts and in there were going to create a deploy dot js were going to paste that in so the only thing we need to do here is so this is just a simple ethers.js script for getting a contract that weve compiled and then deploying it to a network and all were going to do is were going to change greeter here to my first contract which is the name of our contract and were gonna set this to my first contract with a little m and that should be i think contract doesnt have any parameters in the constructor so were saying from that metadata that we created basically get my first contract and deploy it to the specified network in hardhat.config which at the moment is set to hardhat so im going to open up a new terminal window and im going to start the the local hard hat network um so npx hardhat node is the command for that as you can see it generates a whole bunch of accounts and private keys so thats done so now that we have that running we should be able to deploy our contract to the hardhat network so lets go mpx hardhat run and then scripts toy.js cool contract deployed to and we get an address here so weve created a script to deploy the contract to to the local hardhat network lets create some tasks to interact with the um with the contracts so create a new folder called tasks and im going to create a new file ill call it my contract tasks.js so what well do now is well go back to the docs and well go to creating a task and if you scroll down you should see an example of creating a task basically so um i think yeah well take this one so im going to literally paste this example in our tasks file were going to remove web3 we dont need that so we need to create two tasks one to um write to set the number in our contract and one to read the number so the first one well do is a number and give it a description reads the number so what parameters does this task need to take it needs to take a contract um address so that is the the the address of the contract that we want to interact with um and i think thats it and then in the set action um all we need to do is basically put the logic that we want in the task in here right so basically what we want to do is we want to grab the we dont need these anymore i dont think um im gonna go const contract address equals task args.contract so from these um past arguments passed in here were going to get contract and store it into something and well go const my first contract equals a weight ethers.jet contract factory uh first contract so just like we did in the script here were gonna um get the my first contract uh contract deployment here and in addition to that we need to get the signing information so this is um specific to ethers.js so we need to get the account details for the account that were going to be signing transactions with so were gonna go const accounts equals await ethers dot get signers on signer equals accounts zero were taking out the first account and thats my first contract equals awaits new ethers.contract and were going to specify the contract address that we got here and its a my first contract contract and were going to use our signer that we got above to sign transactions then we say let result equals await my first contract dot get number so this is the solidity function that were going to be calling right um but i think we want to return it as a number so what i might do is i might go integer and to stringer o equals begin away my first contract get number dot two string so thats basically getting our sign information for our account creating um an instance of this contract at this address specified and then its calling the get number function on that and what well do at the end is well just say stored value is and salt cool so that is the read number task what im going to do now is im going to copy that exactly as is and um create another one called write to number writes the number so this takes a contract parameter um however we also need to specify a value to set in the number so im going to add another parameter called value and in terms of the set action its going to be very similar were going to also grab the value that was set so were going to take constant value and were going to get a connection to my first contract again get signing information and create a connection to it thats all fine and over here instead of get number were going to say set number whoops and were going to value okay were going to pass in the the value you dont need to do any big integer stuff here so the result equals uh my weight my first contract set number value and we can say value set and um well put value in here okay lets take a quick look that looks okay to me oops task bugs there we go so we get a connection to the deployed contract we get our signing information and we call set number cool so the next step now that weve created our tasks is we need to we need to add these tasks to our local hardhat runtime so to do that we we basically just import the um file here so we can go require um and i believe the syntax is dot forward slash tasks forward slash my contract tasks.js so that should import those two tasks so we can have them made available in our hard hat run time cool so now lets test that out so im going to go im going to deploy our smart contract again uh whoops um ive done something on here ah okay we dont need that in our task file lets try again oh sorry all right to deploy our smart contract were going to run our deploy script there we go so its deployed to this address here so now im going to run as you can see if i run mpx hard hat you can now see the read number and right number tasks show up so im going to say write number and were going to specify the contract that we just deployed and were going to specify a value of 77. oh there we go so value was set to 77. so that um executed our right number task here and it actually uh called the set number um function in our smart contract cool so lets change things up a bit now and lets change our config to now run on coven so lets deploy our smart contract to coven so in this case its going to use our private um key specified in the emv file and the coven rpc url so this one might take a little bit longer just check how were doing for time cool contract is deployed to here so what ill do now is ill do the same right number task that i did before ill set that to 77. cool thats done so now lets check the value with the read number task so i remove the value parameter and i change this to read number uh theres an error somewhere task args there we go there we go stored value is 77. cool were were running a bit behind time so im going to leave it at that so basically in this demo what we did is we created a new hard hat project we set the config we we created a new smart contract we created a script to deploy the smart contract um we created some tasks to interact with the smart contract once its deployed and we we played around with this contract and deployed it and interacted with uh on a local hard out network as well as on the cover network so lets move on now if we have some time and then ill answer a couple questions cool so now that you guys have had a bit of an introduction to hard hat lets talk about the hard hat starter kit so the hard hat starter kit is located in the chain link github repository here so if you go to chainings github smart contract kit you can see it pinned to the top here ill just zoom in a bit hard hat starter kit so basically this is a pre-packaged hard hat repository that contains all of the tools config and and some boilerplate smart contracts for using chain link uh services and solutions right so all of the standard smart contracts for doing a simple api call for interacting with the price feed for creating a keepers compatible contract for creating a vrf contract that uses vrf etc its all packaged into this repository and you can use that as a basis or as a starting point for creating your smart contracts or just as a reference point if you want something to reference while you create your your hackathon project so um its got everything you need to basically get going with when you want to use chain link and you can kind of uh even if you just want to reference it as a reference point for how to get a random number and how to create a task to interact with a contract that gets a random number etc its great for doing things like that as well so lets go through a demo for the hard hat starter kit now so im going to im going to close all of this and were going to go to the hard hat starter kit repository here im going to git clone right so you just pull the code locally you can do it with git if youve got kit installed or you can just grab it directly from from here as well its up to you im going to now change my folder github cool so as you can see on the left weve got a whole bunch of stuff here um so weve got a contract folder so this contains all of the uh standard boilerplate contracts for chaining services and solutions right so the price feed consumer the random number consumer contract for getting a random number uh keepers compatible contract that increments the counter and an api um simple api call example so these are these are all the contracts that are found in our docs as well so if youve interacted with these on remix before youll be familiar with them but these are the contracts in the starter kit as well weve also got some some mock um contracts which basically mock up things such as a link token or an oracle contract when youre running on a local network because when youre running on a local network you cant interact with the actual chainic live network because it doesnt know about your local network in addition to this weve got a bunch of deploy scripts set in a deploy folder right and just like we went through creating scripts before to deploy contracts its very much the same thing its going through its grabbing um compiled uh contracts and its deploying them um to to the specified network of choice right uh in addition to this uh we have a whole bunch of tasks right so weve got some uh generic tasks such as doing whats the balance of our account whats the current block number withdraw a link but then we have tasks specific to um to two contracts so the price consumer contract has a read price feed task the random number consumer contract has a read random number and a request random number task right and these are all very similar to the tasks that we created before and you can kind of go through it through and see all of the logic in here in addition to this weve got some tests but thats for another workshop later this week so im not going to go through those and finally we have our hardhat.config file where were importing a bunch of libraries a bunch of tasks that weve created were setting a bunch of environment variables that are used and we have a default network and some other networks as well right so the first thing we actually need to do which im going to do now because it might take a while is im going to install all of the dependencies by running yarn and what well do after that is um well set the emb file so if you look at the folder contents im just going to shut some of these there we go if you look at the folder contents you see theres a uh an example.env file right so it sets a coven rpc url were using inferior here and we have a private key that needs to be set as well so once again you need to export this private key from your account or that you want to use for deploying and interacting with contracts so if youre using metamask you can extract it from metamask or whatever wallet you can just extract it and the coven rpc or url sorry um you can use services such as infurial or fuse etc to kind of get one if you need so oh its still installing once that finishes we what well do is we will start off with the hard hat network so what ill do is ill start another terminal session here and i will start the local hard hat network so node ah i cant do it yet because i havent set the the details okay lets wait for this to finish lets see any questions here while were waiting how do you run tests mocha in hard hat um we have a workshop on tests um in a couple days so were going to be going through a whole bunch of stuff on on the subject of testing then so recommend checking checking that workshop out there um lets see okay were done so what im going to do now is ive got a pre filledout.emv file with my private key and my infuria thing so im going to grab that and copy it here so now that thats done lets go back to our other terminal and lets try start our mode again the mpx hardhat node well give that a minute so that actually compiles our contracts as well if theyre not compiled which they werent and as you can see it will start the node and we can see a whole bunch of output cool so we have a node thats running um what we do now is our contracts are compiled and you can kind of see all the the metadata thats created as well so now im going to do mpx hard hat deploy so this is actually a plug-in the hard hat deploy plug-in so you dont have to specify a script or anything what it will do is it will go to a deploy folder here and it will run each of these deploy scripts in order right so deploy mocks price consumer api consume etc and then up until this last setup contracts script here so im going to execute that and as we can see we get a whole bunch of outputs so the cool thing about the deploy scripts with the hardhat starter kit is um it gives you it gives you tasks that you can copy and paste to then interact with the contracts so for example for the price consumer contract that uses price feeds it says we deployed your contract to this address heres how you can then interact with the by running npx hard hat read price feed tasks passing in the contract and a network so im going to copy that and im going to literally paste it below and as you can see we have a return price here so because were running on a local network um we its just a static value thats thats not really a from an actual price feed however what we might do now to make it a bit more real is well change the default network to coven and lets deploy everything to coven now so well just give it a minute to deploy okay so as you can see we we get the output as well for every contract thats deployed along with some task information that we can use to basically interact with the deployed contracts one thing to note as well is we the hard hat starter kit has whats called a fun link task so what this does is in this setup contracts script deploy script here for the api consumer and the vrf consumer contract itll actually attempt to pre-fund those contracts with some link before you when theyre deployed so that when you deploy them theyre already ready to be interacted with you dont need to manually fund them with some link like you would if you were deploying those contracts with with the remix examples for example so just just to kind of save some time basically cool so thats done so now lets go back to the price consumer output and lets run the read price fee task with our deployed contract address there we go so that is the um price there i think thats the ethersd price i think its set to um so 4195 so lets try another one lets try the lets do vrf because that one uses link so lets call the request random number task starting our contract so that will call our task in our tasks random number consumer quest random number so that will go through and it will call the get random number um function in our smart contract so that will basically send a request to to the vrf node on coven and once that request is processed and sent back you can see that were given another command that we can run mpxheart hat read random number with our specified contract address to then read the result that that will probably take a few seconds to complete just checking how were doing for time so what ill do is ill copy the read random number command that was given and i will now execute it and we wait cool so we have a random number in our smart contract here so as you can see tasks are really great for for creating small bits of code to interact with your contracts and do things with your contracts once theyre deployed and theyre really easy to create you can kind of base them off other examples and things like that and you can use things like ethers.js or web3.js in conjunction with hardhat with with the plugins that they created for them to interact with your smart contracts using using tasks so were running a little bit late for time so im just going to wrap things up here and see if theres any questions so so theres just a basic example of of our starter kit it gives you all the smart contracts tasks config and things to deploy simple smart contracts that use chain link that you can then use as either a starting point or a reference when doing your smart contract development so if you need to get help as part of your hackathons projects if youre using hard hat truffle or whatever the best place to go is definitely in our discord chain.link forward slash discord we we have a some hackathon specific channels and were constantly monitoring those and wed love to help you out there if you have a hard hat specific issue or question hardhat has got a great discord as well so if you go to hardhat.org forward slash discord youll youll get added to their discord theyre always answering questions and helping people out so i ive personally gotten help from them multiple times in the discord so i can i can definitely recommend heading there if you have any hard hat specific issues as well once again our starter kits are pinned to the top of our repository here so if you go to our github smart contract kit we have our hard hat starter kit our truffle one uh our brownie one which i think patrick has gone through as well so you can find those there for just getting started with using chain link in your smart contracts and whoops uh and and yeah you can head to the docs for obviously for more info as well as other hackathon resources and things like that and um yeah just if you have any questions feel free to reach out and wed love to help you out so i hope this has been um helpful for for some people ive got a um feedback form that im going to paste into the comments here once i work out how to add a comment and then ill see if theres a couple questions because weve got just a couple minutes all right im pasting the link into the youtube chat cool there we go so yeah if you guys want to give any feedback um yeah feel free wed love to have it so im just going to stop showing my screen um cool lets see if theres any other questions here so what do you think of using hard hat in a remote server and deploy adapts with devop tools so the hard hat so the hard hat can be leveraged as a test server instance does this sound cumbersome any better strategy um i mean it sounds feasible ive never done it personally uh however if it gets you the results you need i say yeah why not um i cant see why you shouldnt be able to to do that um any other questions here lets take a look im going to scroll up because i know i may have missed some before to install hard hardhat again for every project there is a global install um i think i think you can do it as a global install i dont think i did for this demo here but its just like any other npm package fork fork maintenance for testing is sweet yes definitely is um if i had a little bit more time i would have the mainnet today but maybe on on the wednesday workshop uh in testing well try and do some forking of mainnet definitely helpful lets see any questions in the youtube channel is hard hat more popular than truffle if i only learn one should it be hard hat um thats a tough one because truffle is so mature now that theres so much stuff thats been created with it however hardhat is probably more popular for new projects right now so for example a lot of the big d5 protocols use hard hats so uni swap rv et cetera if you go to their repositories youll see hardhat in there youll see hardhat configs tasks etc so id say is probably more popular now however truffle is more mature so its personal preference i guess in the end my recommendation is try both see which one you like better which one you find easier to work with i personally like hard hat i feel its a little bit quicker and easier to work with however its personal choice how to use with flash loans and keepers thats a topic for another talk um i think we may have had a keepers demo yesterday actually so recommend checking that out and if you want some information specifically on flash loans if you head to our blog at blog.chain.link and and search for flashlines there youll see theres some really good articles um that talk about them so hopefully that can can help you out okay anything else cool all right i cant see anything else here so i think well wrap it up well wrap it up now so yeah i just want to say thanks everyone for watching really look forward to seeing what kind of stuff you build as part of this hackathon definitely reach out to us if you need help reach out to the hard hat guys if youre using hard hat and you have issues with with hard hat specifically as well if you have issues with our starter kits reach out to us we would love to to kind of help you out if you find issues with our starter kits please raise an issue in github so we can kind of action them as soon as possible as well so yeah im going to sign off now and say thanks everyone for for tuning in and well see you next time bye everyone you Chainlink is the industry standard for building, accessing, and selling oracle services needed to power hybrid smart contracts on any blockchain. Chainlink oracle networks provide smart contracts with a way to reliably connect to any external API and leverage secure off-chain computations for enabling feature-rich applications. Chainlink currently secures tens of billions of dollars across DeFi, insurance, gaming, and other major industries, and offers global enterprises and leading data providers a universal gateway to all blockchains.Learn more about Chainlink: Website: Docs: Twitter:
cineberisso.com.ar