0

I'm trying to understand what this lines of BEP20 code mean, it is written in 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);
TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

In the first lines, he instanciate UniswapV2Router pointing the address router to 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().

IMPORTANT: WETH() is a function that provider the chain native wrapped coin address where smart contract was deployed. 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. 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.

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.

Finally he emitted a Transfer event passing : address(0) (0x0000000000000000000000000000000000000000), owner() and total supply.

More information about pair on documentation.

Antonio Carito
  • 1,287
  • 1
  • 5
  • 10
  • Thanks for the info! About the address in line 3 "0x10ED43C718714eb63d5aA57B78B54704E256024E" What action will actually happen on the address! – Anyanwu Ozioma Jun 02 '22 at 14:38
  • Initializes a pointer to the 0x10ED43C718714eb63d5aA57B78B54704E256024E address and in this way his smart contract (if implements IUniswapRouterV2 interface) through _uniswapV2Router variable can use its methods and variables (if public). – Antonio Carito Jun 02 '22 at 15:17