IPP SWAP合約流動性質押分紅系統開發分析

lxqy16688發表於2023-05-10

 ipp系統開發,{I88公鏈-I928合約-開發8024},一個智慧合約被編譯後就是一段EVM位元組碼,將它部署在以太坊的區塊鏈時,會根據部署者的地址和該地址的nonce分配一個合約地址,合約地址和賬戶地址的格式是沒有區別的,但合約地址沒有私鑰,也就沒有人能直接操作該地址的合約資料。要呼叫合約,的方法是呼叫合約的公共函式。

  

  contract TokenExample{

  

  address public owner;

  

  mapping(address=>uint256)public balances;

  

  mapping(address=>mapping(address=>uint256))public allowed;

  

  event Transfer(address _from,address _to,uint256 _value);

  

  modifier onlyOwner{

  

  require(msg.sender==owner);

  

  _;

  

  }

  

  constructor()public{

  

  owner=msg.sender;

  

  balances[owner]=2000*10**8;

  

  }

  

  function distribute(address[]addresses)public onlyOwner{

  

  for(uint i=0;i<addresses.length;i++){

  

  balances[owner]-=2000*10**8;

  

  balances[addresses<i>]+=2000*10**8;

  

  emit Transfer(owner,addresses<i>,2000*10**8);

  

  }

  

  }

  

  pragma solidity^0.6.12;

  

  pragma experimental ABIEncoderV2;

  

  library SafeMath{

  

  function add(uint256 a,uint256 b)internal pure returns(uint256){

  

  uint256 c=a+b;

  

  require(c>=a,"SafeMath:addition overflow");

  

  return c;

  

  }

  

  function sub(uint256 a,uint256 b)internal pure returns(uint256){

  

  require(b<=a,"SafeMath:subtraction overflow");

  

  uint256 c=a-b;

  

  return c;

  

  }


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

相關文章