4. 技術演進
拜占庭將軍問題 (Byzantine Generals Problem) -- 1982, L. Lamport, R. Shostak, M. Pease
eCash -- 1990, David Chaum
時間戳數位文件安全 --1991, Stuart Haber, W. Scott Stornetta
橢圓曲線數位簽章演算法 -- 1992, Don Johnson, Alfred Menezes, Scott Vanstone
Hashcash (工作量證明機制 Proof of Work, PoW) -- 1997, Adam Back
B-money -- 1998, Wei Dai
Bit Gold (去中心化) -- 1998, Nick Szabo
可重複使用的工作量證明機制 (Reusable Proofs of Work,RPoW) -- 2005, Hal Finney
比特幣 -- 2008, 中本聰
21. 資料型別
實值型別
bool
int / int256, uint
uint constant HEX_NUM = 0x123A1;
address
20 byte value (size of an Ethereum address)
bytesN (1 <= N <= 32)
fixed-size byte arrays
常數修飾詞
constant
參考型別
string
implicitly convertible to bytesN
UTF-8 supported
Arrays (if T is a value type)
T[] t; // Dynamic-length array
T[N] t; // N-length array
T[N][M] t; // M x N array (there is M T[N])
Mappings
mapping (Ktype => Vtype) myMap;
K can be almost any type except mapping
V can be any type
if K does not exist, V is zero
in fatct, it uses sha3(K) to look up its value
23. 參考型別 & 自訂型別
參考型別:Structs
struct Bank
{
address owner;
uint balance;
}
Bank bank
= Bank
({
owner:
"0x692a70d2e424a56d2c6c27aa97d1a86395877b3a",
balance: 5
});
自訂型別
enums
enum Direction { Left, Right, Up, Down }
Direction myDirection = Direction.Up;
24. 其他型別
全域變數
block
block.blockhash(uint blockNumber) returns (bytes32)
block.coinbase // miner's address
block.gaslimit // current block gaslimit
block.number // current block number
block.timestamp // current block time (before commit)
msg
msg.sender // sender of the message (current call)
msg.value // how much wei sent with the message
tx
tx.origin // sender of the transaction (full chain call)
now
alias for block.timestamp
型別轉換
隱含轉換
uint8 -> uint16 (O)
int8 -> int16 (O)
int8 -> uint8 (X)
明確轉換
int8 y = -3; uint x = uint(y); // x is now 0xfffff..fd
uint32 a = 0x12345678; uint16 b = uint16(a); // b is now 0x5678