@@ -63,7 +63,7 @@ function readFile(fileName) {
63
63
}
64
64
function compile ( pragma , inputFileName ) {
65
65
let source = '' ;
66
- source += 'pragma solidity ' + pragma + ';' ;
66
+ source += 'pragma solidity ' + pragma + ';' ;
67
67
source += readFile ( inputFileName ) ;
68
68
return source ;
69
69
}
@@ -77,20 +77,7 @@ function deploy(source, cb) {
77
77
var output = solcSnapshot . compile ( source , 1 ) ;
78
78
79
79
var browser_untitled_sol_ababContract = web3 . eth . contract ( JSON . parse ( output . contracts [ ':Abab' ] . interface ) ) ;
80
- console . log ( source ) ;
81
-
82
- console . log ( output . contracts [ ':Abab' ] . bytecode ) ;
83
- // var browser_untitled_sol_abab = browser_untitled_sol_ababContract.new(
84
- // {
85
- // from: web3.eth.accounts[0] || account_address,
86
- // data: '0x' + output.contracts[':Abab'].bytecode,
87
- // gas: '4300000'
88
- // }, function (e, contract) {
89
- // console.log(e, contract);
90
- // if (typeof contract.address !== 'undefined') {
91
- // console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
92
- // }
93
- // });
80
+
94
81
95
82
let nonce = web3 . eth . getTransactionCount ( account_address ) ;
96
83
let privateKey = new Buffer ( account_private , 'hex' ) ;
@@ -123,7 +110,7 @@ function deploy(source, cb) {
123
110
console . log ( 'Tx check.' ) ;
124
111
return false ;
125
112
}
126
- cb && cb ( txData ) ;
113
+ cb && cb ( txData , output . contracts [ ':Abab' ] . interface , output . contracts [ ':Abab' ] . bytecode , source , solcSnapshot . version ( ) ) ;
127
114
clearInterval ( checkTx ) ;
128
115
129
116
@@ -132,8 +119,17 @@ function deploy(source, cb) {
132
119
} ) ;
133
120
} ) ;
134
121
}
135
- deploy ( source , function ( tx ) {
136
- console . log ( 'Deploy Contract Success:\n\tAddress: ' + tx . contractAddress + '\n\tBlockHash: ' + tx . blockHash + '\n\tblockNumber: ' + tx . blockNumber )
122
+ deploy ( source , function ( tx , _interface , _bytecode , source , solc_version ) {
123
+ fs . writeFile ( "./source.sol" , source ) ;
124
+ fs . writeFile ( "./config.sol.js" , 'const _address = "' + tx . contractAddress + '"; // smart contract address\n' +
125
+ 'const _contract_fixed = 100000000;\n' +
126
+ 'const _name = "Abab";\n' +
127
+ 'const _symbol = "ABC";\n' +
128
+ 'const _abi = ' + _interface + ';\n' +
129
+ 'const _bytecode = "' + _bytecode + '";\n' +
130
+ 'const _version = "' + solc_version + '";\n' +
131
+ 'module.exports = {_address: _address,_contract_fixed: _contract_fixed,_name: _name,_symbol: _symbol,_abi: _abi,_bytecode:_bytecode,_version:_version};' ) ;
132
+ console . log ( 'Deploy Contract Success:\n\tAddress: ' + tx . contractAddress + '\n\tBlockHash: ' + tx . blockHash + '\n\tblockNumber: ' + tx . blockNumber )
137
133
} ) ;
138
134
// console.log(output.contracts[':Abab'].bytecode);
139
135
// console.log(output.contracts[':Abab'].interface);
0 commit comments