在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);
}
}