Current location: Homepage > code > Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep127

Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep127

2025-07-11 12:00:03 [ai] Source: MetaScripta
if chain ID oops chain IDdoes not exist then once again we'regoing to do ai taking jobsconstants do address zero sowe're just going to leave it blank andthen we're going to do the exact samething for the fu slth die token so we'lldo const futokenaddress equals chain ID question mark Soif the chain ID does exist it'll be thebrownieconfignetworks networkname FAUtoken and if chain ID doesn't existwill'll beconstants address zero okay awesome andif we save it oops looks like I put anextra comma in there by accident justgoing to get rid of that andresave and then refresh here so I'mgetting an issue uh because I'm on therink be chain right now and it's sayinghey there's no there's nothing for rinkthere's no dap token for rink beat yougot to be on Coen so if I go back tokovenhere and I refresh now it works out fineright this might still break for you ifyou're on Coen and you haven't deployedanything to Coen we can fix this in ourconfig for the D Provider by changingthe supported chains for this nowtypically a lot of the times you'regoing to want to test using a ganachechain or some type of local chain sothat your front end testing can be a lotfaster for this we're just going to doeverything on Coen but a nice littlechallenge for you would be to refactorthis so that it also works withsomething like ganache and we're goingto not use ganache so I'm just going togo back to app. TSX we're going toremove ganache even we're going to evenremove rink B for now we're just goingto work with Coen just to make it simpleif I go to our react page now refresh Ican connect awesome if I go to rink Bit's not going to freak out because itsays Hey rink B is not even supported soI don't care what you're doing howeverkoven is supported so we're connectedand we're looking good and the thing iswe really don't want to couple our frontend with our contracts right we reallywant to code the contracts independentlyin the front end independently anywaysso let's get back into our main . TSX sowe're going to be in here for a whilebut we've already done some great thingswe've gotten what network we're on whatchain ID we're on and we've gotten thedifferent addresses for these differenttokens so as you can probably see theplace that we're actually going to putstuff on the front end is in this littlereturn statement here right right nowwe're just returning I'm Main and I wejust see I'm main right here to do thiswe're actually going to make anothercomponent we're going to make acomponent called your wallet thiscomponent is going to be part of thisMaincomponent here it's a component insideof a component that is literally onlygoing to address our wallet needs so onour little components tab here we'regoing to go ahead and create a newfolder and we're going to call it yourwallet this is just going to haveeverything to do with our wallet in hereso let's get in here we'll create a newfile because we're going to actuallymake a couple files and our first one isjust going to be your wallet.TSX this is going to be our componentthat is just going to deal with gettingour wallet getting the token balances ofthe different tokens that we have sincewe know we're going to put thiscomponent in Main and Main is in our ourhome base our app. TSX you know thatwe're going to do an export const yourwallet in here and we'll make this afunction now in order to actually showthese tokens we do need to get someinformation from our other component weneed to get some information on what thesupported tokens even are so we're goingto have our main actually pass avariable to our wallet here we're goingto call it thesupported tokens and this is going to beoftype your wallet[Music]props and this is going to be a yourwallet props here just to telltypescript what this is what thissupported tokens is going to look likewe're going to say interface your walletprops it's going to look like like thissupported tokens and it's going to be anarray of token array of sometoken we're going to grab that tokentype from Main as well so actually we'regoing to do importtokenfromMain and in our main we're going to passthis token and we're going to pass somesupported tokens to our wallet so rightunderneath those three token addressesback in main we're going to do constsupported tokens is going to be anarray of token this tokentype so above here we're going to doexport typetokenequals and we're going to say a tokentype is going to involve an image whichis going to be a string an address whichis also going to be a string and a namewhich will also be a string so we'recreating a new type called token here inour main function we're creating thissupported tokens object which is anarray of tokens and this is excuse meand this is going to equal that arraysyntax so our firsttoken is going to be have animage that we haven't defined yet theaddress is going to be this dap tokenaddress and the namethe name of course is going to be dap ordap token now we're going to need acouple images so at this point youshould see where we're going with thiswe're create this array of supportedtokens first is our dap token and weneed an image for this dap token so ifyou're following along you can just grabthis image right off of the GitHub andwe're going to grab that D token andwe're going to pop it intoSRC we're going to change this to dap.PNG now we can import this by doingimport dapfrom dap. PNG now we can take this dapimage and under image I'll put now let'sdo the other tokens so we'll do a commawe'll doimage will be F oops F address will bewetoken we token address name will be weand again we can either oh let's closethis off and again we can either grabright from my GitHub or pop it into mySRC here we'll change this to f.pngwe'll

(Editor: html)

Recommended articles
Hot reading