this.balance
返回该合约地址里的以太坊余额
注意
balance=this.balance//balance需要constant修饰符
pragma solidity ^0.4.22;
/*
+------------------------------------------------------------------------------+
| |
| XX XXXXX XXXXXX XXXXXXXXXXX XXXXXXXXXX |
| XX XX XXX XXX XXX X X X X |
| XX XX X X X XXXXXXXXXXX X X |
| XXXXXXXXX X X X X X |
| XX XX X X X X X |
| XX X X X XXXXXXXXXXX X X |
| |
| |
+------------------------------------------------------------------------------+
*/
contract Balance{
//存入一些ether用于后面的测试
function deposit() payable{
}
//查询当前的余额
function getBalance() constant returns(uint){
return this.balance;
}
}
网友评论