This question already has an answer here:

How would I go about making sure users of a DApp can only interact with the contract using a specific ERC20 token?

For example, say a user has Ethereum, Token 1, and Token 2 in their wallet. The DApp uses Token 2. How can I make it so if they send anything other than Token 2 to the DApp contract, they are refunded.

marked as duplicate by lungj, Richard Horrocks, Ismael, niksmac, Dawny33 Jul 23 '17 at 5:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You would essentially just be looking at the specific token contract that you want to interact with and make a call to the public function that lists the owners of tokens. All ERC20 tokens have a balance of function:

function balanceOf(address who) constant returns (uint256);

also all transfers are done from that same contract:

function transfer(address to, uint256 value);

as long as you are only interacting with the contract for the token that you want to use... you shouldn't have a problem.

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