Created
August 8, 2021 17:15
-
-
Save Turupawn/37c90a5ff41ad18ce20359862d6ade00 to your computer and use it in GitHub Desktop.
Comisiones porcentuales
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.6; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/token/ERC20/ERC20.sol"; | |
contract MyERC20 is ERC20 { | |
string TOKEN_NAME = "Token"; | |
string TOKEN_SYMBOL = "TKN"; | |
uint256 TOTAL_SUPPLY = 21000000 ether; | |
address LIQUIDITY_ADDRESS = 0x0000000000000000000000000000000000000000; | |
address MARKETING_ADDRESS = 0x0000000000000000000000000000000000000000; | |
uint256 LIQUIDITY_TX_PERCENTAGE_FEE = 700; // 700 = 7,00% | |
uint256 MARKETING_TX_PERCENTAGE_FEE = 500; // 500 = 5,00% | |
constructor () ERC20(TOKEN_NAME, TOKEN_SYMBOL) { | |
_mint(msg.sender, TOTAL_SUPPLY); | |
} | |
function getPercentage(uint256 number, uint256 percentage) internal pure returns(uint256 result) | |
{ | |
return number * percentage / 10000; | |
} | |
function _afterTokenTransfer(address from, address to, uint256 amount) internal override | |
{ | |
if(from != address(0) && to != address(0)) | |
{ | |
uint256 liquidity_amount = getPercentage(amount, LIQUIDITY_TX_PERCENTAGE_FEE); | |
uint256 marketing_amount = getPercentage(amount, MARKETING_TX_PERCENTAGE_FEE); | |
_mint(LIQUIDITY_ADDRESS, liquidity_amount); | |
_mint(MARKETING_ADDRESS, marketing_amount); | |
_burn(to, liquidity_amount); | |
_burn(to, marketing_amount); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment