1

I am working on uniswap router contract for _addLiquadity and there uniswap used uniswapV2library and into that library this below function is return the pair address but i dont understand what first hex'ff' using for?

function pairFor(address factory, address tokenA, address tokenB) public view returns (address pair) {
        (address token0, address token1) = sortToken(tokenA, tokenB);
        pair = address(uint(keccak256(abi.encodePacked(
                hex'ff',
                factory,
                keccak256(abi.encodePacked(token0, token1)),
                hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // This is a Bytecode of UniswapV2pair.sol
            ))));
    }
Ismael
  • 30,570
  • 21
  • 53
  • 96
  • 1
    That's the address formula for contracts created with CREATE2 opcode, https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed. The prefix 'ff' is used to avoid collision with the old formula for contracts. – Ismael Dec 30 '21 at 07:09

0 Answers0