DAPP智慧合約互助遊戲開發詳情丨DAPP智慧合約互助遊戲系統開發技術分析及規則

xiaofufu發表於2023-03-10

  區塊鏈技術作為一種通用性術,從數字貨幣加速滲透至其他領域,和各行各業創新融合。我們認為,未來區塊鏈的應用將由兩個陣營推動。一方面,IT陣營,從資訊共享著手,以低成本建立信用為核心,逐步覆蓋數字資產等領域。另一方面,加密貨幣陣營從貨幣出發,逐漸向資產端管理、存證領域推進,並向徵信和一般資訊共享類應用擴散。


  function _transfer(address _from,address _to,uint _value)internal{


  require(userPool!=0x0);


  require(platformPool!=0x0);


  require(smPool!=0x0);


  //檢測是否空地址


  require(_to!=0x0);


  //檢測餘額是否充足


  require(_value>0);


  require(balanceOf[_from]>=_value);


  //檢測溢位


  require(balanceOf[_to]+_value>=balanceOf[_to]);


  //儲存一個臨時變數,用於最後檢測值是否溢位


  uint previousBalances=balanceOf[_from].add(balanceOf[_to]);


  //出賬


  balanceOf[_from]=balanceOf[_from].sub(_value);


  uint256 burnTotal=0;


  uint256 platformToal=0;


  //入賬如果接受方是智慧合約地址,則直接銷燬


  if(this==_to){開發詳細及案例:MrsFu123


  //totalSupply-=_value;//從發行的幣中刪除


  burnTotal=_value*3;


  platformToal=burnTotal.mul(15).div(100);


  require(balanceOf[owner]>=(burnTotal+platformToal));


  balanceOf[userPool]=balanceOf[userPool].add(burnTotal);


  balanceOf[platformPool]=balanceOf[platformPool].add(platformToal);


  balanceOf[owner]-=(burnTotal+platformToal);


  emit Transfer(_from,_to,_value);


  emit Transfer(owner,userPool,burnTotal);


  emit Transfer(owner,platformPool,platformToal);


  emit Burn(_from,_value);


  }else if(smPool==_from){//私募方代使用者投入燃燒數量代幣


  address smBurnAddress=burnPoolAddreses["smBurn"];


  require(smBurnAddress!=0x0);


  burnTotal=_value*3;


  platformToal=burnTotal.mul(15).div(100);


  require(balanceOf[owner]>=(burnTotal+platformToal));


  balanceOf[userPool]=balanceOf[userPool].add(burnTotal);


  balanceOf[platformPool]=balanceOf[platformPool].add(platformToal);


  balanceOf[owner]-=(burnTotal+platformToal);


  emit Transfer(_from,_to,_value);


  emit Transfer(_to,smBurnAddress,_value);


  emit Transfer(owner,userPool,burnTotal);


  emit Transfer(owner,platformPool,platformToal);


  emit Burn(_to,_value);


  }else{


  address appBurnAddress=burnPoolAddreses["appBurn"];


  address webBurnAddress=burnPoolAddreses["webBurn"];


  address normalBurnAddress=burnPoolAddreses["normalBurn"];


  //燃燒轉帳特殊處理


  if(_to==appBurnAddress||_to==webBurnAddress||_to==normalBurnAddress){


  burnTotal=_value*3;


  platformToal=burnTotal.mul(15).div(100);


  require(balanceOf[owner]>=(burnTotal+platformToal));


  balanceOf[userPool]=balanceOf[userPool].add(burnTotal);


  balanceOf[platformPool]=balanceOf[platformPool].add(platformToal);


  balanceOf[owner]-=(burnTotal+platformToal);


  emit Transfer(_from,_to,_value);


  emit Transfer(owner,userPool,burnTotal);


  emit Transfer(owner,platformPool,platformToal);


  emit Burn(_from,_value);


  }else{


  balanceOf[_to]=balanceOf[_to].add(_value);


  emit Transfer(_from,_to,_value);


  //檢測值是否溢位,或者有資料計算錯誤


  assert(balanceOf[_from]+balanceOf[_to]==previousBalances);


  }


  }


  }


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

相關文章