料金は、transacciを無視します.


Nuna Manera de mantener con oxは、o o o iosistate esの間のニュアンスをトークン化します.エロスcomisiは、pupude ir a una billeteraデロスcreadores o a una una - vedaです.P . A . Harramientas必需品Hacerloとしてのopenzeppelin nosダンとしての.エヌエステビデオ探検家Diferentes ForloasデLograrlo、パラAmbos Principiantes y avanzados.

依存関係


パラエステチュートリアルOcuparは、24679152コンFondosデRrinkeby Testnet que Puedes Conseguir desde EL Metamaskです.Tambiは、Necesitarは、コンツェルチュTuをFaucet y Conseguir Matic Desde Alg Exchangeと交換します.

ポリゴンメインネット 1 .手数料フィヨンポラシ


ロスコントラクトのEDC - 20デOpenzeppelin指数関数の関数を使用します.
// SPDX-License-Identifier: MIT

pragma solidity 0.8.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20
{    
    address public vault_address;
    uint public fee;

    bool private is_in_fee_transfer;

    constructor () ERC20("My Token", "TKN")
    {
        // Edit here
        vault_address = 0xb6F5414bAb8d5ad8F33E37591C02f7284E974FcB;
        fee = 1 ether;
        _mint(msg.sender, 1_000_000 ether);
        // End edit
    }

    function _afterTokenTransfer(
        address from,
        address to,
        uint amount
    ) internal virtual override(ERC20)
    {
        require(amount >= fee, "Amount must be greater than fee");
        super._afterTokenTransfer(from, to, amount);

        if(!is_in_fee_transfer)
        {
            is_in_fee_transfer = true;
            _transfer(to, vault_address, fee);
            is_in_fee_transfer = false;
        }
    }
}

