0

I am trying to interact with a simple solidity contract using MetaMask. I can run truffle migrate and run the front-end with no trouble but when I try to interact I get the error:

Unhandled Rejection (Error): This contract object doesn't have address set yet, please set an address first.

I was told I need to change my network as the issue relates to chain id or network id with Ganache. I've tried changing the network ID in Ganache and setting up the network in MetaMask, but then I can't migrate my contracts in truffle anymore error message:

Error: The network id specified in the truffle config (5777) does not match the one returned by the network (1337). Ensure that both the network and the provider are properly configured.

I tried then to add some configuration settings in the truffle-config file, including specifying the correct network and creating a new network and specifying it when migrating, but also no luck.

Another potential solution I have found was to run ganache-cli with specific network and chain Id, which I have tried however I don't know how to migrate my contracts to that network.

When I run truffle migrate it looks for 5777 every time but I need it to deploy to 1337. No idea how to change it. This is all very new to me so I hope it is something simple that I don't understand yet.

Any advice would be great, thanks

3
  • Hello KaneLawless! Welcome to Ethereum Stackexchange! Please include your truffle-config file, the ganache-cli command line used. The truffle command has a --network <NETWORK> option that allows to select the network. You have to make sure the network id is the same in metamask, ganache and truffle.
    – Ismael
    Aug 4, 2021 at 4:23
  • 1
    Hi Ismael, I actually managed to solve the issue eventually. I had not specified the host. With the develop network it wasn't necessary to specify a host and I had been using that network setup as a guideline for my own. Aug 5, 2021 at 13:43
  • Great! It would be nice if you can add the solution as an answer so it can helps others in similar situation and the question be marked as resolved.
    – Ismael
    Aug 5, 2021 at 15:43

1 Answer 1

2

I actually managed to solve the issue eventually.

  • I had not specified the host

. With the develop network it wasn't necessary to specify a host and I had been using that network setup as a guideline for my own.

Your Answer

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

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