How can I make a smart contract receive usdt, and how the users are going to send it?
1 Answer
Your smart contract can receive USDT without you doing anything at all. By default, any smart contract created can receive virtually any ERC20, since the ERC20 contract can send tokens to any address. If you're looking to do something with the USDT once you receive it (maybe crediting the users for sending it?) what you need to do is have an external function which calls address(USDT address).transferFrom(msg.sender, amount)
and then continues with normal functionality. In order for users to use that functionality, they have to first go to the USDT contract and call approve(your smart contract address, amount)
and then call the function inside your smart contract which includes transferFrom.
-
The transferFrom function should also have a recipient parameter, right? I want one user to send USDT to my contract, then I want the owner of the contract to send parts of this USDT to another user many times during the lifetime of the contract. Commented Feb 25, 2022 at 23:12
-
When you say they should call approve on the USDT contract - is this like a singleton contract each blockchain network that supports USDT has? Commented Feb 25, 2022 at 23:14
-
1
-
so if I have a smart contract on Solana for example, only EOA that have USDT on solana can transfer USDT to my smart contract? Commented Feb 26, 2022 at 1:51
-
1