pragma solidity ^0.7.1; import "https://github.com/AVAXFoundation/Ava.sol"; // This is the contract for the CCPR token // Define the contract interface interface Token { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function stake(uint256 value) external returns (bool); function swap(uint256 value) external returns (bool); function burn(uint256 value) external returns (bool); } // Define the contract contract CCPR is Token { // Set the initial values for the token string public name = "Cannacoin Prime"; string public symbol = "CCPR"; uint8 public decimals = 18; // This sets the number of decimal places to 18 uint256 public totalSupply = 31415926535897932384626433832795028841; // This sets the total supply to 31415926535897932384626433832795028841 uint public initialValue = 0; // This sets the initial value to zero // Set up the mapping for the token balances mapping(address => uint256) public balances; // Set the owner of the contract to the contract creator address public owner; // Constructor function to set the owner of the contract constructor() public { owner = msg.sender; } // Function to get the name of the token function name() public view returns (string memory) { return name; } // Function to get the symbol of the token function symbol() public view returns (string memory) { return symbol; } // Function to get the number of decimal places for the token function decimals() public view returns (uint8) { return decimals; } // Function to get the total supply of the token function totalSupply() public view returns (uint256) { return totalSupply; } // Function to get the balance of a specific address function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } // Function to transfer tokens from one address to another function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value && _value > 0, "Insufficient balance"); balances[msg.sender] -= _value; balances[_to] += _value; return true; } // Function to stake tokens for a 33% reward function stake(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value && value > 0, "Insufficient balance"); uint256 reward = value * 33 / 100; balances[msg.sender] -= value; balances[msg.sender] += reward; return true; } // Function to swap tokens for USDC on the Pangolin DEX function swap(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value && value > 0, "Insufficient balance"); // Call the Pangolin DEX contract to swap tokens for USDC bool result = PangolinDEX.swap(value, CCPR, USDC); if (result) { balances[msg.sender] -= value; return true; } else { return false; } } // Function to burn tokens function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value && value > 0, "Insufficient balance"); balances[msg.sender] -= value; totalSupply -= value; return true; } }
0.7.1