Unable to deploy to live network - "Contract transaction couldn't be found after 50 blocks"
See original GitHub issue- [True ] I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
I’ve successfully deployed my test contract to TestRpc as well as a private blockchain, but I’m having immense difficulty actually deploying to the live network. I asked for advice on gittr but nobody on at the time had any advice.
What makes it more peculiar is that there were a few instances where the deploy process did seem to create the Migrations contract (as visible here https://etherscan.io/address/0x0f045791e6a0b1135eff7c3a7fb8092858846d4f) and in a few cases it looks like it deployed the Migrations contract multiple times without deploying the subsequent contract.
The contract compiles without complaint but when I try to deploy to the live network, it hangs and eventually returns Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: Contract transaction couldn’t be found after 50 blocks.
I’ve since pared the contract down to the simplest possible function and still have the same issue.
Any help would be greatly appreciated.
Steps to Reproduce
###Migrations.sol
pragma solidity ^0.4.2;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
function Migrations() {
owner = msg.sender;
}
function setCompleted(uint completed) restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}```
###TradeAuthTest.sol
```pragma solidity ^0.4.4;
contract TradeAuthTest {
mapping (address => uint) AccountBalances;
address owner;
event _FallbackTriggered(
address Sender,
uint WeiSent
);
function TradeAuthTest() public {
owner = msg.sender;
AccountBalances[0x7c9d3507a77C8a732ee396BA8036bE05891E3646] = 50;
AccountBalances[0xC064a245206f780500393aF49692b9c47FeFe139] = 50;
}
function Disburse() payable public returns (bool) {
if(msg.sender == owner){
address a = 0x7c9d3507a77C8a732ee396BA8036bE05891E3646;
address b = 0xC064a245206f780500393aF49692b9c47FeFe139;
a.transfer(5000);
b.transfer(5000);
return true;
}
}
function DestroyContract() external returns(bool){
if(msg.sender == owner){
selfdestruct(owner);
}
}
function() payable public {
_FallbackTriggered(msg.sender, msg.value);
}
}
1_initial_migration.js
var Migrations = artifacts.require("../contracts/Migrations.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
2_deploy_contracts.js
var TradeAuthTest = artifacts.require("../TradeAuthTest.sol");
module.exports = function(deployer) {
deployer.deploy(TradeAuthTest);
};
truffle.js
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "default"
},
live: {
network_id: 1,
port: 8546,
host: "localhost",
gasPrice: 10000000000,
gas: 700000
},
ropsten: {
host: "localhost",
port: 8547,
network_id: "3"
}
}
};
geth --rpcport 8546 --unlock '0x0f045791E6a0b1135eFF7C3A7FB8092858846D4f' --rpc --rpcapi "eth,net,web3"
truffle compile
truffle deploy --network live
Expected Behavior
I would expect the contract to deploy.
Actual Results
user@ethboxlinux:~/code/TestDeploymentContract$ truffle migrate --network live
Using network 'live'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0xd3e5345b304fae4b4d1edfef30c5a86a96ae91c98fbe902c9004e16353fb20bb
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract transaction couldn't be found after 50 blocks
at /home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:222795:30
at /home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:59995:21
at Array.forEach (<anonymous>)
at /home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:59994:32
at Array.forEach (<anonymous>)
at Object.onMessage [as callback] (/home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:59992:22)
at /home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:224938:20
at Array.forEach (<anonymous>)
at /home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:224937:12
at /home/user/.nvm/versions/node/v9.0.0/lib/node_modules/truffle/build/cli.bundled.js:66971:11
## Environment
* Operating System: Ubuntu 17.10
* Truffle version: v3.4.9
* Ethereum client: geth 1.7.2-stable-1db4ecdc
* node version: v9.0.0
* npm version: 5.5.1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:33 (9 by maintainers)
@faizanahmad055 This is a chronic problem everyone is facing using
web3
given current network conditions. The only known solution is to increase thegasPrice
of the transaction to make it more attractive for miners to pick up, or to wait for periods of low network congestion to deploy.The error is a hard-coded limit in web3 whose intent is to stop transactions from hanging indefinitely.
Also important to note is that while web3 and truffle crash here - your transaction has still been transmitted and may actually be mined at some point. You can grab the transaction hash from the output and check its status on Etherscan to see what it’s actual status is
We’re quite close to publishing a re-write of the migrations command that will end-run this error and allow you to set an arbitrary number of blocks to wait for a transaction. Will ping this issue when that work is available in beta form. . .
now I fixed the issue by omitting
gasPrice
and keepinggas
but with higher value