I'm developing a function that accepts any kind of ERC20 token, and transfer it to the provided address. The idea is to execute the function connecting Metamask address, and transferring the desired kind of ERC20 tokens to the desired Ethereum address.
It is not exactly a payable function, since it is not only receiving ETHer. In the examples I have seen, they specify the address contract of the desired ERC20 token, but in this case it could be any ERC20 token.
How could I get the selected token from Metamask, to specify the ERC20 contract address to my Smart Contract?
UPDATE: I think Uniswap do something like I want to achieve in this contract.
They import IERC20 standard Smart Contract, and use it to initialize any pair of tokens.
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
Thanks