0

Here is my solidity code:

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

contract Seller {

struct GoodsItem {
    uint256 id;
    string name;
    uint256 left ;
    uint256 price;
}

struct Shop {
    string shopname;
    string boss;
    GoodsItem[] goodsArr;
    uint256 goodsAmount;
}

struct Balance {
    uint totalBalance;
}

mapping(address => Balance ) public storeBalance;
mapping(address => Shop) public stores;

function getBalance() public view returns (uint256) {
    return storeBalance[msg.sender].totalBalance;
}

function getAllGoods() public view returns( GoodsItem[] memory) {
    return stores[msg.sender].goodsArr;
}

function inputGoods(GoodsItem[] memory arr) public {
    uint256 amount = arr.length;
    stores[msg.sender].goodsAmount = amount;
    for (uint256 i = 0; i < amount; i++) {
        stores[msg.sender].goodsArr[i] = arr[i];
    }
}

}

I used webJs to create smart contract instance successfully, but when i tried to call the inputGoods function, it told me Transaction has been reverted by the EVM: enter image description here

Here is how i create the smart contract instance and call the function.

await contractInstance.methods.inputGoods(userInput).send({from: "0x19a9c8c670f9e7f5050f65674933823f04890b3f", gasPrice: "0x0", gasLimit: "0xffffff" });

I am totally new to solidity, now i got stuck here, hoping someone could help me with this!

0 Answers0