0

I am developing a game on the blockchain platform, this game is a dose game. The scenario of the game is that a user creates a game and a contract is created, other users can see the list of games or the same contracts and join the game and play. I want when the user created the game and no one joined his game, he can cancel the game and get back the amount of coins he deposited. I wrote a method called cancel, but this method does not work properly and calculates the amount of gasfee too much.

This is the error I get:

enter image description here

This is my solidity code:

enter image description here

This is my Web3js code:

enter image description here

1
  • Is addressWage a contract? Cause if it is, it needs a fallback or receive function.
    – 0xSanson
    Commented Jul 16, 2023 at 19:28

1 Answer 1

0

If addressWage is a contract, it needs to have a receive or a fallback function in order to be able to receive ether balance. Simply:

receive() external payable {…}

Moreover, the transfer call needs to specify addressWage as payable:

payable(addressWage).transfer(wage)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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