0

How can I make a smart contract receive usdt, and how the users are going to send it?

1
  • 2
    Please consider breaking out this into multiple questions. Also do a little bit of research and and ask specific questions. Commented Feb 25, 2022 at 3:17

1 Answer 1

2

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.

5
  • 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
    Here is the ERC20 specification, nearly every ERC20 follows this. And yes, transferFrom does have a recipient field. Yes, each separate blockchain has a separate USDT contract.
    – Meriadoc
    Commented Feb 26, 2022 at 1:11
  • 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
    EOA and other smart contracts.
    – Meriadoc
    Commented Feb 27, 2022 at 22:48

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