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

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

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

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

  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.

相关文章
|
9月前
|
安全 区块链
数字货币秒合约/交易所系统开发详细程序/案例项目/需求设计/方案逻辑/源码步骤
The development of a digital currency second contract/exchange system requires the following functions:
|
7月前
|
C++
合约跟单系统开发(源码案例)丨合约跟单开发源码案例部署
量化交易是指用定量的方案拟定行动方案,进行交易。在交易过程中,采用先进的数学模型量化盘面数据,替代人为的主观判断,通过历史数据反复验证寻找未来能够继续盈利的“大概率”策略,利用计算机快速处理技术
|
安全 区块链
defi丨dapp智能合约代币系统开发(开发案例)/需求详细/逻辑方案/项目源码
The development of the Defi single and dual currency pledge liquidity mining system requires the following steps: requirement analysis, system design, contract writing, front-end and back-end development, testing and deployment. Firstly, conduct a comprehensive requirement analysis of the system&#39;s f
|
9月前
|
安全 API 区块链
数字货币合约交易系统开发教程指南丨案例项目丨功能策略丨需求分析丨源码详细
Developing a digital currency contract trading system is a complex project, and the following are possible project requirements details:
|
存储 供应链 算法
交易所项目系统开发案例详细丨交易所系统开发(源码逻辑)/方案设计/源码程序
  广义来讲,区块链技术是利用块链式数据结构来验证与存储数据、利用分布式节点共识算法来生成和更新数据、利用密码学的方式保证数据传输和访问的安全、利用由自动化脚本代码组成的智能合约来编程和操作数据的一种全新的分布式基础架构与计算方式。
|
存储 监控 安全
合约交易所开发详情丨合约交易所系统开发项目/成熟案例/方案逻辑/规则玩法/稳定版/源码部署
合约交易所系统开发是一个复杂的项目,它涉及多个方面,包括系统设计、规则制定、开发实现、部署和稳定运行等
|
供应链 区块链
秒合约系统开发|源码搭建|方案与需求
展望未来,随着区块链技术的不断发展和完善,供应链管理将迎来更加智能化、高效化和透明化的新时代
|
安全 区块链
阐述永续合约交易所系统开发方案逻辑及案例项目丨源码程序
阐述永续合约交易所系统开发方案逻辑及案例项目丨源码程序
|
安全
秒合约时间盘丨源码搭建丨秒合约交易所系统开发技术源码搭建开发方案
秒合约时间盘丨源码搭建丨秒合约交易所系统开发技术源码搭建开发方案
224 0
|
区块链 安全
区块链交易所系统开发详细指南丨交易所系统开发功能逻辑/方案介绍/案例设计/逻辑项目/源码出售
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.