Created
October 31, 2015 16:48
-
-
Save zelig/3bedcca13e7188dd086c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////// | |
// deploy a contract | |
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); | |
///////////////////////////////// | |
// deploy contract info | |
admin.stopNatSpec(); | |
filename = "info.json"; | |
contenthash = admin.saveInfo(contract.info, "./" + 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(); | |
// try Natspec | |
admin.startNatSpec(); | |
info = admin.getContractInfo(contractaddress); | |
multiply7 = eth.contract(info.abiDefinition).at(contractaddress); | |
fortytwo = multiply7.multiply.sendTransaction(6, { from: primary }); | |
eth.getNatSpec({from: primary, to: contractaddress, data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}) | |
"will multiply 6 by 7." | |
/////////////////////////////////// | |
// deploy contract info with swarm | |
contenthash = bzz.put(JSON.stringify(contract.info), "application/eth-contractinfo+json"); | |
admin.register(primary, contractaddress, contenthash); | |
miner.start(1); admin.sleepBlocks(1); miner.stop(); // if you are on a private chain self mining | |
admin.startNatSpec(); | |
info = admin.getContractInfo(contractaddress); | |
multiply7 = eth.contract(info.abiDefinition).at(contractaddress); | |
fortytwo = multiply7.multiply.sendTransaction(6, { from: primary }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first time bootstrap on private test network | |
primary = eth.accounts[0]; | |
balance = web3.fromWei(eth.getBalance(primary), "ether"); | |
miner.start(8); admin.sleepBlocks(10); miner.stop() ; | |
primary = eth.accounts[0]; | |
balance = web3.fromWei(eth.getBalance(primary), "ether"); | |
globalRegistrarTxHash = admin.setGlobalRegistrar("0x0"); | |
globalRegistrarTxHash = admin.setGlobalRegistrar("", primary); | |
miner.start(1); admin.sleepBlocks(1); miner.stop(); | |
globalRegistrarAddr = eth.getTransactionReceipt(globalRegistrarTxHash).contractAddress; | |
eth.getCode(globalRegistrarAddr); | |
admin.setGlobalRegistrar(globalRegistrarAddr); | |
registrar = GlobalRegistrar.at(globalRegistrarAddr); | |
hashRegTxHash = admin.setHashReg("0x0"); | |
hashRegTxHash = admin.setHashReg("", primary); | |
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"); | |
// once you got the address of the globalRegistrar, you can simply set everything with: | |
globalRegistrarAddr = "0x65374c69b902749ebe21ba8297fc92ca5481dac7" | |
admin.setGlobalRegistrar(globalRegistrarAddr); | |
registrar = GlobalRegistrar.at(globalRegistrarAddr); | |
admin.setHashReg(""); | |
admin.setUrlHint(""); | |
///// /////////////////////////////// | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment