A Lottery Solidity Smart Contract - Accept erc20 token instead of ether

I want o change the function

  function enter() public payable {
    require(msg.value > .01 ether);

    players.push(msg.sender);
  }

Instead of ether, user use our token/erc20 to enter the lottery

Hi, I think this is possible, users need to approve to this Lottery contract, and then the contract call transferFrom to get the user token. So what is your question?

how can I implement that? https://gist.github.com/willianmano/eac9b24ff9df04cce88465f485a8fdbc
this is the code I want to modify. Please Help, Thank you.

I think you should try to do this by yourself at first rather than just want to get the final answer. We all would like to help you if you meet any questions when you try to achieve this feature.

Already done, thanks btw

1 Like