Solidity_SimpleSwap_20210713 – 坚固性u SimpleSwap u 20210713区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Solidity_SimpleSwap_20210713 – 坚固性u SimpleSwap u 20210713区块链毕设代写 是一篇很好的国外资料

Solidity_SimpleSwap_20210713

Simple Solidity Contract to swap ERC20 with ETH

Quick Test in Remix

  1. Deploy the contracts/erc20.sol from the W1 Wallet who will be receive the minted initial amount

  2. Deploy the contracts/swap.sol

  3. Say W1 wants to sell a certain amount of its ERC20 tokens so it first calls the ERC20 approve() to approve the Swap Contract for that amount of ERC20 and then calls ask() to create the deal

  4. Everybody can now see the deal inspecting the logs

  5. Now W2 Wallet wants to enter the deal so using it just call buy() making sure you pay at least the required amount of ETH

  6. The Swap Contract will run the swap and refund the buyer for the exceeding amount of ETH

FINAL NOTES

This is just a very minimal example so I have not paid attention to security and efficiency, just focusing on the minimal functionalities

Please do not use this in production


Solidityu SimpleSwapu 20210713

Simple Solidity Contract to swap ERC20 with ETH

快速测试混音

  1. 从W1钱包部署合同/erc20.sol,W1钱包将收到铸造的初始金额
  2. 部署合同/swap.sol
  3. 说W1想要出售一定数量的ERC20代币,因此它首先调用ERC20 approve()来批准该笔ERC20代币的掉期合同,然后调用ask()来创建交易
  4. 现在每个人都可以看到交易查看日志
  5. 现在W2 Wallet想要进入交易,所以使用它只需调用buy(),确保您至少支付了一笔款项交换合同规定的ETH金额将进行交换,并退还买方超出的ETH金额
  6. 交换合同将运行交换并退还买方超过的ETH金额

最后的说明

这只是一个很小的例子,所以我没有注意安全和效率,只关注最小的功能

请不要在生产中使用此功能

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/23042.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Solidity_SimpleSwap_20210713 – 坚固性u SimpleSwap u 20210713区块链毕设代写

提供最优质的资源集合

立即查看 了解详情