0

i'm trying to call a function from contract that i deployed to kovan network, then when i used the truffle console --network kovan and tried to deploy my contract, it says that this contract has not been deployed to detected network but it's already deployed and even use it in my web3 app.

truffle(kovan)> const daiToken = await DaiToken.deployed()
Uncaught:
Error: DaiToken has not been deployed to detected network (network/artifact mismatch)

My contract on etherscan kovan: https://kovan.etherscan.io/address/0x478A24D4CcbFedE653D6aeE3DC202663e4ba2Be0

netowrk configuration at truffle-config.js:

 kovan: {
      provider: () => new HDWalletProvider(MNEMONIC, endpointUrl),
      network_id: 42,       
      gas: 5500000,        
      confirmations: 2, 
      timeoutBlocks: 200,
      networkCheckTimeoutnetworkCheckTimeout: 10000,
      skipDryRun: true 
    }

1 Answer 1

0

If the token is already deployed.

Use await DaiToken.at(ADDRESS_HERE); inside your code. Where for ADDRESS_HERE substitute it with the contract address where DaiToken was deployed to on kovan.

For example in my code:

const Router = artifacts.require('uniswapv2/UniswapV2Router02.sol');
...
const router = await Router.at('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'); // Kovan Uniswap V2 Router

This would get the Router instance that is deployed at that address

1
  • Yes, worked.. there is no way to deploy it again when i elready deployed it i just have to use its contract adress. thank's. Commented Apr 5, 2022 at 10:14

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.