简体   繁体   English

DeFi 平台中的多个 ERC20 代币

[英]Multiple ERC20 tokens in a DeFi platform

I'm building a DeFi application on Ethereum, and I would like to implement the Deposit function.我正在以太坊上构建一个 DeFi 应用程序,我想实现Deposit function。 Everything works fine between ETH and a ERC20 token that I built, but I would like to add some tokens like aToken for AAVE or cTokens for Compound that the user will receive after a Deposit call. ETH 和我构建的 ERC20 代币之间一切正常,但我想添加一些代币,例如用于 AAVE 的 aToken 或用于 Compound 的 cTokens,用户将在调用Deposit后收到这些代币。

So the question is: is it possible to add a function in my smart contract to create multiple tokens without creating a smart contract for each of them?所以问题是:是否可以在我的智能合约中添加一个 function 来创建多个代币而不为每个代币创建一个智能合约? If not, I have to create a different contract for each token I want to add in my app or there is a best method to do it?如果没有,我必须为要添加到我的应用程序中的每个令牌创建不同的合同,或者有最好的方法吗?

Yes this is possible.是的,这是可能的。 You can transfer the tokens to the user's address after the Compound Protocol mint operation.您可以在复合协议铸币操作后将代币转移到用户的地址。 This can be made generic using the ERC-20 transfer interface.这可以使用 ERC-20 传输接口进行通用化。 Be sure to account the amounts users are due and beware of the reentrancy vulnerability.请务必考虑用户应支付的金额,并注意重入漏洞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM