contract has not been deployed to detected network (network/artifact mismatch) on Rinkeby Network
Solution 1
For me, the following steps worked: create the file 2_deploy_contract.js in the migration folder with the code
var myContract = artifacts.require("myContract");
module.exports = function(deployer){
deployer.deploy(myContract);
}
And run on terminal
$ truffle migrate --reset
I didn't need to change any settings in the truffle-config.js
Solution 2
I had the same issue and created the file 2_deploy_contract.js in the migration folder with the code:
var myContract = artifacts.require("myContract");
module.exports = function(deployer){
deployer.deploy(myContract);
}
I also checked the truffle-config.js at the root of the folder with the default settings:
rinkeby: {
host: "localhost",
port: 8545,
from: "0x0085f8e72391Ce4BB5ce47541C846d059399fA6c", // default address to use for any transaction Truffle makes during migrations
network_id: 4,
gas: 4612388 // Gas limit used for deploys
}
Solution 3
Tl;dr:
- Add a new migration to your migration folder and name it as following:
2_deploy_contract.js
PS: you can name it whatever. 2_deploy_yourmomsdonuts.js would work too. Just pay attention to the number - it has to correspond with the order. 2. Add this code snipper to this file:
Replace HelloWorld with the name of your contract that didn't get deployed (see in your console what contract has thrown an error)
var HelloWorld = artifacts.require('HelloWorld');
module.exports = function (deployer) {
deployer.deploy(HelloWorld);
};
Run
truffle migrate --reset
ortruffle deploy --reset
- These are aliases and do the same thing. You can also run both of them to be on the safe side.You should see that your contract got deployed to your network.
Finally
truffle console
and invoke your function again. Voila.
Why did you have to manually add a migration? The problem was that your smart contract didn't get deployed/did't get recognized so by manually adding your migration, you are telling Truffle which file should get deployed.
Sho0310
Updated on June 23, 2022Comments
-
Sho0310 almost 2 years
I have been running into the specified in the title.
I have developed a smart contract and have successfully compiled and deployed it to the network as follows: 1. Run testrpc 2. truffle compile 3. truffle migrate
However, the error above is still being shown. I then tried deleting the build file and followed the steps below: 1. Run testrpc 2. truffle compile 3. truffle migrate --network rinkeby
The error was still being shown.
Below is the truffle.js file
module.exports = { migrations_directory: "./migrations", networks: { development: { host: "localhost", port: 8545, network_id: "*" // Match any network id }, rinkeby: { host: "localhost", // Connect to geth on the specified port: 8545, network_id: "*", }
} };
If anybody has faced any similar issues and have resolved it, I would greatly appreciate it if you could share how you have resolved it.
Thanks in advance
-
Adam Kipnis over 6 yearsCan you add your full
geth
start command? -
Sho0310 over 6 yearsUpdate: I have just noticed the contract is not getting deployed correctly with testrpc, and I have tried to migrate the contract by running a geth node through:
geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --unlock <ADDRESS>
and I am getting the error below. Running migration: 1_initial_migration.js Deploying Migrations... ... undefined Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: authentication needed: password or unlock @AdamKipnis any idea? -
Adam Kipnis over 6 yearsYou need to use the —password option with geth to unlock the account.
-
Sho0310 over 6 yearsWhen
personal.unlockAccount("Address", "Password")
is run on geth console, it returns true though. And the error still persists -
Sho0310 over 6 yearsUPDATE: I am now getting the error:
Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: insufficient funds for gas * price + value
-
SaganRitual about 6 yearsThis isn't really an appropriate question for the site. You might be ill-treated here. I recommend that you post your question to a site with the word "forum" in the name.
-
-
Ndrslmpk over 2 yearsCan you share how you would deploy a contract with a constructor and its arguments? E.g.,
constructor(address1 _add1, address2 _add2, uint value)
-
Admin about 2 yearsAs it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.