1. <legend id='fEMSx'><style id='fEMSx'><dir id='fEMSx'><q id='fEMSx'></q></dir></style></legend>
        <bdo id='fEMSx'></bdo><ul id='fEMSx'></ul>

      <i id='fEMSx'><tr id='fEMSx'><dt id='fEMSx'><q id='fEMSx'><span id='fEMSx'><b id='fEMSx'><form id='fEMSx'><ins id='fEMSx'></ins><ul id='fEMSx'></ul><sub id='fEMSx'></sub></form><legend id='fEMSx'></legend><bdo id='fEMSx'><pre id='fEMSx'><center id='fEMSx'></center></pre></bdo></b><th id='fEMSx'></th></span></q></dt></tr></i><div id='fEMSx'><tfoot id='fEMSx'></tfoot><dl id='fEMSx'><fieldset id='fEMSx'></fieldset></dl></div>
    2. <tfoot id='fEMSx'></tfoot>

      <small id='fEMSx'></small><noframes id='fEMSx'>

      通过python计算uniswap对地址

      Compute uniswap pair address via python(通过python计算uniswap对地址)
      • <tfoot id='t6Y49'></tfoot>
          <bdo id='t6Y49'></bdo><ul id='t6Y49'></ul>
        • <i id='t6Y49'><tr id='t6Y49'><dt id='t6Y49'><q id='t6Y49'><span id='t6Y49'><b id='t6Y49'><form id='t6Y49'><ins id='t6Y49'></ins><ul id='t6Y49'></ul><sub id='t6Y49'></sub></form><legend id='t6Y49'></legend><bdo id='t6Y49'><pre id='t6Y49'><center id='t6Y49'></center></pre></bdo></b><th id='t6Y49'></th></span></q></dt></tr></i><div id='t6Y49'><tfoot id='t6Y49'></tfoot><dl id='t6Y49'><fieldset id='t6Y49'></fieldset></dl></div>

              <tbody id='t6Y49'></tbody>
            <legend id='t6Y49'><style id='t6Y49'><dir id='t6Y49'><q id='t6Y49'></q></dir></style></legend>

              <small id='t6Y49'></small><noframes id='t6Y49'>

                本文介绍了通过python计算uniswap对地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正试图计算(脱机,即没有HTTP请求)Uniswap对的地址, 使用python、web3和eth-abi库,基于this坚固性 示例。

                address factory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
                address token0 = 0xCAFE000000000000000000000000000000000000; // change me!
                address token1 = 0xF00D000000000000000000000000000000000000; // change me!
                
                address pair = address(uint(keccak256(abi.encodePacked(
                  hex'ff',
                  factory,
                  keccak256(abi.encodePacked(token0, token1)),
                  hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
                ))));
                

                有一些想法:

                hexadem_ ='0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
                hexadem_1 = 0xff
                abiEncoded_1 = encode_abi_packed(['address', 'address'], (  token_0, token_1 ))
                salt_ = web3.Web3.solidityKeccak(['bytes'], ['0x' +abiEncoded_1.hex()])
                abiEncoded_2 = encode_abi_packed(['bytes', 'address', 'bytes32'], (bytes(hexadem_1), factory, salt_))
                resPair = web3.Web3.solidityKeccak(['bytes','bytes'], ['0x' +abiEncoded_2.hex(), hexadem_])
                

                能不能有人给我提个建议,哪里不对,应该怎么考虑?

                推荐答案

                首先,resPair太长,不能作为合同地址。 规则可以通过阅读以下内容来解释:https://eips.ethereum.org/EIPS/eip-1014

                还请确保按字母顺序输入这两个地址。请使用.ort()函数执行此操作。

                以下是正确的代码:

                hexadem_ ='0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
                hexadem_1 = 0xff
                factory = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f' 
                abiEncoded_1 = encode_abi_packed(['address', 'address'], ('0x7825e833d495f3d1c28872415a4aee339d26ac88', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' )) #these two addresses to be changed as fit. Currently they are TLOS and WETH
                salt_ = w3.solidityKeccak(['bytes'], ['0x' +abiEncoded_1.hex()])
                abiEncoded_2 = encode_abi_packed([ 'address', 'bytes32'], ( factory, salt_))
                resPair = w3.solidityKeccak(['bytes','bytes'], ['0xff' + abiEncoded_2.hex(), hexadem_])[12:]
                resPair
                

                希望这对您有帮助!我发现这是一个有趣的挑战:)

                这篇关于通过python计算uniswap对地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                <tfoot id='tdrhK'></tfoot>

              1. <legend id='tdrhK'><style id='tdrhK'><dir id='tdrhK'><q id='tdrhK'></q></dir></style></legend>
                  <tbody id='tdrhK'></tbody>
                1. <small id='tdrhK'></small><noframes id='tdrhK'>

                2. <i id='tdrhK'><tr id='tdrhK'><dt id='tdrhK'><q id='tdrhK'><span id='tdrhK'><b id='tdrhK'><form id='tdrhK'><ins id='tdrhK'></ins><ul id='tdrhK'></ul><sub id='tdrhK'></sub></form><legend id='tdrhK'></legend><bdo id='tdrhK'><pre id='tdrhK'><center id='tdrhK'></center></pre></bdo></b><th id='tdrhK'></th></span></q></dt></tr></i><div id='tdrhK'><tfoot id='tdrhK'></tfoot><dl id='tdrhK'><fieldset id='tdrhK'></fieldset></dl></div>

                        • <bdo id='tdrhK'></bdo><ul id='tdrhK'></ul>