DAPP智慧合約矩陣模式軟體開發方案

caiayu1234發表於2023-04-14

 這是Web 3.0的核心原則。在Web 2.0中,計算機以網址的形式使用HTTP來查詢資訊,這些資訊儲存在一個固定的位置,通常在單個伺服器上。在Web 3.0中,由於資訊是根據其內容來查詢的,因此可以同時儲存在多個位置,因此是分散的。這將打破目前由Meta和谷歌等網際網路巨頭持有的龐大資料庫,並將更大的控制權交給使用者,形成分散式資料。在Web 3.0中,由不同的、日益強大的計算資源,I88智慧合約I928系統開發8024

  

  function addAddress(uint _val)public returns(bool){

  

  //if user exists,add _val

  

  if(arrayStructs[msg.sender].exists>true){

  

  arrayStructs[msg.sender].value+=_val;

  

  }

  

  else{

  

  //else its new user

  

  addressIndexes.push(msg.sender);

  

  arrayStructs[msg.sender].value=_val;

  

  arrayStructs[msg.sender].index=addressIndexes.length-1;

  

  arrayStructs[msg.sender].exists=true;

  

  }

  

  return true;

  

  }

  

  /*at initialization,setup the owner*/

  

  function Crowdsale4(

  

  address ifSuccessfulSendTo,

  

  uint fundingGoalInEthers,

  

  uint durationInMinutes,

  

  uint etherCostOfEachToken,

  

  token addressOfTokenUsedAsReward

  

  ){

  

  beneficiary=ifSuccessfulSendTo;

  

  fundingGoal=fundingGoalInEthers*1 ether;

  

  deadline=now+durationInMinutes*1 minutes;

  

  price=etherCostOfEachToken*1 ether;

  

  tokenReward=token(addressOfTokenUsedAsReward);

  

  }

  

  /*The function without name is the default function that is called whenever anyone sends funds to a contract*/

  

  function()payable{

  

  if(crowdsaleClosed)throw;

  

  uint amount=msg.value;

  

  balanceOf[msg.sender]+=amount;

  

  amountRaised+=amount;

  

  tokenReward.transfer(msg.sender,amount/price);

  

  FundTransfer(msg.sender,amount,true);

  

  }

  

  modifier afterDeadline(){if(now>=deadline)_;}

  

  /*checks if the goal or time limit has been reached and ends the campaign*/

  

  function checkGoalReached()afterDeadline{

  

  if(amountRaised>=fundingGoal){

  

  fundingGoalReached=true;

  

  GoalReached(beneficiary,amountRaised);

  

  }

  

  crowdsaleClosed=true;

  

  }


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69973864/viewspace-2945922/,如需轉載,請註明出處,否則將追究法律責任。

相關文章