Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep40

[c] Time: 2025-07-11 11:39:20 Source: AIHackNode Author: ai Click: 129 times
nowis we don't have sarah cindy white killerany erc20 tokensto actually reward people from thiscontract this contract doesn't own anyof those tokens so we have to be able todeposit some tokens in here so that itcan reward those tokens out to the usersthat stake their ERC 721 token now to dothis we're going to have to do a coupleof things so what I'm going to do hereis copy the contract address of ourstaking contract we're going to come onover to our third web token or erc20token and we're going to head to theExplorernow down in our write functions herethere's a function called approve andwhat a proof is going to do is we'regoing to we're going to give the addressof who is allowed to spend or transferthese tokens but what we're going to dohere is we're going to approve thespending of this token automatically forour staking contract so in the spenderhere the spender is our staking contractthat contract is the one that is goingto be transferring these tokens out topeople when they want to claim therewardnow the amount that we're going to giveit the ability to spend for this examplewe're just going to do a hundredthousandso again we're going to use theconverter we're going to get that valuein waywe'll come back to our contract andpaste that in so what we're doing rightnow is we're approving our stakingcontract the ability to transfer up to ahundred thousand of our tokens right nowso we're going to execute that functionhere and this approval here is normallythe transaction that appears but we'regoing to take care of this approval forup to a hundred thousandwe're gonna hit use default here whichwill just make it the value that we areasking it for which will be a hundredthousand we'll hit next and then we'llhit approveall right and you can see ourtransaction went through so now ourstaking contract has the approval totransfer up to a hundred thousand tokensthe only thing is right now it doesn'thave the tokens to transfer we'll haveto deposit those hundred thousand tokensinto our staking contract so we head onover back to our staking contract and wehead to the Explorer tab for thiscontract you'll see there is a writefunction called deposit reward tokensand what we're going to be able to dohere is deposit our erc20 token andwe'll be able to depositly search anamount in our case we're going to usethat same way value for a hundredthousand and we're going to execute sowhat we're doing now is sending ahundred thousand tokens from our walletto the staking contractand there you can see our transactionwent through and we have deposited ahundred thousand tokens to our stickycontract so we actually take our stakingcontract address head back to our erc20token and we head to the read functionshere we can actually read the balance ofand paste in our contract hereand you can see our contract or astaking contract has a hundred thousandof the erc20 tokens that it's going touse to reward out to people who staketheir ERC 721 into the stadium contractso now we have all six of our contractsdeployed and set up all of them have aimage metadata title description and ourstaking contract is set up to startrewarding people who stake their ERC 721tokens so now with all of that set we'regoing to start building out ourapplication we're going to take a lookat the third web SDK and see how easy itis to start building blockchainapplications with itnow that we have all of our smartcontracts set to build our applicationwe're going to start building out ourblockchain application using thirdweb'sevm SDK so right now I am on third websdocs and we're gonna head on over to theevm SDK so in the left-hand navigationhere we'll head over to evmsdk and theevm SDK is available in a variety oflanguages from react react native formobile apps typescript python go we evenhave a Unity support for games but inthis course we're going to be buildingout web applications and we're going tobe using react hereso heading to the third web react SDKyou can read a little bit about it herewe're gonna head on over to the getgetting started section and you can seehere getting started if you already havea react project you can install 3rdosSDK by the install right over here oryou can create a new project and that'swhat we're going to be doing by usingthe MPX third web create app command sowhat I'm going to do here is open up myterminal and in our terminal here we'regoing to run MPX third web create appand when we run that you can see hereour CLI is checking for any new updatesyou'll see here we do have a new versionof the CLI available so we're going tohit yes to upgrade it once it's doneupgrading we'll have to name our projectwe'll name this third web course appthen we'll select the blockchain thatwe're building this application for soagain we support any evm compatibleblockchain we also support Solana aswell but again we will be using evmblockchains throughout this course sowe're going to select evm here now hereyou can select the framework you want touse now we're going to be using next.jsbut if you are more familiar and youwant to use react you can use react andstill follow along within this course aswell but again I'm going to be usingnext.js so we'll hit enter here and thenthe language we're going to be using forthis we're going to use typescript butfeel free to also use JavaScript as welland you can still follow along if youfeel more comfortable using that so I'mgoing to select typescript hereand once it is done what we'll do nextis change directory into our projecthere so I'm going to change into thirdweb course app and I'm going to use thecommand here code period to open this inmy code editorso once in our code editor here you cansee that we have a bunch of files hereand we need to first set up ourapplication and there are a few stepsthat we need to take to set this up sothe first thing we need to do is in ourPages

(Editor in charge: kotlin)

Related content
Wonderful recommendations
Popular Clicks
Friendly links