DAPP钱包交易所系统开发技术详细/方案项目/案例详细/源码功能

简介: Blockchain technology is generally used to build transaction systems, and it is necessary to ensure that the transaction information is authentic, traceable, and tamper proof. The information of each transaction is confirmed and stored in a block,。

Blockchain technology is generally used to build transaction systems, and it is necessary to ensure that the transaction information is authentic, traceable, and tamper proof. The information of each transaction is confirmed and stored in a block,

which is encrypted through hash technology to ensure that the information is not tampered with. These blocks form a chain in chronological order. Each node maintains complete blockchain information, and the information of individual nodes is damaged without affecting the blockchain information. This type of information recording method is called distributed ledger.

What is blockchain? In short, it is a special type of distributed database. Firstly, the main function of blockchain is to store information. Any information that needs to be saved can be written to or read from the blockchain, so it is a database.

Secondly, anyone can set up a server, join the blockchain network, and become a node. In the world of blockchain, there is no central node, and each node is equal and stores the entire database. You can write/read data to any node, as all nodes will eventually synchronize to ensure blockchain consistency.

  /**
销毁方法

 * @param to to地址
 * @return amount0
 * @return amount1
  * @notice 应该从执行重要安全检查的合同中调用此低级功能
 */
// this low-level function should be called from a contract which performs important safety checks
function burn(address to)
    external
    lock
    returns (uint256 amount0, uint256 amount1)
{
    //获取`储备量0`,`储备量1`
    (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings
    //带入变量
    address _token0 = token0; // gas savings
    address _token1 = token1; // gas savings
    //获取当前合约在token0合约内的余额
    uint256 balance0 = IERC20(_token0).balanceOf(address(this));
    //获取当前合约在token1合约内的余额
    uint256 balance1 = IERC20(_token1).balanceOf(address(this));
    //从当前合约的balanceOf映射中获取当前合约自身的流动性数量
    uint256 liquidity = balanceOf[address(this)];

    //返回铸造费开关
    bool feeOn = _mintFee(_reserve0, _reserve1);
    //获取totalSupply,必须在此处定义,因为totalSupply可以在mintFee中更新
    uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
    //amount0 = 流动性数量 * 余额0 / totalSupply   使用余额确保按比例分配
    amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
    //amount1 = 流动性数量 * 余额1 / totalSupply   使用余额确保按比例分配
    amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
    //确认amount0和amount1都大于0
    require(
        amount0 > 0 && amount1 > 0,
        "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED"
    );
    //销毁当前合约内的流动性数量
    _burn(address(this), liquidity);
    //将amount0数量的_token0发送给to地址
    _safeTransfer(_token0, to, amount0);
    //将amount1数量的_token1发送给to地址
    _safeTransfer(_token1, to, amount1);
    //更新balance0
    balance0 = IERC20(_token0).balanceOf(address(this));
    //更新balance1
    balance1 = IERC20(_token1).balanceOf(address(this));

    //更新储备量
    _update(balance0, balance1, _reserve0, _reserve1);
    //如果铸造费开关为true, k值 = 储备0 * 储备1
    if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
    //触发销毁事件
    emit Burn(msg.sender, amount0, amount1, to);
}
相关文章
|
Linux
Linux系统之touch命令的基本使用
Linux系统之touch命令的基本使用
326 1
|
资源调度 前端开发 数据可视化
去中心化交易所开发(演示源码)
去中心化交易所开发(演示源码)
|
关系型数据库 MySQL Linux
在Linux中,如何启动、停止、重启一个系统服务?
在Linux中,如何启动、停止、重启一个系统服务?
中国高校最大云上科研智算平台,上线!
中国高校最大云上科研智算平台,上线!
144 0
|
前端开发 JavaScript Java
小说网站|基于Springboot+Vue实现在线小说阅读网站
小说网站|基于Springboot+Vue实现在线小说阅读网站
450 1
|
自然语言处理 数据可视化 图形学
SolidUI社区-提示词自我一致性
SolidUI社区-提示词自我一致性
401 0
|
消息中间件 存储 Kafka
【Kafka从入门到放弃系列 二】Kafka集群搭建及基本命令
【Kafka从入门到放弃系列 二】Kafka集群搭建及基本命令
238 0
java202303java学习笔记第四十三天函数-事务的隔离级别2 原
java202303java学习笔记第四十三天函数-事务的隔离级别2 原
139 0
|
存储 监控 算法
钱包交易所开发稳定版丨钱包交易所系统开发项目方案/案例详细/成熟技术/源码说明
  随着互联网的迅速发展,人们开始探索更加高效、安全和去中心化的应用。在这一背景下,区块链技术的出现为构建下一代去中心化应用程序(dapp)提供了新的思路和解决方案。