This repository contains the source code for the Degen Gaming ERC-20 token, deployed on the Avalanche network. The Degen token is designed to facilitate a reward system within the Degen Gaming platform, allowing players to earn, transfer, redeem, and burn tokens.
The owner of the contract can mint new tokens, which are then distributed as rewards to players.
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
Players can transfer their tokens to other addresses using the transferTokens function.
function transferTokens(address _receiver, uint _value) external {
require(balanceOf(msg.sender) >= _value, "You do not have enough Degen Tokens");
approve(msg.sender, _value);
transferFrom(msg.sender, _receiver, _value);
}
Players can redeem their tokens for in-game items by calling the redeemTokens function.
function redeemTokens(uint256 option) public {
require(option >= 1 && option <= 4, "Invalid option");
uint256 redeemAmount = calculateRedemptionAmount(option);
require(balanceOf(msg.sender) >= redeemAmount, "Insufficient Degen Tokens");
address store = 0x5723fea1DDC24609F0150Ff0C0B96Af77ceF0753;
_transfer(msg.sender, store, redeemAmount);
emit Redeem(msg.sender, redeemAmount, option);
// console.log("Redemption successful. Option: %s, Amount: %s", option, redeemAmount);
}
Players can check their token balance at any time by calling the getBalance function.
function getBalance() external view returns (uint256){
return this.balanceOf(msg.sender);
}
Anyone can burn tokens that they own but no longer need, using the burnTokens function.
function burnTokens(uint256 _value) public payable {
require(balanceOf(msg.sender) >= _value, "You do not have enough Degen Tokens");
approve(msg.sender, _value);
burnFrom(msg.sender, _value);
}
- Computer
- NodeJS
- Hardhat
- Solidity
- Avalanche Fuji Testnet
- Snowtrace
- Clone this repository by using the git clone command
git clone
- In your project folder run
npm init
npm init -y
- Install Hardhat
npm install --save-dev hardhat
- Install openZeppelin to enable smart contract library for contracts development
npm install @openzeppelin/contracts
- Any modifications needed to be made to files/folders
- Run to deploy your contract
$ npx hardhat run scripts/deploy.js --network fuji
For help check [Guide.md] for detailed instructions
Jeremiah Samuel [email protected]
This project is licensed under the MIT License.