1

完整来源:https ://github.com/laronlineworld/NewToken/blob/main/NewToken.sol 该代币仅在dex上销售时扣除税款,税款到特定地址,转账不收取任何费用。

转账时如何加手续费?费用将转到特定地址。

总结:代币经济学将是 BUY:0% SELL:5% TRANSFER OF TOKEN:5%。这可能吗?

 /**
 * @dev Moves `amount` of tokens from `sender` to `recipient`.
 *
 * This internal function is equivalent to {transfer}, and can be used to
 * e.g. implement automatic token fees, slashing mechanisms, etc.
 *
 * Emits a {Transfer} event.
 *
 * Requirements:
 *
 * - `sender` cannot be the zero address.
 * - `recipient` cannot be the zero address.
 * - `sender` must have a balance of at least `amount`.
 */
function _transfer(
    address sender,
    address recipient,
    uint256 amount
) internal virtual {
    require(sender != address(0), "ERC20: transfer from the zero address");
    require(recipient != address(0), "ERC20: transfer to the zero address");

    uint256 senderBalance = _balances[sender];
    require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");

    unchecked {
        _balances[sender] = senderBalance.sub(amount);
    }
    
    bool takeFee = true;
    if (_isExcludedFromFee[sender]) {
        takeFee = false;
    }
    
    if(recipient==pairAddress&&takeFee){
        uint256 taxFee = amount.mul(dexTaxFee).div(10000);
        _balances[taxAddress] = _balances[taxAddress].add(taxFee);
        emit Transfer(sender, taxAddress, taxFee);
        amount = amount.sub(taxFee);
    }
    
    _balances[recipient] = _balances[recipient].add(amount);
    emit Transfer(sender, recipient, amount);
}
4

0 回答 0