How can I create a function that accepts all ERC20 token?
And a function that allow users to pay before accessing a specific webpage and how to write an event that shows users what they’re paying for?
Hey @Iwambeandy
You can use a
mapping(address => bool)
to track the users that have paid.
Then inside a function, let's call it pay(ierc20 tokenAddress, uint256 amount)
you can call transferFrom
of the token to get the payment and then update the mapping to record the user payment status.
Inside this function you can emit an event like this
emit Paid(address user, uint256 amount)
Then from the website just check the mapping to know if the user has paid.
Please take in mind this is a pseudo code that I wrote from my phone😁
Thanks a lot mate I really appreciate