小编m-d*_*ngo的帖子

错误:合约运行程序不支持在 ethers.js v6 上调用(操作 =“call”,代码 = UNSUPPORTED_OPERATION,版本 = 6.3.0)

我正在使用React、Hardhat、Ethers.js和Solidity制作一个简单的 dapp 。

我一直在关注 YouTube 上的教程,但我陷入了从创建的合约对象调用 Solidity 函数的部分。

每当我尝试从合约中调用函数时,它都会不断产生以下错误:

"contract runner does not support calling"
Run Code Online (Sandbox Code Playgroud)

查询合约是有效的,因为我可以获得合约的余额,但我找不到任何有关如何修复合约运行程序错误的资源。将不胜感激的帮助。下面是 React 中的代码。

"contract runner does not support calling"
Run Code Online (Sandbox Code Playgroud)

坚固性代码:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

contract Rental {
    struct Bike{
        string name;
        uint rangePower;
        uint maxSpeed;
        uint batteryCapacity;
        uint costPerHour;
        bool isAvailable;
    }
    
    //admin variables
    address owner;
    uint totalHours=0;
    uint totalRents=0;
    uint totalEbikes;

    //array of bikes
    Bike[] bikes;
 
    constructor(){
        //contract deployer address
        owner = msg.sender;

        //initialization …
Run Code Online (Sandbox Code Playgroud)

solidity decentralized-applications ethers.js hardhat

1
推荐指数
1
解决办法
4855
查看次数