广州列举网 > 商务服务 > 网站/软件服务 > 马蹄链公排矩阵模式系统开发详情
广州
[切换城市]

马蹄链公排矩阵模式系统开发详情

更新时间:2023-03-01 14:14:27 浏览次数:60次
区域: 广州 > 天河 > 珠江新城/跑马场
类别:软件开发
地址:广州天河区
  MaticNetwork现在更名为Polygon【I8I-系统259I-开发3365】Matic Network是一个第二层可扩展平台,可以实现快速、简单、安全的线下交易,不仅可以支付交易,还可以实现广义的链外智能合约。Matic Network是以太坊生态系统的重要贡献者,致力于实现等离子MVP(低运行等离子)。WalletConnect协议和以太坊事件提醒引擎——Dagger做出了突出贡献。自动令牌用于股权下注,并参与侧链网络的证明共识机制。

  智能合约开发入门步:正确认识并理解合约代码的含义

  智能合约开发步,在于要认识与理解合约代码的含义。接下来让我们先看一下基本的例子。现在就算你都不理解也不要紧,后面我们会有更深入的讲解。

  1、存储合约示例

  把一个数据保存到链上

  //SPDX-License-Identifier:GPL-3.0

  pragma solidity>=0.4.16<0.9.0;

  contractSimpleStorage{

  uintstoredData;

  functionset(uintx)public{

  storedData=x;

  }

  functionget()public view returns(uint){

  returnstoredData;

  }

  }

  行是说明源代码是根据GPL 3.0版本授权的。默认情况下,在发布源代码时加入机器可读许可证说明是很重要的,

  下一行是告诉编译器源代码所适用的Solidity版本为>=0.4.16及pragma是告知编译器如何处理源代码的通用指令(例如,pragma once)。

  Solidity中智能合约的含义就是一组代码(它的功能)和数据(它的状态)的集合,并且它们是位于以太坊区块链的一个特定地址上的。uintstoredData;这一行代码声明了一个名为``storedData``的状态变量,其类型为uint(256位无符号整数)。你也可以认为它是数据库里的一个插槽,并且可以通过调用管理数据库代码的函数进行查询和更改。在这个例子中,上述的合约定义了``set``和``get``函数,可以用来修改或检索变量的值。//SPDX-License-Identifier:SimPL-2.0

  pragma solidity>=0.7.0<0.8.9;

  contract zhongchou{

  //投资者投资记录:投资目标,投资金额

  struct toMoney{

  address payable addressReceiptor;

  uint money;

  }

  //投资者基本信息:地址,是否被,总投资金额,投资次数,映射记录投资记录

  struct funder{

  address payable addressfunder;

  bool isActive;

  uint totalMoney;

  uint numberGive;

  mapping(uint=>toMoney)expMap;

  }

  //众筹合约:合约创建者,是否被,金额总需求,已投资金额,投资人数量,映射记录投资人

  struct needMoneyContract{

  address payable addressNeeder;

  //payable address addressContract;

  bool isActive;

  uint totalMoney;

  uint giveMoney;

  uint amountFunder;

  mapping(uint=>funder)mapFunder;

  }

  //众筹发起者:地址,状态,需求总金额,已经被投资的金额,发起的众筹的数量,映射记录投资合约

  struct needer{

  address addressNeeder;

  bool isActive;

  uint amountMoneyNeed;

  uint amountHasFunded;

  uint numberContract;

  mapping(uint=>needMoneyContract)expMap;

  }

  //记录众筹合约总数,合约地址(资金池地址)

  uint amountContract;

  address payable public addressFinance;

  //三方数组

  mapping(address=>funder)funderMap;

  mapping(uint=>needMoneyContract)contractMap;

  mapping(address=>needer)neederMap;

  constructor(){

  addressFinance=payable(msg.sender);

  }

  //创建一个众筹发起者

  function createNeeder()public returns(bool){

  //需要判定是否已经被

  if(neederMap[msg.sender].isActive){

  return false;

  }

  else{

  address _addressNeeder=msg.sender;

  //0.8.0后不允许直接创建一个包含映射的结构体。需要通过引用的方式,先创建一个storage类型的结构体(与目标是引用关系),再对新变量进行操作即可。

  needer storage tmp1=neederMap[_addressNeeder];

  tmp1.addressNeeder=_addressNeeder;

  tmp1.isActive=true;

  tmp1.amountMoneyNeed=0;

  tmp1.amountHasFunded=0;

  tmp1.numberContract=0;

  return true;

  }

  }

  function createContract(

  uint _amountMoneyNeed

  )public returns(bool){

  address _addressNeeder=msg.sender;

  uint tmpNum=amountContract++;

  needMoneyContract storage tmp2=contractMap[tmpNum];

  tmp2.addressNeeder=payable(_addressNeeder);

  tmp2.isActive=true;

  tmp2.totalMoney=_amountMoneyNeed;

  tmp2.giveMoney=0;

  tmp2.amountFunder=0;

  uint tmpContract=neederMap[_addressNeeder].numberContract++;

  neederMap[_addressNeeder].amountMoneyNeed+=_amountMoneyNeed;

  needMoneyContract storage tmp3=neederMap[_addressNeeder].expMap[tmpContract];

  needMoneyContract storage tmp4=contractMap[tmpNum];

  tmp3=tmp4;

  return true;

  }

  function createFunder()public returns(bool){

  if(funderMap[msg.sender].isActive){

  return false;

  }

  else{

  address _address=msg.sender;

  funder storage tmpfund=funderMap[_address];

  tmpfund.addressfunder=payable(_address);

  tmpfund.isActive=true;

  tmpfund.totalMoney=0;

  tmpfund.numberGive=0;

  return true;

  }

  }

  function donateMoney(

  uint money,

  uint idContract,

  address addressNeeder

  )public payable returns(bool){

  require(contractMap[idContract].isActive==true);

  require(money==msg.value);

  require(contractMap[idContract].addressNeeder==addressNeeder);

  //payable address adressDonate=msg.sender;

  address tmpfunder=msg.sender;

  funderMap[tmpfunder].totalMoney+=money;

  toMoney storage tmpMoney=funderMap[tmpfunder].expMap[funderMap[tmpfunder].numberGive];

  tmpMoney.addressReceiptor=payable(addressNeeder);

  tmpMoney.money=money;

  funderMap[tmpfunder].numberGive++;

  contractMap[idContract].giveMoney+=money;

  funder storage tmpfund1=contractMap[idContract].mapFunder[contractMap[idContract].amountFunder++];

  funder storage tmpfund2=funderMap[tmpfunder];

  tmpfund1=tmpfund2;

  return true;

  }

  function isComplete(uint idContract)public payable returns(bool){

  require(contractMap[idContract].isActive==true);

  require(contractMap[idContract].addressNeeder==msg.sender);

  require(contractMap[idContract].totalMoney<=contractMap[idContract].giveMoney);

  needMoneyContract storage tmptrans=contractMap[idContract];

  tmptrans.isActive=false;

  address tmpaddr=msg.sender;

  uint getMoney=tmptrans.giveMoney;

  neederMap[tmpaddr].amountHasFunded+=getMoney;

  tmptrans.addressNeeder.transfer(getMoney);

  return true;

  }

  }
广州网站/软件服务相关信息
4月30日
4月29日
4月28日
4月28日
4月28日
4月26日
4月25日
注册时间:2022年07月01日
UID:739123
---------- 认证信息 ----------
手机已认证
查看用户主页