地址

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

定义地址

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

address底层以uint160存储

1
2
3
4
5
6
function changeIt() view public returns(uint160){
    return uint160(account2);//428365927726247537526132020791190998556166378203
}
function changeIt2() pure public returns(address){
  return address(1154414090619811796818182302139415280051214250812);//0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB
}

地址比较

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
 }

image.png