solidity学习笔记(九)transfer转账

转账方法需要申明payable

transfer转账

pragma solidity ^0.4.6;

contract TestTransaction{
    function deposit() payable {
        address acc = 0x15Ee9687310EF47b59F2e6060d3b7AD90e6a09E5;
        acc.transfer(msg.value);//向acc地址转账msg.value个以太坊
    }

    function getBalance() constant returns(uint){
        address acc = 0x15Ee9687310EF47b59F2e6060d3b7AD90e6a09E5;
        return acc.balance;
    }
    
    function getOwnerBalance() constant returns(uint){
        address owner = msg.sender;
        return owner.balance;
    }
}

你可能感兴趣的:(区块链)