I have the following function in my contract:
function AcceptOffer() public payable
{
if ( msg.sender != InstanceOwner )
{
revert("You are not the owner of this contract and cannot accept the offer");
}
if (State != StateType.OfferPlaced) {
revert("You can only accept valid offers");
}
InstanceOwner.transfer(Change)
InstanceBuyer.transfer(OfferPrice);
State = StateType.Accepted;
}
But executing it gives a function payable error. If I remove one of the transfer lines, it works. Are multiple transfers in a single contract not possible? InstanceOwner and InstanceBuyer are two different addresses.
EDIT:
Change is calculated from the diff between AskingPrice and OfferPrice. So if AskingPrice is 5 and OfferPrice is 7 then Change is 2. When I debug the transaction, it shows the variables with their expected values. Therefore I expect the transfer to be successful. The line InstanceOwner.transfer(change)
is acting like there's no balance in the variable but there is when I inspect it.
Change + OfferPrice1
) in the contract. Of all things, that should definitely be the first that comes to mind. How on earth did you start with "multiple transfers in a single contract not possible"???InstanceOwner
andInstanceBuyer
) is the address of a contract whose fallback function reverts when executed (or perhaps not even implemented).What may be obvious for you may not be obvious for everyone. I made the assumption based on what I'm observing in my learnings
- you are correct, I apologize for my conclusion.