I'm following the steps in this link to create a truffle project. I'm using ganache-cli as the ethereum client.

    rajkumar@rajkumar: Ethereum$ mkdir helloworld
    rajkumar@rajkumar: Ethereum$ cd helloworld/
    rajkumar@rajkumar: helloworld$ sudo truffle init

    ✔ Preparing to download
    ✔ Downloading
    ✔ Cleaning up temporary files
    ✔ Setting up box

    Unbox successful. Sweet!


    Compile:        truffle compile
    Migrate:        truffle migrate
    Test contracts: truffle test

    rajkumar@rajkumar: helloworld$ truffle create contract HelloWorld
    rajkumar@rajkumar: helloworld$ sudo truffle create contract HelloWorld

Then I updated the smart contract with the one in here.

    rajkumar@rajkumar: helloworld$ sudo truffle create migration HelloWorld
    rajkumar@rajkumar: helloworld$ sudo truffle migrate --network development
    [sudo] password for rajkumar:                                                                                                      

    Compiling your contracts...
    > Compiling ./contracts/HelloWorld.sol
    > Artifacts written to /home/rajkumar/Coding/Ethereum/helloworld/build/contracts
    > Compiled successfully using:
    - solc: 0.5.8+commit.23d335f2.Emscripten.clang

    Network up to date. 
    rajkumar@rajkumar: helloworld$ sudo truffle console
    truffle(development)> let instance = await HelloWorld.deployed()
    Error: HelloWorld has not been deployed to detected network (network/artifact mismatch)
        at processTicksAndRejections (internal/process/task_queues.js:85:5)
        at Function.deployed (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/contract/constructorMethods.js:61:1)
        at Object.checkNetworkArtifactMatch (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/utils.js:256:1)

Why I'm getting above error? How can I fix this?

4 Answers 4


in your HelloWorld migration file from migrate folder you should open it and by the tutorial add this:

var HelloWorld = artifacts.require('HelloWorld');

module.exports = function(deployer) {
  // Use deployer to state migration tasks.

you should read the truffle document for more detail: https://www.trufflesuite.com/docs/truffle/getting-started/running-migrations.


It looks like you deployed to the development network but are running truffle console with the default network, so assume that these are different.

You should deploy and use the console on the same network.

truffle migrate --network development
truffle console --network development

As an aside, you shouldn't have to use sudo. You may want to consider installing packages locally.
I only have ganache-cli installed globally.


Here is an example:

var BlockFinanceToken = artifacts.require("BlockFinanceToken.sol");

//function that is called through the deploy contract migration
//deployer is given by the truffle. deployer is the handler that
//provides handle to the blockchain.
//create initial token of the following number. This can the be the 
number of gift card vouchers
module.exports = async function (deployer) {
await deployer.deploy(BlockFinanceToken, 100000);

In the migrate folder create a file called 2_deploy_contracts.js

file contents are:

var HelloWorld = artifacts.require("HelloWorld.sol");

module.exports = function(deployer) {



and run the migrate

$ truffle migrate

type $ truffle console , hit enter

the type

"HelloWorld.deployed().then(function(instance) {return instance});"

then hit enter

along with that you can also type

"HelloWorld.deployed().then(function(instance) {return instance.getHelloMessage()});"

and then hit enter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.