0

I'm developing contracts with Truffle Suite, using Ganache for tests. I would like to interact with contracts using truffle console. My project is starting from default configuration (truffle init).

I launched Ganache client, truffle migrate, then I'm doing the following:

truffle console
truffle(ganache)> let stor = await Storage.deployed();
Uncaught:
Error: Storage has not been deployed to detected network (network/artifact mismatch)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Function.deployed (/usr/local/lib/node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:83:1)
    at Object.checkNetworkArtifactMatch (/usr/local/lib/node_modules/truffle/build/webpack:/packages/contract/lib/utils/index.js:245:1)
truffle(ganache)> 

(Storage is my contract). What's wrong with deploy? truffle migrate gave me successful deploy:

truffle migrate

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Starting migrations...
======================
> Network name:    'ganache'
> Network id:      5777
> Block gas limit: 6721975 (0x6691b7)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x92c2fa06e4c3128e54a0aabcb713c6adcd2e544a28bb0c7af248f80341960b1f
   > Blocks: 0            Seconds: 0
   > contract address:    0x3E09162B6c7ECC804C5f82E7D91E8391F7f53e4F
   > block number:        1
   > block timestamp:     1623067868
   > account:             0xe1F0955a3A8Fd7ab6de489f5b32b1F70D7917Da9
   > balance:             99.99616114
   > gas used:            191943 (0x2edc7)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00383886 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00383886 ETH


Summary
=======
> Total deployments:   1
> Final cost:          0.00383886 ETH
0

You have to deploy your contract before trying to access it.truffle migrate log shows that you didn't deploy your contract.For that you have add 2_filename.js before deploying

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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