【转载】solidity智能合约[22]-地址

solidity

#1

地址

solidity语言中有账户的概念,solidity语言中有两类账户。一类是合约账户、一类是外部账户。账户都有地址。地址为160位。

定义地址

address public account1 = 0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB;
address public account2 = 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c;

address底层以uint160存储

function changeIt() view public returns(uint160){
     return uint160(account2);//428365927726247537526132020791190998556166378203
 }
 function changeIt2() pure public returns(address){
   return address(1154414090619811796818182302139415280051214250812);//0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB
}

地址比较

地址可以进行比较,和整数比较大小类似。

function check1() view public  returns(bool){
    return   account1>account2;
  }

      function check2() view public returns(bool){
     return account1>=account2;
  }
    function check3() view public returns(bool){
     return account1<=account2;
  }

      function check4() view public returns(bool){
     return account1<=account2;
  }
  • 本文链接: <https ://dreamerjonson.com/2018/11/20/solidity-22-addressAndPayable/>