Loading video player...
All of you welcome back to yet another
project video. In this project, you're
going to build the most advanced staking
dab where user will stake the native
currency and they will earn reward in
form of ERC20 token. It will compatible
with all the EVM compatible chain. So
you can deploy on Binance, Polygon,
Ethereum where user will deposit their
ETH and they will get the ERC20 token.
So let me give you a complete walk
through that what are the feature and
functionality we have included. have
included for the admin. So how you can
control the entire smart contract and
provide all of this feature. So when the
user will come back to our application,
this is what exactly they will find. Up
to bottom we have this beautiful
interface. So the very first section we
have is our header section and we have
staking tab. Here we have these two
option. One is the stake and the other
one is the admin. So if you are admin,
you can easily to redirect to the admin
panel and from there you can control the
entire smart contract. Here we have the
current to wallet. So you can simply
click here. You will have this pop-up
model. You can simply copy and you can
disconnect or connect your wallet. Here
you will find the hero section where we
are providing all the stats regarding
your transaction which you have done
with the wallet. So you will find that
currently the total stake you have done
in this particular pool I have done to
poll. So I have deployed the contract on
polygon but you can deploy to any EVM
compatible chain. So all the transaction
which I'm going to do I'm going to do on
the polygon main network but at the end
I will also show you that how you can
deploy to test network like EVM
compatible chain like so far. So just
wait and watch this video till the end.
So I have done the actual transaction
and I have deposit two pool into the
contract and this reward would only
calculated when the time will complete
which we're going to talk about it. So
you will find the total pool I have
stake is two and here you will find your
void balance. So this is the overall
stats about the stake and your wallet.
Now if you come back to the pool section
and here we are providing four different
pools. If the user will stake for 30
days they will get 10% of what they will
stake. We have a 90 days, 180 days and
365 days and the percentage will go up.
From here you can give the amount which
you want to deposit. You can see your
wallet balance and here is a condition.
If you try to withdraw the fund out of
the contract early before completing
this period then you have to pay 5%
penalty on that and the minimum stake we
have set it to one pole but you can set
to any quantity and the reward would
only unlock when the time period will be
completed. So I have to wait for the
time period completed then the reward
going to display here. If you come back
to the my stake here you will find all
the history about the stake which you
have done. So altogether I have done two
stake one is for 90 days and the other
one is also for 90 days. So if I want to
withdraw I can withdraw that fund very
easily. So this is the pool I have
created yesterday and you can see the
time is 89 days 6 hour remaining and
this is the one which I have created
just now. So 89 days 33 hours is
remaining. So if I want to withdraw my
fund out of it, I have to pay 5% penalty
on that and the rest of the amount I
will have in my wallet which I'm going
to show you in practical performing the
transaction. So you can come back here
and here you will find the overview
which I have provided. So user can
simply connect their wallet, stick the
token and earn the reward. Here we have
this beautiful photo section. So that's
all we have dashboard for the user where
he can perform all the transaction. So
before I take you to the admin panel,
let's perform the transaction. So here
you will find that I'm connected with
the admin account. So admin can also do
the investment and perform all the
general action which user can do. So
what I will do let's try to stake uh
let's create another pool for getting
the reward. So I'll simply take this 365
and I want to stake let's say one pool
because that's the minimum but you can
go higher up to that and you can see
that how much you're going to get on the
reward. You can set the reward any
quantity which you want. You can go with
this one. You can see every single thing
is going to be changed. So this reward
system is you can able to manage in your
contract. So you can come back here and
I want to start staking now. So I'll
click on this stake now and you will
find the transaction is happening. Now
I'm going to call my Metamas and I'm
depositing my phone. You can see I'm
giving my one poll to the contract. I'll
click on this confirm and here the
transaction is the process. Once the
transaction will be completed, you will
find that this data would store and our
fund is going to be transferred into the
contract and the entire calculation
would be started. So I have successfully
deposited one pool into this particular
pool. If I come back to my stake, I can
click here and here I can able to find
the stake which I have done just now.
You can see the reward. So this is the
reward I will get after completing 360
days. If you want to create more pool,
you can see this fund went down and I
can come back to the staking and there
you will find that we have other ones.
So if I go with 180, I can give my
another one pool and I can see the
amount which I will get and I can click
on the stick now and it's going to
deposit and it will be in my
transactional history. So simply confirm
the transaction and the transaction is
happening. The transaction is happening.
Once the transaction will complete, I
can able to see the logs in my
transactional history. So here you will
find the transaction is completed and
this is the pool I have chosen. So I can
come back to my stake and there you will
find all the stake which you have done.
Now let's do one thing. Let's try to
withdraw the pool and I'm going to pay
the penalty for it. That's the one thing
you have to keep in mind. So let's take
this one 360 that one. I'll simply
select this one and it's going to make a
call and here I have to simply confirm
the transaction. You can see how much
you're going to receive because we have
paid 5% penalty. You can set any penalty
amount. So I'll simply click on this
confirm. But 5% we have in the industry
at the moment. Whatever project you will
find related to staking. So the
transaction the process once the
transaction will complete you will find
the notification that we have
successfully withdraw our fund and is
went down went down and right now we
have three pools. If I want I can
withdraw that one as well. So let's
withdraw this one 180. I'll click here
and I'm going to pay the penalty. So
I'll selecting that one. I'll come back
here. You can see I'm going to get this
much because I have invested one pole.
So I'll simply click on this confirm and
the transaction is happening.
Once the transaction will complete you
will have your fund back after paying
the penalty. So finally we have
successfully withdraw our fund out of
the pool. Once the time period will be
over the button will be visible. So you
can simply get your fund and simply get
the reward as well. So that's how you
can able to stake in the pool. Every
single thing is working absolutely fine.
That's how user will interact and do the
investment. Now let me show you how you
can able to perform all the transaction
and control the entire smart contract as
a admin. So that's how you have seen me
performing the transaction as a user.
Now I can come back to the so click on
this admin and you will come back to the
admin page and here you will have the
complete stat of the entire smart
contract. So you can see stake we have
in total total reward token how much
plenty you have earned what is the
current balance in the smart contract
what is the minimum staking and here you
will find the average percentage reward
and here we have all the function like
deposit reward token withdraw reward
token if you want to withdraw the
penalty which you have earned you can
withdraw that and here you can update
the minimum staken and here we have the
emergency function which will withdraw
all the fund from the smart contract
including the user invest investment. So
you should not call this because if you
try to withdraw user will not able to
get their fund back to their vault
address. So this one is the emergency
one. Don't include it. Okay? And don't
call this one. Now let me show you how
you can deposit the tokens. Right now we
have 90. If I want to deposit let's say
100 token. I can click on this deposit
and the transaction is the process. All
right. Got it? Now all I have to do is
to simply click on this confirm and it's
going to perform two transaction. First
is going to approve the token to the
contract. The second is going to simply
transfer and deposit the token in the
contract. So just wait. The transaction
is happening. Here we got the another
pop-up. And this time I have to simply
click on this confirm and we are
depositing and sending our token to the
contract.
So that's how you can deposit in the
contract. So we got the notification if
you want to withdraw you can do that. So
for example, I want to withdraw 19 token
this 19. So click on this withdraw. And
here the transaction is happening. It
will withdraw the token straight away
and you can see that you going to get 90
token. Click on this confirm and the
transaction is the process. Once the
transaction will complete you can able
to have that 90 token back to your
wallet and every single state would be
changed. So finally we got the state.
Now if I want to collect the penalty
which I have earned because the user st
the token and they have withdraw early.
So we are charging 5% penalty on that.
So this is the penalty withdrawal
function. So I'll simply click here and
it going to withdraw the penalty we have
earned. So we can see 005%.
Click on this confirm and the
transaction is in the process.
Once it will complete the transaction
and we'll have the fund back to our
wallet address. So just wait here we
have withdraw the fund. It's empty. If
you want to change the minimum stake you
can do that. So you can go with let's
say 2 or 11 whatever you want to decide.
Or if you want to go with let's say
decimal you can do that but I'll go with
let's say two. Click on this update and
it's going to update the
minimum staking in the contract. So
let's click on this confirm and the
transaction is in the happening. Once
the transaction will complete you can
able to have and you can see it's
updated successfully the minimum
staking. So this is how you can able to
control the entire smart contract. This
one is the emergency function which will
withdraw all the fund and destroy the
entire contract. So we should not call
this. So that's how you can able to
control the entire smart contract. I
hope you have understood that what are
the feature and functionality we have
included and what control you have as an
admin. How the user can invest and how
they can withdraw. If they withdraw only
you going to earn penalty quickly on top
of it. So let me quickly withdraw all my
investment because I have this staking
and I have all of this. Let me withdraw
my fund. So this is the one which I'm
withdrawing. If I want to wait for the
reward, I have to wait for like 90 days
or 30 days. Then I can able to get the
reward and I can claim it. So here I got
it. Now I want to withdraw this one as
well in which I have invest pool. So
let's click on this investment confirm
and the transaction is happening.
Once it will complete you will get the
notification and you can see the details
about the transaction. So we have done
with that. If you come back to your
stake you can able to find that you
don't have any stake. your fund got back
here. If I come back to admin, I can see
the reward, the current balance in a
smart contract and I can simply call
this withdraw to withdraw all the
penalty. So, I'll simply click on this
and it's going to perform the
transaction. Here you can see the
details. Click on this confirm and I
will have the penalty back into my
wallet
and just wait soon it will be completed
and I will have my fund which I have
earned in the penalty in my wallet. So,
just wait here. I got it. I want to
withdraw this one as well because this
is my actual token on the polygon. I'll
withdraw all of that. So that's how you
can able to control. I hope you have
understood. It's looks simple but it's
really powerful and most of the project
which you will find right now we have in
the industry is follow the exact model
where you can stick the native currency
and get the custom reward token. So
that's how we have. So I hope you have
understood all the feature and
functionality functionality we have
included and how this entire project
would work. Now let me provide you all
the resources which you need to develop
this project and if you want you can get
the final source code to fast your
development. So to get the assets you
can click on the link down below in the
description or you can come back to the
blockchain coder come back here open a
new tab type the blockchain coder here
you will find all the project we have
developed on our channel. So we have
more than 100 plus projects. So make
sure to check and go through all of
this. You will find all the complete
tutorial which you can simply follow. So
make sure to loging in. Once you will
log in you can have the option called
source code and here you will have all
the project we have developed. So build
at least five of them if you really want
to master complete blockchain
development build at least five of them
it will help you to understand the
complete architecture and check all of
this project. So to get the asset you
can click on this click on this recent
and you will come back here click on
this and here you will find the complete
starter file including the final source
code. So click on the starter file. It
will take you to the GitHub and here you
can able to understand the complete
architecture we have utilized for this
particular project. What are the models?
What are the folder and file structure?
So you can simply have a look try to
clone the repository and save in your
system. So when the complete project
will come you can start following
straight away. Now let me show you how
you have to do the final code setup. So
make sure to get the final source code
and when you will take it you will give
your valuable contribution to my team to
bring more tutorial like this. Once you
will download the final source code you
will get the zip file. Make sure to
extract the zip file and you will get
this folder in which you will have the
complete source code of the project
which you have seen in the demo. So make
sure to install a zip extractor then you
can extract this file and get this
folder and this is the one we have to
open in our VS code. So let's click on
the VS code and right now you will find
that I have this empty. I'll click on
this open go back to desktop and I have
the folder as which I will select and
click on open. Now let me give you a
complete walkthrough of the folder and
file structure we have designed for this
project. And this one is very important
which you have to understand before you
make any changes and perform any
transaction. So just test the way I'm
doing it. After that do all the
experiment from your end. So first I'm
going to deploy the contract to polygon
main network. After that I will show you
that how you can deploy to Sofali test
network. So once you will open the
project this is the complete folder file
structure you will find in this
particular project. So the very first
one we have is the app in which you will
find the admin page and the global page.
So if you open the admin you don't need
to make any changes just keep it as it
is. You can see this red under lines.
I'm getting this because I have a
different configuration in my preer. So
just keep it as it is. So this is the
admin we have. This is the global CSS.
This is the layout. This is the page and
this is the web3 provider where we are
doing the wallet configuration. Just
keep it as it is. Don't need to make any
changes. First test the way I'm doing
it. After that make all the changes. So
that's the first folder we have which is
app. The next one we have is the
component in which you will find all the
component we have designed like admin
dashboard dashboard footer header
staking card and stats card. So just
keep it as it is. Close this one. Now
come back here. Go back to the
configuration and here you will find
that we have the AI of our ERC20 token
because we are providing reward to the
user and we need to have the function of
the AI which we can execute to transfer
the token. So that's what we have here.
Here we have the index in which you will
find some network configuration I have
done. So this one is for the polygon
mainet where I'm doing the transfer and
currently polygon Mumbai is already
depreciated but I have given you. So you
can simply check. We also have a polygon
MI which is a test network and we have
the local host. So just keep it as it
is. You don't need to make any changes.
If you want to configure manually you
can add the network just like this. Got
it? And here we have some other network
configuration and other models which you
can see the data which we are using
throughout our application. That's all
we have here. So close this one. And we
have the most important one is our
contract AI. Contract AI the JSON file.
So this is the huge contract we have
coded and we have deployed that and we
got the AI. So just keep it as it is.
Don't need to make any changes. Just
keep it as it is. Close this one. Close
this one. Now come back to the context.
There you will find these three file. We
have the users admin which allow us to
do the validation and call the admin
functionality. So that's what we have
built in the context. Keep it as it is.
The next one we have is the use use
staking. So here we have all the feature
which allow the user will call and stake
and tracking down the entire data. Keep
it as it is. The next one we have is the
web three context where we are
interacting and performing all the
transaction. So just keep it it where we
are reading the data and injecting into
our component. So that's what we have in
the web3 context. Close this one. Now
come back to the contract and this one
is the most important thing which you
have to understand. So click on this
contract and we have this called staking
contract. Staking contract click here
and here you will find the complete
contract we have coded which bring all
the functionality for the user as well
as the admin. So we're using the open
zeppelink library which is the
predefined contract for having the
ownership reint.
And here you will find the different
variable which we have defined. So I'm
charging 5% penalty. If you want to
charge higher penalty, you can take
that. And here you will find some other
variables and all of the functions. So I
would suggest you to take your time try
to go through that. It's very simple and
very powerful industry standard. So just
have a look on this. Close this one. Now
come back to the public. In that we have
the assets. So right now we don't have
anything in the asset folder. If you
want to keep your assets like the images
which you can keep it very easily. Now
come back to the next one which is the
script and there you will find that we
have written our deploy script which
allow us to deploy our smart contract.
So we are getting the contract we are
getting the deployer we are providing
all the relevant information and then we
are deploying and getting the address of
our contract which we're going to do it
together just wait close this one close
this one come back to the style it's
empty folder if you want to add any
external files for the styling you can
keep it but just keep it as it is. Now
come back to the most important thing
which is the environment variable where
you have to provide all your data. So
I'll click on this filement variable and
here you have to provide all the
environment variable from your side. I
have also given this RPC endpoint which
is my and it has a limited number of
requests. So I will also show you it's
free to get and how you can get it and
how you can replace. So I'm going to
first test on polygon. After that I'm
going to move to Sofali and that's what
I have done the configuration. Here you
have to paste your private key of your
wallet which you want to use for
deploying and that wallet is going to be
the admin of the contract which have all
the control. So you have to get your
private key because that's what we're
going to use it for deployment. And here
you have to put your token address which
you want to allow user to get reward. So
it's going to be the same address. So
that's what you have to paste the
minimum stake we are allowing. So when
the user will deploy the contract that's
the minimum we are allowing them to
stake in the pool. And here you have to
provide your sticking contract after
deployment. And here is the name. So you
can call whatever name you want to your
application. And here you have to
provide your project ID for wallet
connect because that's where we are
providing most of the vault option. So
we're going to get it all of this
together. Just wait. Let's close this
one. And here we have some other files
like islain get ignore keep it as it is.
We have the hard configuration. So I
have already done the configuration for
the two different network. One is for
polygon and the other one is for Safali.
But if you want to configure any other
network, you can simply do the
configuration just like that and provide
the relevant information. We have the
next dev, next config, packages and
files. We are following the most stable
version. So no matter when you are
developing this project, it will work
absolutely fine as long as you follow
this particular video the way I'm doing
the setup. So don't make any changes. We
are focusing on stability. So it can be
working absolutely fine for next 5 to 10
years. The next one we have is the post
CSS looking absolutely fine. We have the
readme file. You can simply have a look
where I have given the detailed
explanation about the project and all
the important links for getting some
important credential. That's all you
will find. We have the two different
Telvin CSS file. Just keep it as it is.
Close this one. And we have the tx
config file JSON. And here we have done
the model configuration and webpack.
That's all we have. So this is the
complete folder file structure we have
in this particular project. I hope you
have understood every single thing. I
would suggest you not to make any
changes. Just test the way I'm doing it.
Okay. So now first thing we have to do
is to get our environment variable. So
I'll simply come back here in the
environment variable and let's get these
variable. Although this will work
absolutely fine but it has a limited
number of request which you can make. So
it better to have your own. So let's get
the RPC endpoint. So to get that we can
come back hit enter and you will find
the very first link. Click here and you
will come back here. So make sure to
create your account and login then you
will have your API credentials. API
credentials. So I'll simply click on the
sign in. So make sure to verify your
account after creating it. So finally I
got into my dashboard and I can go back
to the chain list and there you will
find all the RPC node which is available
through this provider. So I need the
polygon. I can click here and I can
click on this copy endpoint. I will go
with the mainet because that's where I'm
going to deploy and that's what I'm
going to paste here for the polygon. So
replace and paste. I got my RPC
endpoint. That's the one thing or you
can also do the configuration here as
well. So you can see this is the one I
have and here we have this polygon and
that's what we are getting from our
environment variable. Got it? Perfect.
Now I'll close this one. And now come
back here. Now we have to get for the
Sofali because we are using also I'll
come back here. I'll close this one.
I'll go back to the chain list. I'll go
back to the Ethereum in which we have
the Sofali. So I'll simply click here.
Click on this test and go back to Sofali
and copy. And that's what so this is my
Sofali endpoint. So that's how you can
get your own. That's the very first
thing you have to do. You have to get
your polygon and the Sofali. We got it.
Now we can come back to the private key
because this one is very important. But
before we get the private key, you have
to get your token. So I believe that you
already have your token which you want
to provide as a reward. I have already
created my token on Polygon main network
and that's what I'm going to use it. So
I'll come back here and I'm going to
open my Metamas. I'll select my Metamas
and you can see I'm connected with the
Polygon mainet. And if I go back to my
token, I already have my token which I
have created on polygon. So I'll simply
click here and this is the address of
the token. I will simply copy. If you
don't know how to create a token, you
can come back here and here we have
multiple project which allow you to
launch your own token. So this is the
one project which help you to create
your ERC20 token and we have the other
advanced token project which you can
use. So you can check all of that. This
is the other one and come back to my
corator and I'm going to provide the
address of the token which I want to
provide as a reward. This is going to be
the token. Got it? Here you have to
select the quantity which you want to
allow as a minimum stake. But I would
suggest you to go with this because this
is what we follow in the industry. And
here you have to provide your contract
address which we going to do it
together. Now here we have to get a
project ID. So let's get this one. After
that we going to get the private key.
I'll open a new tab. Type
wallet connect project ID and you will
come back here. Click on this first
link. Click here and you will get into
your dashboard. Let me minimize this
one. You will get into your dashboard
and here you will find all the details
about your project. So make sure to
create account and verify it. Then you
will have all the feature available in
your dashboard. So to create a new
project can come back here and you can
click on this create new project. You
can call whatever you want. I can say
staking and select this one. Click on
this create and it's going to create a
brand new project for you and you will
get this particular one. Simply copy and
that's what you have to provide here. So
you got it. Now I'll come back here.
I'll provide this one. Perfect. So you
can see we have given all our credential
the RPC endpoint. We have to get the
private key of our wallet. You can see
this is what I have and all of things
are looking good. Now I have to get my
contract address. So before I do that
first I have to get my private key and I
will deploy the contract. Then I can
able to provide my contract address
here. So let's get the private key
first. So I'll come back here. I'll
close this existing tabs. Open up my
Metamas. And you can see that I'm into
my Metamas wallet and I already have
enough fund which I can use to deploy
the contract. And this is the account
which I'm going to use and it's going to
be the admin of my contract. So to get
the details about the private key, I can
click on this account, click on this
private key and here you have to paste
your credential. So let me give that
and I'm going to click on this confirm.
So let me quickly copy my private key.
Then I will come back once again. So
finally I got my private key. I'll come
back here and I'm going to paste my
private key here. So finally I provided
my private key. Now we are ready to
deploy our contract. Once we'll deploy
it, we'll get the address and that's
what we're going to provide here. Got
it? Now I'll simply close this one. And
here we have the AI which is going to be
just keep it as it is. We have the
sticking contract. So we're going to
simply get that as well. Or if you want
you can simply delete this one as well.
So we have deleted our AI. Just do it.
Okay. So we are ready with all the
environment variable. Now we have to
deploy our contract. So if you come back
to the packages and file, we have to run
this command. This is going to deploy to
polygon. And if we execute this one is
going to deploy to sofa. So first I'm
going to do the installation of all
these packages. So I'll open my
terminal. And if I show you the
environment I'm using. So if I show you
my node version, I have the latest one.
So it will work absolutely fine. No
matter when you are developing, make
sure to use the exact node version for a
better stability and you won't have any
issue. If I check my npm version, I have
the latest one. So it looks absolutely
fine. Now I have to do the installation.
So I'll simply type npm. I hit enter and
it's going to do the installation of all
the packages which I have included in my
project. This might takes a little bit
time depending on your internet speeds
your system configuration. So just wait.
Don't stop and interrupt the
installation. Just wait and soon the
installation will complete and we are
ready to test and deploy our contract.
If you're done with the installation,
you can see we are getting couple of
warnings. Simply ignore that we are
focusing on stability. So simply ignore
all of this depreciated depreciate
because it will work absolutely fine.
Now I have to clear my terminal. So now
we are ready to start our application
and deploy our contract. So you will
find that we have our node modules in
which we have all the packages. Now come
back to the packages file and this is
the command we have to execute the
compile mode and it's going to generate
the artifact and the AB of our contract.
So I'm on the same directory taking
native currency. I'll type npm
run and
compile. Hit enter. And it's going to
compile our smart contract. And you can
see that I'm getting this particular
error. Can you guess why I'm getting
this error? So to fix this error, we can
come back to the harded config file. And
we have commented the network
configuration for the sofal in our
environment variable. That's why we are
having this issue because there is no
variable for this. So all I have to do
is to simply come back here and comment
this. Once I will do that, every single
thing would be working fine because we
have to keep one network active at a
time. So we are done with that. Now I'll
simply come back here. I'm going to
clear my terminal and I'm going to run
the command which is which is compile
compile and hit enter. And now it's
going to simply down load all that and
it's going to compile our smart contract
successfully. So once you're done with
the compilation you will get this
artifact in the cachier and in the
artifact you will have the contracts in
which you will have this sticking
contract AI. So what I will do I'll
simply select or I can simply copy and
I'm going to paste here my AI. Make sure
to do that. Okay. So we got the AI of
our contract. So far so good. Looks
pretty good. I'll close this one. I'll
close this one. I'll close this one. And
we are done with the compilation. Now we
have to execute this command because we
are deploying to polygon mainet. Got it.
I'll simply type first let me clear my
terminal. Type npm run and the deploy
script. Hit enter and it's going to
simply deploy our contract. So you can
able to so we got the address of our
contract. If you really want to verify
you can do that very easily. So this is
the account which I have used and I can
come back to the polycan open up paste
your wa address and you will find that
your contract is successfully created.
So this is the one which I have
deployed. Click here and this is the
same address we have. I got it. So I'll
simply copy and that's what I have
provided in my environment variable. So
I got the addresses. Every single thing
is looking good. Now I will clear my
terminal. I'll close this one. Now I'm
going to start the application. So this
is the command we have to execute. So
I'll come back here and this is the dev
one I have to execute. So simply type
npm rundev. Hit enter and it's going to
start our application on local 3000. So
we are using on stability. I'll simply
copy that one. I'll close this one. And
you can minimize it just like this or
you can do it from here. Don't delete
it. Okay. So I'll minimize this one.
Every single thing is looking good. If
you come back here in the config, you
will find that we have activated the
polygon and that's where we have
deployed our contract. So simply close
this one. Close this one. Now we can
come back to the browser. Open a new tab
and click on the local. And here you
will find that our application got
started. Simply reload the page and it's
going to implement all the animations.
You can see I'm already connected with
the Metamas. So I'll simply click here.
You can see the details or you can
disconnect. You can click here and here
you will have the option called Metamas.
Select and I'm connected with the admin
account which is the account number two.
I'll simply click on this connect. And
here I'm connected with the crypto
wallet. You can see all the details
about the project. Right now we have all
the pools. There's no staking and there
is no data in the contract. this much
fund I have in my wallet. So first thing
you have to connect with your admin
account and you have to deposit the
reward token in the contract. So come
back to the admin section and there you
will have you can see it's going to
verify your details. So simply give a
quick reload and it's going to give you
the details and you will have the access
of your dashboard and there you will
have all the details about the project.
So you can see this is the minimum stake
we have allowed but you can update that.
So I'm going to deposit the reward
token. So I already have I'll give this
let's say 100 token. So 100 I'll click
on this deposit and it's going to
perform two transaction. First we have
to approve and second we have to simply
execute. So here I'm confirming. Click
on confirm. Now I'm going to transfer
the token. So it's going to call one
more time. You can also check in your
MetaMask and you will find that we have
approved successfully. Now you can click
on this deposit function. Click on this
confirm and we are giving our token and
it's going to deposit in the smart
contract. And here we have done with the
deposit successfully. You can able to
find it's going to reflect here the
deposit. You can deposit that very
easily. If you want to withdraw the
reward token, you can simply click on
this and I want to withdraw 10 token and
it's going to withdraw the token from
the contract back to my wallet. And here
you can see I have the options and I'm
getting the token which is 10 token.
Click on this confirm and the
transaction is in the pending. Just
wait. Soon the transaction will complete
and you will have the token back to your
wallet and you will get the notification
or you can also check your Phantom
wallet and we got it. So that's how you
can deposit and withdraw your token. And
here we have some additional function
like withdraw withdraw their investment
early before completing the time. You
will have this option visible and you
can able to withdraw all the penalty.
And if you want to set the minimum and
maximum right now this is the minimum
but if you want to increase it you can
do that. I can click on this one and I
can click on this update minimum and
it's going to update the minimum amount
which we have set. So let's click on
this update and right now it's going to
change to one pole. So there is no
longer 0. It's updated. You can also
confirm here. So that's how you can able
to update the minimum staking. And here
we have added the emergency function.
You should never call it. This one will
withdraw all the fund from the contract
including the user investment and just
keep this as it is. So this is how you
can control. Now let's come back here to
the homepage and let's try to do couple
of investment. So you can see I already
have this much fund and I already have
all the tokens. So I want to invest for
90 days or 30 days 180 360 you can do
that. So let's invest for 30 days and I
want to give let's say one port. You can
see how much you can get. You can give
for 30 360 and you can see how much you
will get as a reward. Now I can click on
this take now and it's going to perform
the transaction. Here I'm getting the
option and I'm calling the deposit. I'm
giving one poll. I can click on this
confirm and the transaction is in the
process.
transaction in the process and is going
to simply execute it and deposit the
fund I have. So I have done the deposit
for this particular pool. You will find
your investment. Here you will find your
investment.
You can come back here. You can see the
investment you have done. If you want to
do the investment once again like for 30
days. If you want to give your quantity
give that and you can see the expected
reward. Click on this take and it will
perform the transaction and you can
simply click on this confirm. And here
the transaction is happening. You are
depositing the fund into the contract.
So that's what we have here. So looks
fine. Just wait. Soon the transaction
will complete and you will get the
confirmation right up here. So we have
done with that. If you want to deposit
for 90 days, you can see it's getting
down and the fund is getting available
in the contract. If I want to do for 90
days, I can give that and I can call
this let's say one or you can give any
one or you can call this two. But I will
go with because this is my real fund. So
I'll go with this one one. And I can
simply deposit the fund which I want. So
click on this confirm and the
transaction is happening. Soon it will
be completed and the fund would be
deposited in the contract.
So just wait. It's taking a little bit
time. Soon we'll get the confirmation.
So we are done with the deposit. So you
can see the fund the stats all is there.
You can come back to the my stats and
here you will find all of this. So if I
want to withdraw early my fund without
completing time, I have to pay the
penalty of 5%. So let's do that. I'll
click on this withdraw early and it's
going to perform the transaction. I'll
come back here and you can see we are
charging 5% penalty. So that's why it
went down. I'll click on this confirm
and the transaction is the process and
once it will be completed you will have
the notification and this will be
hidden from this particular section. So
here the transaction is completed. Now
we have these two pools which we have
and we have withdraw that. If you come
back to the admin section there you will
find the details that how many
investment we have. You can see the
penalty collection you have got. This is
the total token balance available we
have in the contract and that's what you
can see all.
So let's try to withdraw this fund. So I
can come back here. You can see this is
visible now. Now I can able to withdraw
the fund. Click on this withdraw. And
here the pro transaction is performing.
You can see we are withdrawing our fund.
Click on confirm and soon we'll have our
fund back to our wallet. The penalty we
have earned. So finally we got it. And
now you will find two pool is left in
the contract. So that's how you have to
do the setup. I hope you have understood
all the feature and functionality we
have included in this particular project
and how you can able to do the testing
in your environment. How you can deploy
the contract and how you can perform all
the transaction. Now let me show you
that how you can deploy the contract to
the Sofali test network if you don't
want to test on the mainet. The process
is going to be exactly the same. Hope
you have understood that how you can
deploy the contract and do all the
testing on the polygon. Now let me show
you that how you can deploy very quickly
on the Sofali test network. So first
thing we have to do is to activate our
network in our environment variable. So
I'll simply come back here. So I'll come
back here first. I'm going to deactivate
this and I'm going to activate
the Sofali network and I'm going to use
the same wallet address because in which
I have some funds. I'll open my Metamas
and right now you can see that I'm
connected with account number two with
Polygon. But I'm going to switch back to
Sofali the Ethereum test network and by
default it will be available in your
Metamas. So make sure to activate test
network in your Metamas. Then this
Sofali network would be available. So
make sure to select this one and you
will find that I already have enough
fund in my wallet five which is enough
to deploy the contract and perform all
the transaction and this is the token
which I have which I can use for
deployment and interacting with the
reward. So first thing if you don't have
this test foret you can get it very
easily. First copy the address and you
can come back to the web 3 Google web 3
Google faucet. Click on the second link
and here you will have the option. So
you can simply paste your vault address
and click on this get and it's going to
transfer you 0 five sofali. I already
made a request yesterday. So I have to
wait for one day. And one thing you have
to understand that you can make one
request in one day. So I already have
enough fund which I can use to deploy
the contract. So that's one thing you
have to do. Now you have to get your
token. I hope you have your token. If
you don't have your token, you can come
back here, pick the project and simply
create your token. So I'll simply come
back here. I'm going to use this token
body and I will get the address of this
contract. So simply copy that one and
that's what I have to provide. So I'll
simply come back to my coator and I have
activated that one and I'm going to use
the same account number two. So my
private key is already here. Now I have
to simply pro change the void
uh token address. So this is the one.
Now I'm going to change this one as
well. So I've got my addresses. Now I
can come back here. This is the polygon
one. Contract address. I have to
redefine it. Once I will deploy the
contract, I'll get that one. Now every
single thing is looking good. What I
will do now? I'm going to simply open up
my terminal. So first let's close this
one. Save it. Now I will open my
terminal and I'm going to stop the
application from running. I got it. Now
I can come back to the hard config file.
I'm going to deactivate this one and I'm
going to activate our sofali.
That's what we have done. We have
activated our sofali. I'll close this
one. Come back here in the packages file
and this is the command I have to
execute. So simply copy open up my
terminal and I'm going to simply type
npm run got this particular command once
again. So copy and that's what I can
provide and hit enter and it's going to
compile my contract and it's going to
deploy the contract to Sofali network
and you can see I got the address. So we
got our contract address looks
absolutely fine. Now you can simply copy
this one.
You can copy this. Now close this one.
Come back to the environment variable
and here you have to provide the
contract address. So you got your
contract address looks absolutely fine.
So that's how you can deploy your
contract and you can perform the
transaction. So once you're done with
the contract address on all the
environment variable close this one we
are done with this now you can come back
to the wing the config and there we have
the wing and here you have to simply
activate the sofali so simply copy and
paste sofali and replace this one
you got it now you can clear your
terminal type npm run dev and it's going
to start our application on local 3000
you can simply copy close this one close
this one Close this one. Come back to
the browser. Open a new tab. Paste the
URL. Hit enter. And you will find that
our application is live. Simply reload
the page and you will find that our
application is absolutely fine and it's
connected with the Sofali. You can see
it's displaying poll because it's a
hardcode currency. You can simply go to
each one of the component and whenever
you find pole you can replace with
Sofali. If I show you my metamas, you
can see I'm connected with the Sofali.
If I come back here, I can disconnect. I
can click on this connect and I can
select the metamas or any other wallet
and I can simply connect with my account
and here I'm connected. The moment I
will change the network like if I go
back the other network like the main
network polygon and if I give a reload
it will say wrong network. I can click
here and it will automatically connect
with the polygon. Open up your metamas
and you can double confirm. You can see
sometime the metamas will block. So you
can simply confirm and change the
network manually and so select sofale.
Perfect. And now you're ready to perform
all the transaction the way we have
done. So I hope you have understood that
what are the feature and functionality
we have included. If you don't have your
token you can come back here. Here we
have a project which you can use to
create your ERC20 token. You can check
this project or you can check the other
project we have. There may have multiple
project which allow us to create the
token. So check this one. So that's the
only thing I want to cover. I hope you
have understood all the feature and
functionality. If you have any question
any doubt do let me know in the comment
section. I'll definitely try to help in
that. Have a wonderful. Bye-bye.
Source Code: https://www.theblockchaincoders.com/sourceCode/create-and-deploy-staking-native-currency-dapp-or-earn-erc20-token-rewards-or-next.js-+-solidity-full-project Blockchain Course: https://www.theblockchaincoders.com/pro-nft-marketplace All Project Code: https://www.theblockchaincoders.com/SourceCode Donate Please: https://linktr.ee/daulathussain 1 - 1 Consultancy: https://www.theblockchaincoders.com/consultancy Pro Blockchain Courses: https://www.theblockchaincoders.com/ Public Discord: https://discord.gg/Gah6YGuBFS Create & Deploy Staking Native Currency DApp | Earn ERC20 Token Rewards | Next.js + Solidity Full Project Build a fully functional Staking DApp where users can stake their native blockchain currency (ETH, BNB, MATIC, etc.) and earn ERC20 token rewards ā all powered by Next.js, Solidity, and Web3. In this step-by-step tutorial, you will learn: - š How to create a native currency staking smart contract - š° How to distribute ERC20 token rewards to stakers - āļø How to build the full-stack DApp using Next.js - š How to connect wallets (MetaMask, etc.) - š¤ How to deploy your smart contract on any EVM blockchain - š How to integrate staking, reward claiming, and UI dashboards - š” How to verify and interact with your contract on the blockchain Perfect for beginners and intermediate blockchain developers who want to learn real-world Web3 development with full frontend + smart contract integration. š§ Tech Stack Used - Solidity - Hardhat / Foundry - Next.js - Ethers.js / Wagmi - ERC20 Token - Any EVM Blockchain (ETH, BSC, Polygon, Avalanche, etc.) š Timestamps 00:00:00 ⤠Introduction 00:00:33 ⤠Overview 00:03:19 ⤠Features Demo 00:11:39 ⤠Starter File 00:12:46 ⤠Final Source Code 00:19:36 ⤠Environment Variables 00:24:15 ⤠Installation 00:28:17 ⤠Testing Live Save NFT Marketplace PlayList: https://youtube.com/playlist?list=PLWUCKsxdKl0olgEF4OxXVk2B-jwpGqL5d API PlayList: https://youtube.com/playlist?list=PLWUCKsxdKl0oAFAVuRZxQSYC07UTcl_v_ Solidity PlayList: https://youtube.com/playlist?list=PLWUCKsxdKl0oksYr6IG_wRsaSUySQC0ck Complete JavaScript Course: https://youtube.com/playlist?list=PLWUCKsxdKl0qROhA0XO4_ek9bIwZ4j4Xr HTML Course Code: https://www.daulathussain.com/complete-html-course-daulat-hussain/ =================== HOSTING ++++++++++++++++++++ Best Hosting: https://clients.domainracer.com/aff.php?aff=28826 Follow Me: Instagram: https://www.instagram.com/daulathussain92/ Facebook: https://www.facebook.com/daulat.hussain.18 Twitter: https://x.com/TheBCoders Pinterest: https://in.pinterest.com/daulathussainhealthfitness/ Linkedin: https://www.linkedin.com/in/daulat-hussain/ Quora: https://www.quora.com/q/schahkxkdudpgjvh Facebook Group: https://www.facebook.com/groups/59011 Facebook Page: https://www.facebook.com/yourdhfitness Subscribe to My Channel: https://www.youtube.com/channel/UCz6_...