Current location: Current location: Home > web3 > Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep39 Text
Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep39
[web3] Time: 2025-07-11 11:53:01 Source: AIHackNode Author: article Click: 101 times
staking contract andwe'll cover that contract in a littlebit more detail right now so coming backto the explore page on ai skills for beginnersthe third webswebsite we're going to scroll down a bitand we're going to see a section calledstakingand staking here you can see you canstake your nfts or tokens to earn erc20tokens in return and essentially whatwe're going to be doing is we can take alook at our demo application here we'llhead to our staking contract herecontract is staking our ERC 721 tokensand what staking means is depositingthis nft to our staking contract and ourstaking contract is going to then holdon to this nft and what we'll be able todo in our contract is set a reward forhowever long that nft is deposited inthe contract the owner's wallet will beable to earn a set amount of rewards wecan say for every minute that this nftis in this contract you earn one tokenand we'll be able to set that to anyvalue that we want so what we'll do hereis actually test this in our demoapplication so let's take this nft intoour staking contract we'll have toconfirm that transaction that appears inorder to execute this functionand once our nft is staked you can seeit is now in the staked section of ourapplication we have no unstaged nftshere and if we wait a bit we'll start toearn a reward balance now currently Ihave this set to earn one token every 15seconds so we'll wait a bit I'll comeback once we have a few tokens that wehave rewarded to us and then we'll beable to claim those tokensall right so we waited a bit and you cansee here our reward balance we now havea claimable reward of 3.4 tokens now ourcurrent balance in this wallet is uh 400025 tokens so when we claim that 3.4 weshould get an updated balance amount inhere so with this will be able to claimRewardswe'll confirm that transaction becauseagain we are executing a function on oursmart contract so we're gonna have topay some gas for itand you can see we added a littlenotification here saying our rewardshave been claimed and you can see hereour value has updated we now own 400030.4 tokens and again this is howstaking contracts work we can alsounstake our nft which is going towithdraw our nft from the contract andput it back into our own walletand you can see here we now haveunstaked that nft and we now have itback in our wallet right over here sowe're going to deploy this stakingcontract and again in the explore pageof third web we actually have apre-built contract that does all of thisfor us now we do have a few stakingcontracts here in our case we're goingto do a stake ERC 721 which defines thatthe staked token or the token that wehave to deposit in order to earn erc20tokens as a reward has to be an ERC 721but you can also do this for ERC 1155 orerc20s as well so we're going to selectthe stake erc721 again we are brought tothe publish page for the contract hereand we're going to select deploy now inthe top right now we need to add a fewthings here for this contract the firstthing we need to add is the name of thecontract so we're going to name this athird weberc7 721staking we'll name this stake 721 we'lljust paste our description here from ourproject and we'll add an image in thereas wellnow compared to some of the othercontracts that we've deployed there area few more contract parameters that weneed to fill out here you can see herethe first one is the erc20 reward tokenaddress so this is going to be the tokenaddress of the erc20 token that we wantto reward people when they have an nftstaked here and in this instance it'sgoing to be our third web token here sowe're going to come to our third webtoken contract copy that head back toour staking contract here paste that inthen the next one is the ERC 721 stakingtoken so this is the ERC 721 nft that wehave to stake in order to earn thiserc20 reward so we'll come over to ourthird web ERC 721copy that and then come back here andpaste that in now the next one down hereis time unit for rewards we can read thedescription here and it says that thisnumber is going to be in seconds and anexample is if we want to give out ourreward per hour then we'll have to enter3600 because that's how many seconds arewith one hour now we're going to do thisreward just like how we did the otherone which was 15 seconds so every 15seconds we're going to give out a rewardand we'll specify how much that rewardis down here in the reward per unit timeso in here we're going to say every 15seconds how much of a reward is thattoken going to earn so if we read downhere too we're also going to have to seewe'll also see that this number has tobe in way if you remember when we dealwith numbers and that we input intocontracts we're going to have to use theway unit so we can come to the converterhere in ethers we're going to put oneand we're going to get the value in wayhere copy itcome back to our contract here and inputthat reward per unit timenow the networker chain we're going tomake sure that this is on the samenetwork and chain that we deployed ourother contracts to in my case I'm usingthe Mumbai test net and I'm going to hitdeploy nowwe'll get a transaction that pops up andwe'll pay for the gas here to deploy ourcontractand then we'll sign that transaction toadd it to our dashboard and once yourstaking contract has been deployedyou'll be brought to the stakingcontract dashboard here now we do needto set up a few things before thiscontract is actually ready to be usedwithin our application now again with astaking contract we are rewarding theusers who stake their ERC 721 with anerc20 token now the only thing right
(Editor in charge: rust)
Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep60Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep74
Related content
- Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep134
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep206
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep191
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep220
- Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep9
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep278
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep196
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep72
- Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep11
- XRP Ripple LIVE Senate Brad Garlinghouse - FROM WALL STREET TO WEB3 - Martyn Lucas Investor - Ep18
- 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 - Ep13
- Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep105
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep151
Wonderful recommendations
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep243
- Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep53
- Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep13
- Web3 & Crypto Will Change The World As We Know It! Yat Siu - Ep1
- Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep15
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep148
Popular Clicks