0

I want to create a solidity smart contract (ERC20) for a play to earn and I would like to know how to reward the winners without them having to pay gas fees when they claim their winnings.

I think that's not possible but I need confirmation.

The rules of my game are very simple:

  1. Player A and Player B deposit on the smart contract the same amount.
    Example: each player deposits 1 ETH
  2. The winner gets the amount deposited (2 ETH)

Is it possible to allow the winner to recover his winnings for free. That is to say that the gas fees of the transaction are taken into account by another entity (ex: the owner of the contract)?

(Or do you have any suggestions?)

Best Regard and Thank you

1 Answer 1

2

Yes you can. Not sure what is the logic of your game but let's say once they deposit the 1ETH, you save their addresses in the contract. You can get the user's address with msg.sender.

Once the game is finished, you can just transfer the prize to the winner using address.call.value(amount)( ).

0

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.