0
function addProductToStore(
    string memory _name,
    string memory _category,
    string memory _imageLink,
    string memory _descLink,
    uint256 _auctionStartTime,
    uint256 _auctionEndTime,
    uint256 _startPrice,
    uint256 _productCondition
) public {
    //开始时间需要小于结束时间
    require(
        _auctionStartTime < _auctionEndTime
        // "开始时间不能晚于结束时间"
    );
    //商品ID自增
    productIndex += 1;
    //product对象稍后直接销毁即可
    Product memory product = Product(
        productIndex,
        _name,
        _category,
        _imageLink,
        _descLink,
        _auctionStartTime,
        _auctionEndTime,
        _startPrice,
        0,
        0,
        0,
        0,
        ProductStatus.Open,
        ProductCondition(_productCondition)
    );
    stores[msg.sender][productIndex] = product;
    productIdInStore[productIndex] = msg.sender;
}
4
  • Hi wanshunzhong! Welcome to Ethereum Stackexchange! There's not enough code to try it, can you include a more complete example? What's the exact error message?
    – Ismael
    Commented Nov 30, 2021 at 5:14
  • 代码链接:cxybb.com/article/weixin_34387284/91785195 Commented Nov 30, 2021 at 6:40
  • Sorry, but I can't follow that article. Do you have a link to a github repo with the whole code?
    – Ismael
    Commented Dec 1, 2021 at 2:27
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Dec 3, 2021 at 19:53

1 Answer 1

0

If a struct has nested mapping you should use storage modifier

Product storage product = Product( ...

it means you can't get temporary variable of which struct that contains mapping

1
  • 代码链接:cxybb.com/article/weixin_34387284/91785195 Commented Nov 30, 2021 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.