DAPP公排矩陣互助合約系統開發分析方案

lxqy16688發表於2023-05-10

 合約搭建,{I88公鏈-I928合約-開發8024},區塊鏈的英文叫做Blockchain,用比較官方的話來說,區塊鏈是一種集分散式資料儲存、點對點傳輸、共識機制、加密演演算法等計算機技術於一體的新型應用模式。簡單來說,它就是一個分散式記賬的應用模型,透過去中心化、去信任的方式集中維護一個可靠的資料庫。你可以把它理解為:我們每個人都有一個小的賬本(小的資料庫),會記錄下來我們所有的資料

  

  contract ZT is ERC20("ZERO TOKEN","ZT"){

  

  //RULE 1

  

  bytes32 constant RULE_WITHDRAW_WANT=keccak256(abi.encodePacked("withdraw"));

  

  //RULE 2

  

  bytes32 constant RULE_NONE_WANT=keccak256(abi.encodePacked("depositByValue"));

  

  constructor()public{

  

  _mint(msg.sender,10000000*10**18);

  

  }

  

  function depositByWant(uint _amount)external payable{

  

  uint amount=_amount.mul(10**18);

  

  require(msg.value>=amount,"you want to trick me?");

  

  MkaheChange(msg.sender,amount,RULE_NONE_WANT);

  

  }

  

  function withdraw(uint _amount)external payable returns(bool){

  

  uint amount=_amount.mul(10**18);

  

  require(balanceOf(msg.sender)>=amount);

  

  _balances[msg.sender]=_balances[msg.sender].sub(amount);

  

  return MkaheChange(msg.sender,amount,RULE_WITHDRAW_WANT);

  

  }

  

  Coin.Sent().watch({},'',function(error,result){

  

  if(!error){

  

  console.log("Coin transfer:"+result.args.amount+

  

  "coins were sent from"+result.args.from+

  

  "to"+result.args.to+".");

  

  console.log("Balances now:n"+

  

  "Sender:"+Coin.balances.call(result.args.from)+

  

  "Receiver:"+Coin.balances.call(result.args.to));

  

  }

  

  })


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

相關文章