调用还原异常代码:"CALL_EXCEPTION",方法:"token0()",



我试图在UniSwap交易所列出加密货币,但我收到一个错误。我将poolAddress作为UniSwap中的Goerli默认地址,而address是创建令牌的地址。这是我的错误:

Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="token0()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
    at Logger.makeError (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectloggerlibindex.js:238:21)
    at Logger.throwError (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectloggerlibindex.js:247:20)
    at Interface.decodeFunctionResult (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectabilibinterface.js:388:23)
    at Contract.<anonymous> (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectcontractslibindex.js:395:56)
    at step (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectcontractslibindex.js:48:23)
    at Object.next (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectcontractslibindex.js:29:53)
    at fulfilled (C:UsersdumitOneDriveDesktopCryptoSmartHack2022soliditynode_modules@ethersprojectcontractslibindex.js:20:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: null,
  code: 'CALL_EXCEPTION',
  method: 'token0()',
  data: '0x',
  errorArgs: null,
  errorName: null,
  errorSignature: null,
  address: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6',
  args: [],
  transaction: {
    data: '0x0dfe1681',
    to: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6'
  }
}

这是我创建令牌(并将其发送到一个帐户)的代码:

createToken(BigInt(supply), nume, simbol, BigInt(decimals))
       .catch(error => {
         console.error(error);
       });
    async function createToken(supply, tokenName, symbol, decimals)
    {
      const myToken = await ethers.getContractFactory("token"); 
      // Start deployment, returning a promise that resolves to a contract object
      const my_token = await myToken.deploy(supply, tokenName, symbol, decimals);
      console.log("Contract deployed to address:", my_token.address);
      await my_token.transfer(address, supply)
      console.log("sent to " + address)
    
      res.send(my_token.address)
    
      listToken(address, tokenName, symbol, decimals).catch(error => {
        console.error(error);
      });
    }

下面是.ts文件生成的用于列出它的函数:

async function main() {
    return __awaiter(this, void 0, void 0, function () {
        var _a, immutables, state, TokenA, TokenB, poolExample;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0: return [4 /*yield*/, Promise.all([getPoolImmutables(), getPoolState()])];
                case 1:
                    _a = _b.sent(), immutables = _a[0], state = _a[1];
                    TokenA = new Token(address, immutables.token0, decimals, symbol, tokenName);
                    TokenB = new Token(poolAddress, immutables.token1, 18, 'WETH', 'Wrapped Ether');
                    poolExample = new Pool(TokenB, TokenA, immutables.fee, state.sqrtPriceX96.toString(), state.liquidity.toString(), state.tick);
                    console.log(poolExample);
                    return [2 /*return*/];
            }
        });
    });
}
main();

以下是这个问题的一些潜在原因和解决方案:

Contract Address:确保currentPoolAddress为已部署的Uniswap V3池契约的正确地址。仔细检查您是否提供了正确的合同地址,并且合同已成功部署。

ABI Mismatch: Verify that IUniswapV3PoolABI。abi对应于Uniswap V3池契约的abi。确保ABI与您正在交互的契约的特定版本和实现相匹配。

合约方法可用性:确认token0()方法在Uniswap V3池合约的ABI中实际上是可用的。检查合同的源代码或文档,以确保该方法存在并具有正确的签名。

合约交互权限:确保用于与合约交互的帐户或签名者(部署者)具有调用token0()方法所需的权限。检查该帐户是否具有调用该方法所需的适当角色或权限。

区块链网络:确保您连接到正确的区块链网络(例如以太坊主网,Ropsten等),其中部署了Uniswap V3池合约。验证您的网络配置和提供程序设置是否准确。

相关内容

  • 没有找到相关文章

最新更新