I'm using Parity ( "ropsten" test net), Nodejs and web3js to deploy smart contract from my system. Parity is synchronised in test mode, but when I run below code using Nodejs, it gave me a transaction id "https://ropsten.etherscan.io/tx/0xa229e52224e7200337aa7893fea71c83e79cd5b2b37234a1559d9e6a7512385d", but when I verified this transaction on etherscan ropsten testnet, then I found that transaction not mined by etherscan. Not sure why transaction not moved from my local "Parity" node to etherscan.
Any help would be appreciated.
var Web3 = require('web3');
let fs = require("fs");
var solc = require('solc');
if( typeof Web3.currentProvider !== 'undefined'){
web3 = new Web3( Web3.currentProvider );
}else{
web3 = new Web3( new Web3.providers.HttpProvider("http://localhost:8545"));
}
async function deployContract(){
var address = await web3.eth.getAccounts()
var contractAdminAddrs = address[2]
console.log("Contract deployed from: "+contractAdminAddrs);
var input = {
//'IERC20.sol': fs.readFileSync('IERC20.sol', 'utf8'),
//'SafeMath.sol': fs.readFileSync('SafeMath.sol', 'utf8'),
'Distribution.sol': fs.readFileSync('Distribution.sol', 'utf8')
};
let compiledContract = await solc.compile({sources: input}, 1);
//console.log(compiledContract);
//return false;
let abi = compiledContract.contracts['Distribution.sol:Distribution'].interface;
let bytecode = '0x'+compiledContract.contracts['Distribution.sol:Distribution'].bytecode;
console.log("Contract Deployment Gas Estimate=")
var gasEstimate = web3.eth.estimateGas({
to: contractAdminAddrs,
data: bytecode
}).then(console.log)
let Token = new web3.eth.Contract(JSON.parse(abi));
console.log("ABI");
console.log(abi);
//return false;
//var gasEstimate = 4500000; //Default gas
var gas_Estimate = 4500000 //Calculated from above function,used static
var gasPrice = 30000000000;
var lms = Token.deploy(
{data:bytecode,arguments:[contractAdminAddrs]})
.send({
from: contractAdminAddrs,
gas: gas_Estimate,
gasPrice: gasPrice
},
function(error, transactionHash){
console.log("send function error=")
console.log(error)
console.log("transactionHash=")
console.log(transactionHash)
})
.on('error', function(error){
console.log("contract deploy error=")
console.log(error)
})
.on('transactionHash', function(transactionHash){
console.log("transactionHash 2nd function=")
console.log(transactionHash)
})
.on('receipt', function(receipt){
console.log("Receipt=")
console.log(receipt.contractAddress) // contains the new contract address
})
.on('confirmation', function(confirmationNumber, receipt){
console.log("Confirmation Number=")
console.log(confirmationNumber)
})
.then(function(newContractInstance){
console.log("New Contract address=")
console.log(newContractInstance.options.address) // instance with the new contract address
});
}
//Call function to deploy contract
deployContract()