I am trying to deploy a contract in Ethereum testnet, with the web3 API via my geth node. The contract is deployed correctly and I can see the address in geth and verify it exists on etherscan. However I can't get the contract address working in my javascript. My code is:
var myContractReturned = web3.eth.contract(abi).new({data: code,gas:500000}, function (err, contract) {
if(err) {
console.error(err);
return;
} else if(contract.address){
console.log('ContractAddress: ' + contract.address);
document.getElementById('status').innerText = 'Mined!';
}else{
console.log('ContractAddress: ' + contract.address);
}
});
In the If statement the only part that is executed is the "else" and contract.address returns undefined.
Waiting a mined block to include your contract... currently in block 587791and then the next block 587792, 587793 and so on. This happens indefinitely. – PetrosM Mar 04 '17 at 13:06console.log(web3.eth.getTransactionReceiptMined(txnHash.transactionHash));gets stuck at [[PromiseStatus]] : "Pending" and never changes. I just added thegetTransactionReceiptMinedfunction and added the console log command above. Am I doing anything wrong? Note that I am usingtxnHash.transactionHashbecause I changed the contract to txnHash like you indicated above – PetrosM Mar 04 '17 at 18:14geth --rpc --rpcapi="db,eth,net,web3,personal,web3" --rpcaddr="localhost" --rpcport="8545" --rpccorsdomain="http://localhost:3000" --testnetI read somewhere about another attack on ropsten might be happening now. Is this the case? – PetrosM Mar 05 '17 at 10:12