Как добавить налог на транзакцию в мой смарт-контракт (Bep20)

Я хочу добавить функцию налога на транзакцию, которая взимает 2,5% от суммы отправителя, которая будет отправлена ​​на адрес кошелька владельца. Как мне подойти к этой функции. Спасибо.

прагма солидность ^0.8.2; контракт Token {

      mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance
uint public totalSupply = 1,000,000,000,000 * 10 ** 18;  // Total supply and the smallest denomination
string public name = "My Token"; // Name of Token
string public = "TKN";  //Token Symbol  
uint public decimal = 18; // Denoting smallest denomination and the number of decimals.(8 or 18)

event Transfer(address indexed from , address indexed to ,uint value);

constructor(){
    balances[msg.sender] = totalSupply;
    
}
//All the function names are required by the Bep20 standard
function balanceOf(address owner) public view returns(uint){
    return balanceOf[owner];
    
}

function tranfser(address to , uint value) public returns(bool)
    require(balanceOf(msg.sender) >= value, 'balance is insufficient for transfer');
    balances[to] += value;
    balances[msg.sender] -= value;
    emit Transfer(msg.sender, to , value);
    return true;
    
    
    )
function transferFrom(address from, address to ,uint value) public returns(bool){
    require (balanceOf(from) >= value, "balance is insufficient for transfer");
    require(allowance(from)[msg.sender] >= 'value',"allowance too low ")  ;
    balances[to] += value;
    balances[from] -= value;
    emit Transfer(from, to, value);
    return True;
    
}        
    
function approve(address spender, uint value) public returns(bool){
    allowance[msg.sender][spender] = value;
    emit Approval(msg.sender,spender,value);
    return true;
    
}        

}

0 ответов

Другие вопросы по тегам