4

求一份可参考的erc20代币购买erc20代币的合约,万分感谢!! | 登链社区 | 技术问答

 2 years ago
source link: https://learnblockchain.cn/question/2832
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

20 求一份可参考的erc20代币购买erc20代币的合约,万分感谢!!

假设我发行了erc20代币 A,
我现在明白,用链的原生币购买erc20代币的流程,比如说在BSC链上,用BNB买A币流程。不明白合约里怎么写才可以让别人用 USDT(erc20代币) 买我的 erc20代币 A。

先假定代币A的价格固定。

感谢解答!

最佳答案 2小时前

可以参考这个文章:https://learnblockchain.cn/article/3245

核心代码是:

// 从 USDT 转入:
TransferHelper.safeTransferFrom(usdt, user, this, amount);
.....
//转出A
TransferHelper.safeTransfer(A, user, amountx);

好的老哥,我看一看,感谢!

Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 40% | 回答于 2小时前

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK