合约交易系统开发(逻辑开发)丨合约交易所系统开发(案例源码)/成熟方案/项目开发/源码部署

简介:   智能合约的生命周期根据其运行机制可概括为协商、开发、部署、运维、学习和自毁六个阶段,其中开发阶段包括合约上链前的合约测试,学习阶段包括智能合约的运行反馈与合约更新等.智能合约的基础架构模型,模型自底向上由基础设施层、合约层、运维层、智能层、表现层和应用层组成

  智能合约的生命周期根据其运行机制可概括为协商、开发、部署、运维、学习和自毁六个阶段,其中开发阶段包括合约上链前的合约测试,学习阶段包括智能合约的运行反馈与合约更新等.智能合约的基础架构模型,模型自底向上由基础设施层、合约层、运维层、智能层、表现层和应用层组成,

  基础设施层:封装了支持智能合约及其衍生应用实现的所有基础设施,包括分布式账本及其关键技术、开发环境和可信数据源等,这些基础设施的选择将在一定程度上影响智能合约的设计模式和合约属性.

  event DeployMarketEvent();

  event ChangeMarketStatusEvent(uint8 status);

  event SetTokenInfoEvent(uint16 tokenCode,string symbol,address tokenAddr,uint64 scaleFactor,uint minDeposit);

  event SetWithdrawAddrEvent(address trader,address withdrawAddr);

  event DepositEvent(address trader,uint16 tokenCode,string symbol,uint64 amountE8,uint64 depositIndex);

  event WithdrawEvent(address trader,uint16 tokenCode,string symbol,uint64 amountE8,uint64 lastOpIndex);

  event TransferFeeEvent(uint16 tokenCode,uint64 amountE8,address toAddr);

  //balanceE8is the total balance after this deposit confirmation

  event ConfirmDepositEvent(address trader,uint16 tokenCode,uint64 balanceE8);

  //amountE8is the post-fee initiated withdraw amount

  //pendingWithdrawE8is the total pending withdraw amount after this withdraw initiation

  event InitiateWithdrawEvent(address trader,uint16 tokenCode,uint64 amountE8,uint64 pendingWithdrawE8);

  event MatchOrdersEvent(address trader1,uint64 nonce1,address trader2,uint64 nonce2);

  event HardCancelOrderEvent(address trader,uint64 nonce);

  event SetFeeRatesEvent(uint16 makerFeeRateE4,uint16 takerFeeRateE4,uint16 withdrawFeeRateE4);

  event SetFeeRebatePercentEvent(address trader,uint8 feeRebatePercent);

  function Dex2(address admin_)public{

  admin=admin_;

  setTokenInfo(0/tokenCode/,"ETH",0/tokenAddr/,ETH_SCALE_FACTOR,0/minDeposit/);

  emit DeployMarketEvent();

  }

  function()external{

  revert();

  }

  //Change the market status of DEX.

  function changeMarketStatus(uint8 status_)external{

  if(msg.sender!=admin)revert();

  if(marketStatus==CLOSED)revert();//closed is forever

  marketStatus=status_;

  emit ChangeMarketStatusEvent(status_);

  }

  //Each trader can specify a withdraw address(but cannot change it later).Once a trader's

  //withdraw address is set,following withdrawals of this trader will go to the withdraw address

  //instead of the trader's address.

  function setWithdrawAddr(address withdrawAddr)external{

  if(withdrawAddr==0)revert();

  if(traders[msg.sender].withdrawAddr!=0)revert();//cannot change withdrawAddr once set

  traders[msg.sender].withdrawAddr=withdrawAddr;

  emit SetWithdrawAddrEvent(msg.sender,withdrawAddr);

  }

  //Deposit ETH from msg.sender for the given trader.

  function depositEth(address traderAddr)external payable{

  if(marketStatus!=ACTIVE)revert();

  if(traderAddr==0)revert();

  if(msg.value<tokens[0].minDeposit)revert();

  if(msg.data.length!=4+32)revert();//length condition of param count

  uint64 pendingAmountE8=uint64(msg.value/(ETH_SCALE_FACTOR/10**8));//msg.value is in Wei

  if(pendingAmountE8==0)revert();

  uint64 depositIndex=++lastDepositIndex;

  setDeposits(depositIndex,traderAddr,0,pendingAmountE8);

  emit DepositEvent(traderAddr,0,"ETH",pendingAmountE8,depositIndex);

  }

  //Deposit token(other than ETH)from msg.sender for a specified trader.

相关文章
|
6月前
|
安全 API 网络安全
数字货币交易所系统开发详细功能/需求项目/教程步骤/指南逻辑
Developing a digital currency exchange system is a complex project that requires multiple steps to complete. The following are the general steps for developing a digital currency exchange system
|
6月前
|
安全 区块链
数字货币秒合约/交易所系统开发详细程序/案例项目/需求设计/方案逻辑/源码步骤
The development of a digital currency second contract/exchange system requires the following functions:
|
6月前
|
安全 API 区块链
数字货币合约交易系统开发教程指南丨案例项目丨功能策略丨需求分析丨源码详细
Developing a digital currency contract trading system is a complex project, and the following are possible project requirements details:
|
运维 前端开发 关系型数据库
交易所系统开发源码及部署丨交易所系统开发(逻辑方案)
交易所系统开发是一个复杂而关键的过程。它包括需求分析、系统设计、编码实现、测试和部署等多个环节。在整个流程中,需要密切合作与沟通,确保系统能够按照预期的方式运行。
|
存储 供应链 算法
交易所项目系统开发案例详细丨交易所系统开发(源码逻辑)/方案设计/源码程序
  广义来讲,区块链技术是利用块链式数据结构来验证与存储数据、利用分布式节点共识算法来生成和更新数据、利用密码学的方式保证数据传输和访问的安全、利用由自动化脚本代码组成的智能合约来编程和操作数据的一种全新的分布式基础架构与计算方式。
|
存储 监控 安全
合约交易所开发详情丨合约交易所系统开发项目/成熟案例/方案逻辑/规则玩法/稳定版/源码部署
合约交易所系统开发是一个复杂的项目,它涉及多个方面,包括系统设计、规则制定、开发实现、部署和稳定运行等
|
安全 区块链
阐述永续合约交易所系统开发方案逻辑及案例项目丨源码程序
阐述永续合约交易所系统开发方案逻辑及案例项目丨源码程序
|
存储 区块链 数据安全/隐私保护
秒U合约交易系统开发(成熟源码)|秒U合约模式系统开发
智能合约只是存储在区块链上的程序,在满足预先确定的条件时会运行这些程序。
|
SQL 安全 区块链
交易所系统开发(案例项目)丨区块链交易所系统开发(稳定版)/成熟技术/步骤逻辑/源码教程
The development of a blockchain exchange system involves complex technologies and functions.
|
区块链 安全
区块链交易所系统开发详细指南丨交易所系统开发功能逻辑/方案介绍/案例设计/逻辑项目/源码出售
User experience: The interface and user experience of blockchain exchanges should be intuitive, user-friendly, and easy to use and navigate. The platform should provide a simple and clear trading interface to facilitate users' buying and selling operations.
下一篇
无影云桌面