Solidity__获取合约账户余额

作者: ACToken | 来源:发表于2018-10-26 13:48 被阅读6次

    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;
      }
    }
    

    相关文章

      网友评论

        本文标题:Solidity__获取合约账户余额

        本文链接:https://www.haomeiwen.com/subject/qdiktqtx.html