Member Login - User Registration - Set as Homepage - Add to Favorites - Website Map Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep90!

Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep90

Time: 2025-07-11 11:43:43 Source: Codora.ai Author: go Reading: 197 times
so what's going onon well our hard hat network is women in spaceactuallydifferent from this locally runningNetwork here this locally runningNetwork we often want to refer to as ourLocal Host so it's slightly differentthan the hardhead Network it's stillusing the hardhead runtime environmentbut it's just not this default hardheadNetwork it's considered its own separateNetwork when we're running a a node thatis going to live past the duration of ascript so we can actually interact withthis by adding a new network Network toour hardhead doc config.js we'll createa new network and call it LocalHost and exactly as we did up here we'llgive it a URL accounts and a chain ID sofor a URL we can get that URL right fromour terminal output of running yarnhardhead node by copying that andpasting it in here we can then do acomma we'll give it a chainID of 31337because even though it's considered adifferent network it actually has thesame chain ID as hard have interestinglyenough I know I just said we were goingto give it accounts but we actuallydon't need to give it accounts becausewhen we run with this Local Hosthardhead will automatically give usthese 10 fake accounts for us so you cankind of think of of the accounts herefor this Local Host as as hard hadalready placing them in thanks hardapbut now if we go back to our bash herelet clear the terminal let's rerun thescript and we'lldo-- Network Local Host now we should bepointing to this node and when I runthis script we should see some loggingoutput at the end of this node so let'sgo ahead and hit enter well we see ournormal stuff on our deploy script weflip back to our node wow we see a tonof logging here similar to ganach we cansee a whole bunch of different log LS onwhat just happened we can see a contractwas deployed we can see the address thetransaction hash from value gas and theblock number and everything we can alsosee our contract call calling the storefunction to update the value of ourfavorite number this is incrediblypowerful for quickly testing and workingwith things on a local JavaScript VM orhardhead Network to be able to see howyour contracts will interact on a realtestnet and this is much quicker thanworking with a real test net nowadditionally same as what we said beforeany process that's running in theterminal we can kill it with contrl C soif you want to stop your node and thenrestart it you can hit contrl C to stopit and then just up and then rerun thatsame command to resin up your nodecontrl C stops it and then you can hitup to start again another way you canstop it of course is if you hit thetrash can which deletes the wholeterminal you pull the terminal back upwe can run it again and just remember ifyou hit the x that actually doesn'tdelete the terminal that just hides itso our hardhead node right now is stillrunning because I just hit it so if Ipull it back up I can see that it isindeed still running but if I trash canit and then I pulled the terminal backup I can see that it is no longerrunning so running scripts is great butwhat if I don't want to have to code anentire script to do some things what ifI want to just Tinker around with theblockchain well hard hat comes packedwith this thing called the console theconsole is a JavaScript environment forus to run JavaScript commands tointeract with any blockchain we can jumpinto the console by running yarn hardhat console and then whatever Networkflag if we want to work on rink B mainnet polygon Avalanche Etc D- Networklocal hosts and now we're dropped into ashell here in this shell we can doeverything that we do in a deploy scriptand we don't even have to run theseImports because everything with hard hatis automatically imported into ourconsole so for example let's say Iwanted to get a simple storage contractFactory well I could run exactly thisline here I could say const simplestorage Factory equals weight ethersdoget contract Factory of simple storageand now I can go ahead and even deploythis so I can even just copy this linepaste it and if we flip back to our nodewe'll see that we just deployed anothersimple storage and now I can do thingslike await simplestorage.retrieve and I get the return valuewhich is going to be a big number with avalue of zero I can also maketransactions so I can do a weit simplestoragestore let's do55 if I hit up twice I can go back tothe simple storage. retrieve call thatfunction and I can see my big number hasa value of 55 now this is a great way toquickly interact with any blockchainthat we want now you can exit the Shellby hitting contrl C twice to get out oryou can also just you can also trash canyour terminal if you get confused thisconsole works with any network we caneven do yarn hard hat console D- Networkhardap and we'll get dropped into a hardhat Network now this is not going to bethe same node that's running here thisis going to be one that only runs forthe duration of this command so wheneverwe cancel this command this hardheadNetwork gets cancelled we close out ofthat too we can also do yarn hardapconsole D- Network rink B rink b orpolygon or test net or main net orwhatever we want and we can do thingslike ethers dopr provider dot you dothings like await ethers provider. getetblock number see the block number ofrink be we can also deploy contracts wecan update contracts we can do anythingthat we want you can do anything inthese consoles and they're great ways toquickly test and tinker and interactwithcontracts now there's a couple othertasks that are really helpful you'll seebefore I went ahead and just deletedartifacts and deleted cash manually wellwell to do that yourself you can alsojust run yarn hardheadclean and that'll delete the artifactsfolder and clear out your cache wealready know what compile does one ofthe biggest things

(Editor in charge: cpp)

Related content
  • Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep130
  • Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep61
  • Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep147
  • Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep3
  • Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep14
  • Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep11
  • Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep53
  • Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep43
Recommended content
  • Artificial Intelligence Full Course _ Artificial Intelligence Tutorial for Beginners _ Edureka - Ep41
  • Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep108
  • Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep38
  • Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep14
  • Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep134
  • The Basics of Web3 - Ep5