# Solidity 書籍修改 2-9 2-9 Payable Address  使用範例改成如下 ```solidity= // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract Withdraw { // msg.sender: 呼叫此函式的"錢包"或"合約"地址 // 初始化合約的同時,並匯入 ETH // 5-6 章節有介紹 constructor() payable {} function withdrawByTransfer() public { payable(msg.sender).transfer(1 ether); } function withdrawBySend() public { bool success = payable(msg.sender).send(1 ether); require(success); } function withdrawByCall() public returns (bytes memory) { (bool success, bytes memory result) = payable(msg.sender).call{value: 1 ether}(""); require(success); return result; } } ``` 3-3 Block Time  使用範例改成如下 ```solidity= // SPDX-License-Identifier: GPL-3.0 contract BlockTime { // 全部都是回傳秒數 uint256 public second = 1 seconds; uint256 public minute = 1 minutes; uint256 public hour = 1 hours; uint256 public day = 1 days; // 訪問當前區塊時間 function getBlockTime() public view returns (uint256) { return block.timestamp; } } ``` 2-2 Integer  使用範例改成如下 ```solidity= // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract MyInt { uint256 public myUint = 566778778787; uint32 public myUint32 = 4294967295; uint16 public myUint16 = 65535; uint8 public myUint8 = 256; int256 public myInt = -566778778787; int32 public myInt32 = -2147483648; int16 public myInt16 = -32768; int8 public myInt8 = -128; // 兩種表示最大值的方式 uint8 public uint8_max = 2**8 - 1; uint8 public uint8_min = 0; int8 public int8_max = type(int8).max; int8 public int8_min = type(int8).min; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up