Home > Blockchain >  In DAPP project, calls the contract bid function, an error: the VM Exception while processing transa
In DAPP project, calls the contract bid function, an error: the VM Exception while processing transa

Time:09-24

The function revealBid (uint _productId, string _amount memory, string the memory _secret) public {
The Product storage Product=stores [productIdInStore [_productId]] [_productId];
Require (now> product. AuctionEndTime);
Bytes32 sealedBid=keccak256 (abi) encodePacked (_amount _secret));
The Bid the 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 {
} else {
If (product. HighestBidder==address (0)) {
Product. HighestBidder=MSG. Sender;
Product. HighestBid=amount;
Product. SecondHighestBid=product. StartPrice;
Refund=bidInfo. Value - the 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 - the 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);
}
}
  • Related