3. 手動編譯(using geth)
• connect to console
• set up a chain
• connect to main chain:go-ethereum/build/bin/geth console
• connect to testnet:go-ethereum/build/bin/geth --testnet console
• build a private net:go-ethereum/build/bin/geth --datadir
“your_directory" --rpc --rpcport port --rpccorsdomain "*" --port
"30303" --nodiscover --ipcapi
"admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi
"db,eth,net,web3" --autodag --networkid number --nat "any"
console
4. 手動編譯(using geth)
• in console
• var contractABI = web3.eth.contract([{contractABI}]);
• var contract123 = contractABI.new(
parameters,
{from: address,
data: bytecode,
gas: gas
}, callback_function)
45. 可能危險
• throw when address.send() fails
• why address.send() fail?
• 1. out of gas
• supply enough gas
• 2. callstack
• 1024 layer
46. 可能危險
• throw when address.send() fails
• use a withdraw pattern
• still, this solution leaves the problems mentioned to the msg
sender
function withdraw(amount) {
if( balances[msg.sender] >= amount ) {
msg.sender.send(amount);
balances[msg.sender] -= amount;
}
}
47. 可能危險
• shared state between external call and external callable functions
function extCall() {
…
external_call();
…
if(shared_state) {
…
}
…
}
function extCallable(){
do_something_on_shared_state…
}
48. 可能危險
• state corruption
• 1. sum of sizes of 1st and 2nd state variables are less than 256
bytes
• 2. first variable is not a signed interger or bytesXX type
function extCall() {
uint32 a;
uint32 b;
function run() returns(uint32){
a--;
return b;
}
}
fixed after compiler version 0.4.4