转账

如果在函数中涉及到以太币的转移,需要使用到payable关键词。意味着可以在调用这笔函数的消息中附带以太币。

1
2
3
function pay() public payable{
        
        

}

this代表合约地址

this 代表当前部署的合约地址

1
2
3
4
5
function  getThis() public view returns(address){
        
        
    return this;
    // 0x9F4c14f487B8e4E3986467c2a2aA5bDE93052666
     //0x9f4c14f487b8e4e3986467c2a2aa5bde93052666
}

获取合约账户余额

1
2
3
4