美文网首页
常见EVM错误

常见EVM错误

作者: 天地一小儒 | 来源:发表于2023-12-13 11:29 被阅读0次
    1. Returned error: {"jsonrpc":"2.0","error":"[ethjs-query] while formatting outputs from RPC '{\"value\":{\"code\":-32603,\"data\":{\"code\":-32000,\"message\":\"transaction underpriced\"}}}'","id":4815365370376783}

      gasprice定价过低,调高定价

    2. Remix上合约调试时不能仅依赖事件是否发出为成功依据,而应该以状态变量为准,因为事件有可能不发!

    3. 部署时报错:code=CALL_EXCEPTION

      检查gaslimit:5b8d80==6000000 ⇒contracts/src.ts/deploy.ts 6000000改8000000

    4. Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fail if the current network has activated the eip 170.

      合约过大,需要拆分。参考另一篇《delegatecall》

    5. ProviderError: sender doesn't have enough funds to send tx. The max upfront cost is: 4845817880859375 and the sender's account only has: 0

      合约部署账户没有钱,打点原生币过去就行了

    6. CompilerError: Stack too deep, try removing local variables.

      变量声明太多了,可以用结构体封装一些,或者把部分代码挪出去变成函数

    7. Error: Transaction reverted: function call to a non-contract account

      接口正在尝试调用一个不存在的合约。检查合约确实是否存在,或者在合约中增加代码检查如果是合约地址就调用,否则就不调用。

    8. Explicit type conversion not allowed from "address" to "uint256".solidity(9640)

      在 Solidity 0.8.0 版本中,引入了一个更为安全的类型系统,不再允许直接将 address 类型转换为 uint256 类型。因此,你需要使用 type 关键字进行显式类型转换。

      uint256 size;
      assembly {
          size := extcodesize(_addr)
      }
      
    9. Explicit type conversion not allowed from "bytes memory" to "address".solidity(9640)

      function bytesToAddress(bytes memory data) internal pure returns (address) {
          require(data.length == 20, "Invalid address length");
          address result;
          assembly {
              result := mload(add(data, 32))
          }
          return result;
      }
      
    10. abi: length larger than int64: 48129323291152180489044384789343333891201197466736324414383260238138438582324

      合约有bug,检查是否修改了合约但忘记重新部署

    11. ProviderError: replacement transaction underpriced

      gasprice过低,hardhat可以设置如下代码修复:

      const contract = await Contract.deploy({
        gasPrice: ethers.parseUnits("25", "gwei"), // fuji中的 gas 价格最低是25 Gwei
      });
      

    相关文章

      网友评论

          本文标题:常见EVM错误

          本文链接:https://www.haomeiwen.com/subject/udvbgdtx.html