title: Compute pancake pair address via python3
body: <p>This question is quite related to <a href="https://stackoverflow.com/questions/66710238/compute-uniswap-pair-address-via-python/67156507#67156507">Compute uniswap pair address via python</a></p>
  <p>I am trying to do the same but for panckage swap v2.</p>
  <p>I am using the CAKE/WBNB pair as an example:</p>
  <pre><code>CONTRACTS = {
      &quot;CAKE&quot;: &quot;0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82&quot;,
  }
  
  PANCAKE_SWAP_FACTORY = &quot;0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73&quot;
  PANCAKE_SWAP_ROUTER  = &quot;0x10ED43C718714eb63d5aA57B78B54704E256024E&quot;
  
  WBNB_ADDRESS = &quot;0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c&quot;
  
  hexadem_ ='0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5'
  factory = PANCAKE_SWAP_FACTORY
  abiEncoded_1 = encode_abi_packed(['address', 'address'], (CONTRACTS['CAKE'], WBNB_ADDRESS))
  salt_ = pancakeswap.w3.solidityKeccak(['bytes'], ['0x' +abiEncoded_1.hex()])
  abiEncoded_2 = encode_abi_packed([ 'address', 'bytes32'], ( factory, salt_))
  
  resPair = pancakeswap.w3.solidityKeccak(['bytes','bytes'], ['0xff' + abiEncoded_2.hex(), hexadem_])[12:]
  
  # resPair is the address for the pancakeswap CAKE/WBNB pair
  print(resPair.hex())
  print('0xA527a61703D82139F8a06Bc30097cC9CAA2df5A6')
  print(resPair.hex() == '0xA527a61703D82139F8a06Bc30097cC9CAA2df5A6')
  print()
  </code></pre>
  <p>My first problem is the code is not working, it is not producint the correct contract address, in fact it prints:</p>
  <pre><code>0x0ed7e52944161450477ee417de9cd3a859b14fd0
  0xA527a61703D82139F8a06Bc30097cC9CAA2df5A6
  False
  </code></pre>
  <p>I think the problem is the value of the constant hexadem_, which can be found in:</p>
  <ul>
  <li>hexadem_ = '0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66' # from <a href="https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/libraries/PancakeLibrary.sol" rel="nofollow noreferrer">https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/libraries/PancakeLibrary.sol</a></li>
  <li>hexadem_ ='0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' # from uniswap (most likely wrong...)</li>
  <li>hexadem_ ='0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5' # from <a href="https://bscscan.com/address/0x10ED43C718714eb63d5aA57B78B54704E256024E#code" rel="nofollow noreferrer">https://bscscan.com/address/0x10ED43C718714eb63d5aA57B78B54704E256024E#code</a> line 298</li>
  </ul>