Skip to content

Latest commit

 

History

History
98 lines (69 loc) · 3.84 KB

README.md

File metadata and controls

98 lines (69 loc) · 3.84 KB

Quests Smart Contracts Evm

Adding a New Chain to Quest Service

To add a new chain to the Quest Service, you need to update the hardhat.config.js file with new network and Etherscan configuration details. Below is an example of how to configure a new chain, specifically for the Polygon network.

Configuration

Update your hardhat.config.js with the following network configuration for Polygon:

module.exports = {
  networks: {
    polygon: {
      url: "https://polygon.meowrpc.com",
      accounts: ["<Private key>"],
    }
  },
  etherscan: {
    apiKey: {
      polygon: "<Api Key>",
    }
  }
};

Deployment

Use the following commands to deploy and manage contracts on the Polygon network:

  1. Compile contracts:

    npx hardhat compile
    
  2. Deploy the TokenHolder contract:

    npx hardhat run scripts/deployTokenHolder.js --network polygon
    
  3. Verify the TokenHolder contract:

    npx hardhat verify --network polygon <contractAddress>
    
  4. Before running the deployment, ensure to update this line in the deploy.js script as specified: Update this line with token holder before deploy.js.

  5. Deploy the quest service contract:

    npx hardhat run scripts/deploy.js --network polygon
    
  6. Verify the quest service contract:

    npx hardhat verify --network polygon <contractAddress> <tokenHolderAddress>
    
  7. setQuestsDappRadarApprovalStatus:

    setQuestsDappRadarApprovalStatus <QuestsDappRadar Address> in TokenHolder
    
  8. setNewAdmin:

    setNewAdmin <Our signer wallet> in QuestsDappRadar
    
  9. Transfer ownerships if needed

  10. If you wish to deploy ERC20, update this line with your wallet address: Update this line

  11. Deploy the ERC20 contract:

    npx hardhat run scripts/deployErc20.js --network polygon
    
  12. Verify the ERC20:

    npx hardhat verify --network polygon <contract address> Test TEST <mint tokens to this address> <mint token amount with decimals>
    

Usage

To use the AssetsHolder contract, you first need to deploy it. You can use the provided deployment script deployTokenHolder.js to do this.

After deployment, you can call the following functions:

  • transferERC20(address tokenAddress, uint256 amount, address recipient): Transfers the specified amount of an ERC20 token to the recipient.
  • transferERC721(address tokenAddress, uint256 tokenId, address recipient): Transfers an ERC721 token with the specified ID to the recipient.
  • transferERC1155(address tokenAddress, uint256 id, uint256 amount, address recipient, bytes calldata data): Transfers the specified amount of an ERC1155 token with the given ID to the recipient. QuestsDappRadar

The QuestsDappRadar contract is used to manage quests and rewards. It interacts with the AssetsHolder contract to distribute rewards.

To use the QuestsDappRadar contract, you first need to deploy it. During deployment, you need to pass the address of the AssetsHolder contract to the constructor.

After deployment, you can call the following functions:

  • createQuest(uint256 questId, address[] memory erc20Rewards, address[] memory erc721Rewards, address[] memory erc1155Rewards): Creates a new quest with the specified rewards.
  • setWinnerReward(uint256 questId, address winner, ERC20TokenInfo[] memory erc20Rewards, ERC721TokenInfo[] memory erc721Rewards, ERC1155TokenInfo[] memory erc1155Rewards): Sets the rewards for a winner of a quest.
  • claimReward(uint256 questId): Allows a winner to claim their rewards.

Please note that the claimReward function should be called by the winner of the quest.

Contracts