0

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.

  • 1. What is "a function payable error"? – goodvibration May 26 at 12:21
  • 2. How exactly are you executing it? – goodvibration May 26 at 12:22
  • 3. No, It IS possible. Sounds like there is simply not enough ether (less than 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"??? – goodvibration May 26 at 12:23
  • Another option is that one of those two recipients (InstanceOwner and InstanceBuyer) is the address of a contract whose fallback function reverts when executed (or perhaps not even implemented). – goodvibration May 26 at 12:25
  • 1
    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. – goodvibration May 26 at 14:10
0

There is no issue with multiple transfers, you can do as many transfers as you want iff you supply enough gas. The following could be possible causes of error:

  • Your contract must have sufficient balance (Change+OfferPrice) or your since your function is payable, you must send Change+offerPrice WEI to your contract while executing AcceptOffer function.
  • You are sending sufficient gas, try increasing the gas
  • If one of the InstanceOwner or InstanceBuyer is a contract address which does not accept Ether
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.