ETH转账合约

淩亂°似流年 2022-10-10 11:29 209阅读 0赞

pragma solidity ^0.4.23;

interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
/**
* owned是合约的管理者
*/
contract owned {
address public owner;

  1. /\*\*
  2. \* 初台化构造函数
  3. \*/
  4. function owned () public \{
  5. owner = msg.sender;
  6. \}
  7. /\*\*
  8. \* 判断当前合约调用者是否是合约的所有者
  9. \*/
  10. modifier onlyOwner \{
  11. require (msg.sender == owner);
  12. \_;
  13. \}
  14. /\*\*
  15. \* 合约的所有者指派一个新的管理员
  16. \* @param newOwner address 新的管理员帐户地址
  17. \*/
  18. function transferOwnership(address newOwner) onlyOwner public \{
  19. if (newOwner != address(0)) \{
  20. owner = newOwner;
  21. \}
  22. \}

}

contract payableTest is owned{

  1. function pay() public payable\{
  2. \}
  3. function getbalance() public view returns(uint)\{
  4. return address(this).balance;
  5. \}
  6. function getThis() public view returns(address)\{
  7. return this;
  8. \}
  9. function getExternalBalance(address account) public view returns(uint)\{
  10. return account.balance;
  11. \}
  12. function transfer(address account ,uint256 amount) public onlyOwner payable\{
  13. account.transfer(amount);
  14. \}
  15. function () public payable\{
  16. \}

}

发表评论

表情:
评论列表 (有 0 条评论,209人围观)

还没有评论,来说两句吧...

相关阅读