Current location: Current location: Home > c > Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep95 Text
Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep95
[c] Time: 2025-07-11 11:56:42 Source: AIHackNode Author: cs Click: 76 times
ton of plugins and interstellar ambitionsyou'llwait a while for everything to getuploaded and you wait and you wait alittle bit for everything to getdownloaded we're not going to do thatthough because I'm going to show you howto convert this to JavaScript anyways ifin future hardhead sections as we'recoding along with JavaScript if you wantto code along with typescript youabsolutely 100% can but let's go aheadand show you what the main differencesare now that advanced typescript thingis going to add a whole bunch ofpackages that you may or may not want Iwill talk about some of them in our nextlesson but there are going to be somethat you absolutely do need those aregoing to be at type chain ethersdv5 at type chain slard hat attypescript at types SL Chai at types SLnode at types SL mocha TS node typechain andtypescript and I have a link and in theGitHub repo associated with this courseI've got this yarn ad that you can justcopy paste if you want to just copypaste that into your project to run itoops and I should have added those asDev dependencies so we're going toactually just make them Dev dependenciesreal quick just by deleting these twolines and adding a comma here awesomethat looks much better and then ofcourse what we're going to do is we'regoing to convert all of our JavaScriptto typescript so anywhere where we haveJs we're going to put TS obviously ifyou're coding this from scratch withtypescript you would do the TS from theget-go this includes our hard hat.config that's also going to betypescript now and additionally we'regoing to add a TS config.js this isgoing to be our typescript configurationtypically for a setup we're going to gowith something like this and you cancopy this from the GitHub repoassociated with this course it'sbasically telling typescript whatversions of typescript and what files toinclude for working with typescript nowlet's go ahead and start with our deploytypescript per usual instead of usingrequire we're going to go ahead and useimport so we're going to do the exactsame thing we're going to have importethers runnetwork[Music]from hardap and then in our verifyfunction we're going to add we're goingto add the types for these arguments socontract address is going to be a stringand args is going to be an array ofarguments so we're going to say it'sgoing to be any array because it couldbe string it could be numbers it couldbe booleans it could be anything we'realso going to say for our e it could beany even though this is technically anerror type we're just going to put anyfor Simplicity for now all of ourtypescript scripts are included in ourTS config or any typescript files aremanually added here which we have ourentire scripts folder here which is goodso now we need to add ethers in herewell if we look at our hard hat.config.sys TS we can see that thatlinting has gone away if you want to beeven more explicit we can go ahead andadd import Atomic Labs SL hard hatethers like so reason we don't need toimported here is because these twopackages also work with hardhead ethersso they automatically import it but ifyou want to be super explicit you can goahead and add it like so now we'realmost good to go but remember our hardhat. config is also importing our tasksso we're going to need to update ourtasks our block number to be types scripified so of course instead of constrequire we're going to do import taskfrom hardhead SLC config and we're goingto be sure to export our task from blocknumber as the default so we're going todo export default task like so and nowwe should be good to run our scripts sowe can just do yarn AR hat run scriptsdeploy TS we can do Network hard hat ifwe choose and awesome now it's when weget to the testing that things get alittle bit different here so let's goahead and change this require to importjust to make it happy there and let'stry to run run yarn Aradtest we get a whole bunch of errors andin vs code we'll actually go ahead andget these errors right from the linterone of the trickiest things that you runinto as a developer in this space iscalling functions on contracts wherethose functions don't exist or viceversa we're not calling functions oncontracts that do exist right now thetyping for our contracts is just typecontract which isn't super helpfulbecause type contract doesn'tnecessarily have all the functions thatwe want it to have we want our contractsto be of type contract but we want themto be of of the type of our contractbecause if they're the type of ourcontract they can have all the functionsthat we want them to have so to give ourcontracts the correct typing here weactually can use this tool called typechain which gives our contracts correcttyping type chain has a hardhead plug-inwhich allows us to use type chain andtypescript natively together type chainhard hat was one of these things that wealready installed and to add it to ourhard hat we got to just go to the hardhat config and add it in import at typechain SL hardap now once we import thatin to our config if we run yarn hardapwe now get a new task here called typechain you read the description it saysgenerate type chain typings for compiledcontracts this will enable all of ourcontracts to have their own typing so wecan have a simple storage variable oftype simple storage contract which ismuch better because we're always goingto know exactly what we can do with eachcontract to create this we run yarn HardHat type chain and this is going tocreate a new folder called type chaintypes with types for all of ourcontracts you can even go into oursimple storage. TS which is going tohave all the different functions andeverything you could do with our simplestorage contract automatically codedinto typescript in JavaScript for uswhich is incredibly helpful and again Iknow I haven't shown you what this isyet but in ourg ignore we usually wantto add type chain and type chain Dastypes into
(Editor in charge: php)
Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep22Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep144
Related content
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep163
- Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep127
- GenAI Essentials – Full Course for Beginners - Ep98
- Artificial Intelligence Full Course _ Artificial Intelligence Tutorial for Beginners _ Edureka - Ep33
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep94
- GenAI Essentials – Full Course for Beginners - Ep192
- Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep82
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep12
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep106
- GenAI Essentials – Full Course for Beginners - Ep20
- GenAI Essentials – Full Course for Beginners - Ep126
- GenAI Essentials – Full Course for Beginners - Ep140
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep136
- GenAI Essentials – Full Course for Beginners - Ep88
Wonderful recommendations
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep161
- Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep125
- GenAI Essentials – Full Course for Beginners - Ep67
- Web3 Incorporation in Panama (A Legal Guide) - Ep1
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep284
- Full interview_ Donald Trump details his plans for Day 1 and beyond in the White House - Ep9
Popular Clicks