简体   繁体   English

这段代码在使用 Solidity 编写 BEP20 令牌中意味着什么

[英]What Does this code mean in BEP20 token writting with Solidity

I'm trying to understand what this lines of BEP20 code mean, it is written in solidity我试图理解这行 BEP20 代码的含义,它是用solidity编写的

constructor () {
    _rOwned[owner()] = _rTotal;
    IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);
    uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
        .createPair(address(this), _uniswapV2Router.WETH());
    uniswapV2Router = _uniswapV2Router;
    _isExcludedFromFee[owner()] = true;
    _isExcludedFromFee[address(this)] = true;
    emit Transfer(address(0), owner(), _tTotal);

In the first lines, he instanciate UniswapV2Router pointing the address router to PancakeSwap.在第一行中,他实例化了 UniswapV2Router,将地址路由器指向 PancakeSwap。 This because, he want to create a liquidity pool with his TOKEN and BNB, indeed after this instanciating operation he call createPair() that allows him to create this pair between his smart contract and the address WETH().这是因为,他想用他的 TOKEN 和 BNB 创建一个流动性池,实际上在这个实例化操作之后,他调用createPair() ,允许他在他的智能合约和地址 WETH() 之间创建这个对。

IMPORTANT: WETH() is a function that provider the chain native wrapped coin address where smart contract was deployed.重要提示: WETH() 是一个函数,它提供部署智能合约的链原生包裹的硬币地址。 For example: If I create a pair instanciating Uniswap router on Ethereum blockchain then WETH() will return address about WETH (Wrapping Ether) address present into Etheruem.例如:如果我在以太坊区块链上创建了一对实例化 Uniswap 路由器,那么 WETH() 将返回关于存在于 Etheruem 中的WETH (Wrapping Ether)地址的地址。 On the contrary if I instanciate Uniswap Router with its address present into binance smart chain (and so I refers to Pancakeswap in this case), the value of WETH() will be WBNB address.相反,如果我将 Uniswap 路由器的地址存在于币安智能链中(因此在这种情况下我指的是 Pancakeswap),WETH() 的值将是WBNB地址。

After this lines of code, I assume that he excluded from paying a fee for only transactions the owner() address (who deployed the smart contract for the first time) and smart contract itself.在这行代码之后,我假设他只为owner()地址(首次部署智能合约)和智能合约本身的交易支付费用。

Finally he emitted a Transfer event passing : address(0) (0x0000000000000000000000000000000000000000), owner() and total supply .最后他发出了一个 Transfer 事件,传递: address(0) (0x0000000000000000000000000000000000000000), owner()total supply

More information about pair on documentation .有关文档对的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM