Skip to content

Instantly share code, notes, and snippets.

@TanjinAlam
Created August 21, 2022 10:42
Show Gist options
  • Save TanjinAlam/6da6a08e6de6bc249eb5919171a99869 to your computer and use it in GitHub Desktop.
Save TanjinAlam/6da6a08e6de6bc249eb5919171a99869 to your computer and use it in GitHub Desktop.
Steezy Token
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract Steezy is ERC20 {
using SafeMath for uint256;
address public owner;
mapping(address => bool) public whitelistedAddresses;
address public developerWallet = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
address public marketingWallet = 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db;
uint256 private developerWalletTex = 19; //default tax for developer wallet
uint256 private marketingWalletTex = 3; // default tx for marketing wallet
event Bought(uint256 amount, address buyerAddress);
event Sold(uint256 amount, address receivedAddress);
// set the tax for developer
function setPercentageDeveloper(uint256 _developerWalletTex) public onlyOwner {
developerWalletTex = _developerWalletTex;
}
// set the tax for marketing
function setPercentageMarketing(uint256 _marketingWalletTex) public onlyOwner {
marketingWalletTex = _marketingWalletTex;
}
// calculate the tax for marketing
function percentageForMarketing(uint256 amount) internal view returns(uint percent){
if(marketingWalletTex < 10) {
return amount.mul(marketingWalletTex).div(100);
} else if ( marketingWalletTex < 100 ) {
return amount.mul(marketingWalletTex).div(1000);
} else if ( marketingWalletTex < 1000) {
return amount.mul(marketingWalletTex).div(10000);
}
}
// calculate the tax for developer
function percentageForDeveloper(uint256 amount) internal view returns(uint percent){
if(developerWalletTex < 10) {
return amount.mul(developerWalletTex).div(100);
} else if ( developerWalletTex < 100 ) {
return amount.mul(developerWalletTex).div(1000);
} else if ( developerWalletTex < 1000) {
return amount.mul(developerWalletTex).div(10000);
}
}
/// @notice Official record of token balances for each account
// mapping (address => uint) public _balances;
constructor(address _owner) ERC20("Steezy", "STZY") {
_mint(address(this), 100000000 * 10 ** decimals());
owner = _owner;
}
modifier onlyOwner() {
require(msg.sender == owner, "Ownable: caller is not the owner");
_;
}
//add user to whitelist
function addUserToWhiteList(address _addressToWhitelist) public onlyOwner {
whitelistedAddresses[_addressToWhitelist] = true;
}
//remove user to whitelist
function removeUserToWhiteList(address _addressToWhitelist) public onlyOwner {
whitelistedAddresses[_addressToWhitelist] = false;
}
function purchase(uint256 amount, address to) payable public onlyOwner {
require(amount <= 2000000, "exceding maximum purchase amount");
if(whitelistedAddresses[to]){
_transfer(address(this),to,amount);
} else {
uint256 calculateTaxForDeveloper = percentageForDeveloper(amount);
uint256 calculateTaxForMarketing = percentageForMarketing(amount);
uint256 amountExcludingTx = amount.sub((calculateTaxForDeveloper.add(calculateTaxForMarketing)));
_transfer(address(this),to,amountExcludingTx);
// send the tax calculated token to the fix address
//_transfer(msg.sender,developerWallet,calculateTaxForDeveloper);
//_transfer(msg.sender,marketingWallet,calculateTaxForMarketing);
}
}
function sell(uint256 amount, address to) payable public onlyOwner {
require(amount <= 2000000, "exceding maximum sell amount");
if(whitelistedAddresses[to]){
_transfer(msg.sender,address(this),amount);
} else {
uint256 calculateTaxForDeveloper = percentageForDeveloper(amount);
uint256 calculateTaxForMarketing = percentageForMarketing(amount);
uint256 amountExcludingTx = amount.sub((calculateTaxForDeveloper.add(calculateTaxForMarketing)));
_transfer(msg.sender,address(this),amountExcludingTx);
// send the tax calculated token to the fix address
//_transfer(msg.sender,developerWallet,calculateTaxForDeveloper);
//_transfer(msg.sender,marketingWallet,calculateTaxForMarketing);
}
}
//change admin
function setAdmin(address admin_) internal onlyOwner {
owner = admin_;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment