I am trying to create a contract to store ether and two ERC-20 tokens. People will transfer ether and the other two ERC-20 tokens to this contract and when the time comes, the owner of this contract will transfer these ether and ERC-20 tokens back to them. I don't know how to make this contract.
Currently, I can make an ERC-20 token contract and it can only store the ether and this ERC-20 token itself like below.
Suppose this contract can store 3 kinds of tokens. When people transfer these tokens to the contract, how the contract itself knows which token was sent?
contract WalkDogToken is ERC20, ERC20Burnable, Ownable {
constructor() ERC20("WalkDogToken", "WDT") {}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function decimals() public view virtual override returns (uint8) {
return 8;
}
receive() external payable {}
}