forked from kp666/solidity_compiler_helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_compiled.js
2 lines (2 loc) · 2.41 KB
/
test_compiled.js
1
2
function create(abiDefinition) { return web3.eth.contract(abiDefinition);}/*function deploy(account, value, gas, contract, code, input) */function deploy() { var account = arguments[0]; var value = arguments[1]; var gas = arguments[2]; var contract = arguments[3]; var code = arguments[4]; var codeString = "contract.new(inputMarker,{from:'accountMarker', value: valueMarker, data: 'codeMarker', gas: gasMarker}, function (e, contract) { if(!e) { if(!contract.address) { console.log(\"Contract transaction send: TransactionHash: \" + contract.transactionHash + \" waiting to be mined...\"); } else { console.log(\"Contract mined! Address: \" + contract.address); } } else { console.log(e) } })"; codeString = codeString.replace("accountMarker", account); codeString = codeString.replace("valueMarker", value); codeString = codeString.replace("codeMarker", code); codeString = codeString.replace("gasMarker", gas); console.log(codeString); input = "null"; if (arguments.length > 5) { if (arguments[5] != null) { var args = Array.prototype.slice.call(arguments, 5); console.log(args); input = args.join(","); console.log(input); } } codeString = codeString.replace("inputMarker", input); var instance = eval(codeString); return instance;}function watcher(error, result) { if (!error) { console.log("Result"); console.log(JSON.stringify(result)); return; } console.log("Error" + error);}function call(account, gas, func, input) { if (typeof(input)==='undefined') input = null; func.sendTransaction(input, gas, {from:account}, watcher);}function send(from_index, to, value, gas){ return eth.sendTransaction({from:eth.accounts[from_index], to:to, value:web3.toWei(value,'ether'), gas:gas});};
var testCompiled = {"test":{"abi":[{"constant":true,"inputs":[],"name":"data","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[{"name":"a","type":"uint256"}],"type":"constructor"}],"bin":"0x60606040526040516020806053833950608060405251600081905550602c8060276000396000f3606060405260e060020a600035046373d4a13a8114601a575b005b602260005481565b6060908152602090f3","devdoc":{"methods":{}},"userdoc":{"methods":{}}}};testContract = create(testCompiled.test.abi);test = deploy(eth.coinbase,0,400000,testContract,testCompiled.test.bin,null);console.log('Compiled Object : testCompiled');console.log('Contract : testContract');console.log('Contract Instance : test');