在DAPP项目中,调用合约中的揭示出价函数时,报错:VM Exception while processing transation:revert

诺小刀 2019-04-18 04:38:41
function revealBid(uint _productId, string memory _amount, string memory _secret) public {
Product storage product = stores[productIdInStore[_productId]][_productId];
require (now > product.auctionEndTime);
bytes32 sealedBid = keccak256(abi.encodePacked(_amount,_secret));
Bid memory bidInfo = product.bids[msg.sender][sealedBid];

require (bidInfo.bidder > address(0));
require (bidInfo.revealed == false);

uint refund;
uint amount = stringToUint(_amount);

if(bidInfo.value < amount) {
refund = bidInfo.value;
} else {
if (product.highestBidder == address(0)) {
product.highestBidder = msg.sender;
product.highestBid = amount;
product.secondHighestBid = product.startPrice;
refund = bidInfo.value - amount;
} else {
if (amount > product.highestBid) {
product.secondHighestBid = product.highestBid;
product.highestBidder.transfer(product.highestBid);
product.highestBidder = msg.sender;
product.highestBid = amount;
refund = bidInfo.value - amount;
} else if (amount > product.secondHighestBid) {
product.secondHighestBid = amount;
refund = amount;
} else {
refund = amount;
}
}
}

product.bids[msg.sender][sealedBid].revealed = true;

if (refund > 0) {
msg.sender.transfer(refund);
}
}
...全文
322 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

791

社区成员

发帖
与我相关
我的任务
社区描述
区块链技术专区
区块链 技术论坛(原bbs)
社区管理员
  • 区块链技术
  • ccc908
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