第2回エド・アヴァンザドdeカプチュラ料金

  • は、Useda delルータデUniswap Podemos Capturar国連Porcentaje Diferenteデ料金エヌCocoデBuy、Y P P Pを売っています:compra、venta y transacci
  • エスタヴェズcapturamos国連ポルセンタジデラタンサッシーデn ' n no valvalfijo
  • のアデレードs agragamosは、オペレレスcomo課税のない、exemptosデ料金
  • に対処します
    Reddida Ajustar la Direcci and n del Router依存性ネットワーク
  • ポリゴンのクイックスワップ
  • Ethereum Uniswap V 2:_afterTokenTransfer
  • BSCメインネットパンケーキ:0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff
  • BSCテストネットパンケーキ:0x10ED43C718714eb63d5aA57B78B54704E256024E
  • // SPDX-License-Identifier: MIT
    
    pragma solidity 0.8.12;
    
    import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
    
    interface IUniswapV2Factory {
        function createPair(address tokenA, address tokenB) external returns (address pair);
    }
    
    interface IUniswapV2Router02 {
        function factory() external pure returns (address);
        function WETH() external pure returns (address);
    }
    
    contract MyToken is ERC20
    {    
        address public vault_address;
    
        address public pair;
    
        uint public fee_decimal = 2;
        enum FeesIndex{ BUY, SELL, P2P }
        uint[] public fee_percentages;
    
        mapping(address => bool) public is_taxless;
    
        bool private is_in_fee_transfer;
    
        constructor () ERC20("My Token", "TKN")
        {
            IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
            pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
    
            // Edit here
            vault_address = 0xb6F5414bAb8d5ad8F33E37591C02f7284E974FcB;
    
            fee_percentages.push(1000); // Buy  fee is 10.00%
            fee_percentages.push(1500); // Sell fee is 15.00%
            fee_percentages.push(500);  // Buy  fee is  5.00%
    
            _mint(msg.sender, 1_000_000 ether);
            // End edit
    
            is_taxless[msg.sender] = true;
            is_taxless[vault_address] = true;
            is_taxless[address(this)] = true;
            is_taxless[address(0)] = true;
        }
    
        function _afterTokenTransfer(
            address from,
            address to,
            uint amount
        ) internal virtual override(ERC20)
        {
            super._afterTokenTransfer(from, to, amount);
    
            if(!is_in_fee_transfer)
            {
                uint fees_collected;
                if (!is_taxless[from] && !is_taxless[to]) {
                    bool sell = to == pair;
                    bool p2p = from != pair && to != pair;
    
                    uint fee = calculateFee(p2p ? FeesIndex.P2P : sell ? FeesIndex.SELL : FeesIndex.BUY, amount);
    
                    fees_collected += fee;
                }
    
                if(fees_collected > 0)
                {
                    is_in_fee_transfer = true;
                    _transfer(to, vault_address, fees_collected);
                    is_in_fee_transfer = false;
                }
            }
        }
    
        function calculateFee(FeesIndex fee_index, uint amount) internal view returns(uint) {
            return (amount * fee_percentages[uint(fee_index)])  / (10**(fee_decimal + 2));
        }
    }
    

    <研究ノート>トド・アヴァンザドM .

  • Funciones編集表0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
  • スプリットド手数料は、diferentes billeteras
  • // SPDX-License-Identifier: MIT
    
    pragma solidity 0.8.12;
    
    import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
    import "@openzeppelin/contracts/access/Ownable.sol";
    
    interface IUniswapV2Factory {
        function createPair(address tokenA, address tokenB) external returns (address pair);
    }
    
    interface IUniswapV2Router02 {
        function factory() external pure returns (address);
        function WETH() external pure returns (address);
    }
    
    contract MyToken is ERC20, Ownable
    {
        uint internal wallet_a_collected;
        uint internal wallet_b_collected;
    
        address public wallet_a;
        address public wallet_b;
    
        address public pair;
    
        enum FeesIndex{ BUY, SELL, P2P }
        uint[] public wallet_a_fee_percentages;
        uint[] public wallet_b_fee_percentages;
        uint public fee_decimal = 2;
    
        mapping(address => bool) public is_taxless;
    
        bool private is_in_fee_transfer;
    
        constructor () ERC20("My Token", "TKN")
        {
            IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
            pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
    
            // Edit here
            wallet_a = 0xb6F5414bAb8d5ad8F33E37591C02f7284E974FcB;
            wallet_a = 0xb6F5414bAb8d5ad8F33E37591C02f7284E974FcB;
    
            wallet_a_fee_percentages.push(500); // Buy  fee is 5.00%
            wallet_a_fee_percentages.push(500); // Sell fee is 5.00%
            wallet_a_fee_percentages.push(500);  // Buy  fee is  5.00%
    
            wallet_b_fee_percentages.push(1000); // Buy  fee is 10.00%
            wallet_b_fee_percentages.push(1500); // Sell fee is 15.00%
            wallet_b_fee_percentages.push(500);  // Buy  fee is  5.00%
    
            _mint(msg.sender, 1_000_000 ether);
            // End edit
    
            is_taxless[msg.sender] = true;
            is_taxless[wallet_a] = true;
            is_taxless[wallet_b] = true;
            is_taxless[address(this)] = true;
            is_taxless[address(0)] = true;
        }
    
        function _afterTokenTransfer(
            address from,
            address to,
            uint amount
        ) internal virtual override(ERC20)
        {
            super._afterTokenTransfer(from, to, amount);
    
            if(!is_in_fee_transfer)
            {
                uint fees_collected;
                if (!is_taxless[from] && !is_taxless[to]) {
                    uint wallet_a_fee;
                    uint wallet_b_fee;
    
                    bool sell = to == pair;
                    bool p2p = from != pair && to != pair;
                    (wallet_a_fee, wallet_b_fee) = calculateFee(p2p ? FeesIndex.P2P : sell ? FeesIndex.SELL : FeesIndex.BUY, amount);
    
                    wallet_a_collected += wallet_a_fee;
                    wallet_b_collected += wallet_b_fee;
                    fees_collected += wallet_a_fee + wallet_b_fee;
                }
    
                if(fees_collected > 0)
                {
                    is_in_fee_transfer = true;
                    _transfer(to, address(this), fees_collected);
                    is_in_fee_transfer = false;
                }
            }
        }
    
        function calculateFee(FeesIndex fee_index, uint amount) internal view returns(uint, uint) {
            uint wallet_a_fee = (amount * wallet_a_fee_percentages[uint(fee_index)])  / (10**(fee_decimal + 2));
            uint wallet_b_fee = (amount * wallet_b_fee_percentages[uint(fee_index)])  / (10**(fee_decimal + 2));
            return (wallet_a_fee, wallet_b_fee);
        }
    
        // Owner admin functions
    
        function setWalletA(address wallet)  external onlyOwner {
            wallet_a = wallet;
        }
    
        function setWalletB(address wallet)  external onlyOwner {
            wallet_b = wallet;
        }
    
        function setWalletAFee(uint buy, uint sell, uint p2p) external onlyOwner {
            wallet_a_fee_percentages[0] = buy;
            wallet_a_fee_percentages[1] = sell;
            wallet_a_fee_percentages[2] = p2p;
        }
    
        function setWalletBFee(uint buy, uint sell, uint p2p) external onlyOwner {
            wallet_b_fee_percentages[0] = buy;
            wallet_b_fee_percentages[1] = sell;
            wallet_b_fee_percentages[2] = p2p;
        }
    
        function setIsTaxless(address _address, bool value) external onlyOwner {
            is_taxless[_address] = value;
        }
    
        // Fee collector functions
    
        function collectWalletAFee() external {
            require(msg.sender == wallet_a, "Sender must be buy address");
            wallet_a_collected = 0;
            transfer(wallet_a, wallet_a_collected);
        }
    
        function collectWalletBFee() external {
            require(msg.sender == wallet_b, "Sender must be buy address");
            wallet_b_collected = 0;
            transfer(wallet_b, wallet_b_collected);
        }
    }
    
    サラグラシアスpor ver esteチュートリアル!
    O . P .に対するGeme Een Devy .