Depositing other ERC20 tokens to a contract then lock them

Is it possible to create a function that will allow deposits of other ERC-20 tokens to my newly created smart contract then lock them?

For example, I created a token ABC but I will need collateral from the owner using other ERC-20 tokens like DAI or USDT. The owner will deposit this DAI to the contract then lock it in for a certain period of time.

Is this possible? Basically, there are 2 concerns: The contract will accept other ERC-20 tokens then the next one is locking those other ERC-20 tokens.

Thanks

1 Like

Yes, I think it is possible.
If you have not deployed your contract, it seems like you just need to add such a function.
If you have deployed the contract, and it is upgradable, then you also can upgrade your contract to do so, but if is not upgradable, I think you can nothing for it.

1 Like

Thanks for the reply. Yeah the contract is not yet created. You mean using the transferFrom function of another token by using a contract address right?

1 Like

Yeah, I think so, you can have a try.

1 Like

Hi @Benjamin_P,

In your contract you could add a withdraw mechanism for any deposited tokens, checking for any conditions before allowing them to be withdrawn.

Have a look at: Example of withdrawing an ERC20 from another contract

1 Like

Thanks, I’ll check this out.

1 Like

Thanks, this is working and the one I was looking for.

1 Like