Miners use a process called ‘hashing’ – turning an input into a sequence of letters and numbers – to solve these complex puzzles. If you did as well, pat yourself on the back and share it with us on the thirdweb Discord! If you want to take a look at the code, check out the GitHub Repository.Miners around the world produce trillions of computations every minute and whoever gets to the winning proof-of-work first receives a batch of that cryptocurrency, which typically happens every 10 minutes. This guide taught us how to allow your users to stake the ERC1155 NFTs they hold and earn rewards for staking them! Getting the owned NFTs: const address = useAddress() Ĭonst Let's edit the index.tsx page to add this logic. We will first show the NFTs that the person holds and allow them to stake these with a button. This is the chainId your dApp will work on.Ĭonst activeChainId = ChainId.Mumbai Showing Owned NFTs of Connected Wallet Using the CLI, create a new Next.js & TypeScript project with the React SDK preconfigured for you, using the following command: npx thirdweb create app -next -tsīy default the network is Ethereum Mainnet, you'll need to change it to the network you deployed your smart contracts to inside the _app.tsx file. Now let's create an NFT staking web app where users can connect their wallets, stake/withdraw NFTs, and claim rewards.īefore we begin, you can access the complete source code for this template on GitHub. Once done click on execute and you are good to go! Creating a Staking Web Application Deposit the tokens into the smart contract This is the function we're going to use to supply our staking contract with funds for it to distribute as rewards.Īdd the amount of tokens you want to deposit into the staking contract address. Here, you will see a depositRewardTokens function. Approve the contract to spend tokensįinally, go to the explore tab of the Staking contract. We're going to allow the staking contract to spend (amount) of tokens so that it can pay rewards to the stakers.Įnter your staking contract address and an amount that you think is suitable, click on Execute and approve the transaction. Head over to the explore tab on your Token contract, and click on the approve function. Head back to your ERC20 smart contract and approve tokens for your newly deployed staking smart contract address to spend. Once you're ready, click Deploy Now to ship your staking smart contract! Deposit ERC20 Token You can use the information below each field to help you understand what values you need to fill them out with. You will now need to provide some configuration for your staking contract. Head to the EditionStake smart contract page, and click Deploy Now: Deploy the StakeERC1155 contract We will move on to the exciting part and deploy the staking contract itself! Click "Mint" to create an additional supply of your token.Įnter an amount and click on Mint tokens: Add in the mint amount and click Mint tokens Deploy an Edition Staking Smart Contract Head to the Tokens tab and click on Mint. To do that, let's first mint some tokens in our ERC20 smart contract and transfer them to the staking contract. The way the EditionStake.sol smart contract works that we're going to deploy next is by transferring tokens to the user when they claim their staking rewards.įor this reason, we need to provide the staking smart contract with a supply of tokens for it to transfer. I am using the Polygon testnet Mumbai, but you can choose any network you prefer.Įnsure you deploy this to the same network as your NFT collection. Set up your smart contract with an image, name, description, etc., and configure which wallet address will receive the funds from primary and secondary sales: Populate metadata for the edition drop contract If you don't already have an ERC1155 NFT collection smart contract, head to the Explore page and select the Edition Drop smart contract: thirdweb Explore Pageįrom this page, click Deploy Now on the latest version: Deploy Edition Drop ContractĪ drawer will open to populate the metadata of the NFT Drop contract you're going to deploy. Let's get started! Deploy An Edition Drop Smart Contract Building a frontend web application to interact with the contract.Creating the ERC20 Token smart contract.Creating the ERC1155 Edition smart contract.In this guide, we'll show you how to create and deploy an ERC1155 NFT staking smart contract, where people can stake their Edition NFTs and earn ERC20 tokens as rewards.
0 Comments
Leave a Reply. |