Skip to content

Commit 955dd5e

Browse files
contract
1 parent 49462ed commit 955dd5e

File tree

3 files changed

+715
-28
lines changed

3 files changed

+715
-28
lines changed

build_contract.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function readFile(fileName) {
6363
}
6464
function compile(pragma, inputFileName) {
6565
let source = '';
66-
source += 'pragma solidity '+pragma+';';
66+
source += 'pragma solidity ' + pragma + ';';
6767
source += readFile(inputFileName);
6868
return source;
6969
}
@@ -77,20 +77,7 @@ function deploy(source, cb) {
7777
var output = solcSnapshot.compile(source, 1);
7878

7979
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+
9481

9582
let nonce = web3.eth.getTransactionCount(account_address);
9683
let privateKey = new Buffer(account_private, 'hex');
@@ -123,7 +110,7 @@ function deploy(source, cb) {
123110
console.log('Tx check.');
124111
return false;
125112
}
126-
cb && cb(txData);
113+
cb && cb(txData, output.contracts[':Abab'].interface, output.contracts[':Abab'].bytecode,source, solcSnapshot.version());
127114
clearInterval(checkTx);
128115

129116

@@ -132,8 +119,17 @@ function deploy(source, cb) {
132119
});
133120
});
134121
}
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)
137133
});
138134
// console.log(output.contracts[':Abab'].bytecode);
139135
// console.log(output.contracts[':Abab'].interface);

0 commit comments

Comments
 (0)