-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the new wiki!
git init git add README.md git commit -m "first commit" git remote add origin [email protected]:chiachia12121/new2.git git push -u origin master
var _greeting = "Hello World!" var greeterContract = web3.eth.contract(greeterCompiled.greeter.info.abiDefinition);
var greeter = greeterContract.new(_greeting,{from:web3.eth.accounts[0], data: greeterCompiled.greeter.code, gas: 300000}, function(e, contract){ if(!e) { geth --maxpeers 0 --networkid 123456 --nodiscover --unlock primary js script.js 2>> geth.log
personal.newAccount("")
primary = eth.accounts[0]; balance = web3.fromWei(eth.getBalance(primary), "ether"); personal.unlockAccount(primary, "00"); // miner.setEtherbase(primary)
miner.start(8); admin.sleepBlocks(10); miner.stop() ;
// 0x2705a23b6dc59cab2f0B7489cf85d8089f50310 primary = eth.accounts[0]; balance = web3.fromWei(eth.getBalance(primary), "ether");
globalRegistrarTxHash = admin.setGlobalRegistrar("0x0"); //'0x0' globalRegistrarTxHash = admin.setGlobalRegistrar("", primary); //'432726590c01b981414280af64ba7aff0bi1be5a66beed383f98e6' miner.start(1); admin.sleepBlocks(1); miner.stop(); //true globalRegistrarAddr = eth.getTransactionReceipt(globalRegistrarTxHash).contractAddress; //'0x2705a23b6dc59cab2f0B7489cf85d8089f50310' eth.getCode(globalRegistrarAddr); //... admin.setGlobalRegistrar(globalRegistrarAddr); registrar = GlobalRegistrar.at(globalRegistrarAddr);
hashRegTxHash = admin.setHashReg("0x0"); hashRegTxHash = admin.setHashReg("", primary); txpool.status miner.start(1); admin.sleepBlocks(1); miner.stop(); hashRegAddr = eth.getTransactionReceipt(hashRegTxHash).contractAddress; eth.getCode(hashRegAddr);
registrar.reserve.sendTransaction("HashReg", {from:primary}); registrar.setAddress.sendTransaction("HashReg",hashRegAddr,true, {from:primary}); miner.start(1); admin.sleepBlocks(1); miner.stop(); registrar.owner("HashReg"); registrar.addr("HashReg");
urlHintTxHash = admin.setUrlHint("", primary); miner.start(1); admin.sleepBlocks(1); miner.stop(); urlHintAddr = eth.getTransactionReceipt(urlHintTxHash).contractAddress; eth.getCode(urlHintAddr);
registrar.reserve.sendTransaction("UrlHint", {from:primary}); registrar.setAddress.sendTransaction("UrlHint",urlHintAddr,true, {from:primary}); miner.start(1); admin.sleepBlocks(1); miner.stop(); registrar.owner("UrlHint"); registrar.addr("UrlHint");
globalRegistrarAddr = "0x2705a23b6dc59cab2f0B7489cf85d8089f50310" admin.setGlobalRegistrar(globalRegistrarAddr); registrar = GlobalRegistrar.at(globalRegistrarAddr); admin.setHashReg(""); admin.setUrlHint("");
///// ///////////////////////////////
admin.stopNatSpec(); primary = eth.accounts[0]; personal.unlockAccount(primary, "00")
globalRegistrarAddr = "0x2705a23b6dc59cab2f0B7489cf85d8089f50310"; admin.setGlobalRegistrar(globalRegistrarAddr); registrar = GlobalRegistrar.at(globalRegistrarAddr); admin.setHashReg("0x0"); admin.setHashReg(""); admin.setUrlHint("0x0"); admin.setUrlHint("");
registrar.owner("HashReg"); registrar.owner("UrlHint"); registrar.addr("HashReg") registrar.addr("UrlHint");
///////////////////////////////////// eth.getBlockTransactionCount("pending"); miner.start(1); admin.sleepBlocks(1); miner.stop();
source = "contract test {\n" +
" /// @notice will multiply a
by 7.\n" +
" function multiply(uint a) returns(uint d) {\n" +
" return a * 7;\n" +
" }\n" +
"} ";
contract = eth.compile.solidity(source).test;
txhash = eth.sendTransaction({from: primary, data: contract.code});
eth.getBlock("pending", true).transactions;
miner.start(1); admin.sleepBlocks(1); miner.stop(); contractaddress = eth.getTransactionReceipt(txhash).contractAddress; eth.getCode(contractaddress);
multiply7 = eth.contract(contract.info.abiDefinition).at(contractaddress); fortytwo = multiply7.multiply.call(6);
/////////////////////////////////
// register a name for the contract registrar.reserve.sendTransaction(primary, {from: primary}); registrar.setAddress.sendTransaction("multiply7", contractaddress, true, {from: primary}); ////////////////////////
admin.stopNatSpec(); filename = "/info.json"; contenthash = admin.saveInfo(contract.info, "/tmp" + filename); admin.register(primary, contractaddress, contenthash); eth.getBlock("pending", true).transactions; miner.start(1); admin.sleepBlocks(1); miner.stop();
admin.registerUrl(primary, contenthash, "file://" + filename); eth.getBlock("pending", true).transactions; miner.start(1); admin.sleepBlocks(1); miner.stop();
////////////////////
// retrieve contract address using global registrar entry with 'multply7' contractaddress = registrar.addr("multiply7); // retrieve the info using the url info = admin.getContractInfo(contractaddress); multiply7 = eth.contract(info.abiDefinition).at(contractaddress); // try Natspec admin.startNatSpec(); fortytwo = multiply7.multiply.sendTransaction(6, { from: primary });
if(!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
}
})