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;
}
-
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– wanshun zhongCommented 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 BotCommented Dec 3, 2021 at 19:53
Add a comment
|
1 Answer
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