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!
Commands:
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()
Thrown:
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)
truffle(development)>
Why I'm getting above error? How can I fix this?