1

I have this error when i use :"truffle migrate --network ropsten"

enter image description here

This is my truffle-config.js: enter image description here

What I want to do is deploy my smart contracts using the same account (address) that I entered on Metamask. Why do I get another address when I deploy? How can I go about using the specific one of Metamask that Ropsten uses?

EDIT I managed to do the migration using, on Metamask, the address indicated in the console and uploading ETH. The problem remains as the account I want to use must be that of a hypothetical user who wants to access my dApp and sign contracts and not the one that Truffle provides you.

2
  • you probably need to get the private key of that account and then use it somehow in the truffle config.. please take care , it is very easy to make an error or expose it and therefore don't use that private key if you have real eth on it.
    – Majd TL
    May 2, 2022 at 13:56
  • He uses the correct mnemonic, you can see the address posted has value in Ropsten chain.
    – Kof
    May 2, 2022 at 16:40

1 Answer 1

0

It looks fine, my guess is that there's an issue with rpcURL.

  1. Double check you're connecting to the correct URL.
  2. Try using https://ropsten.infura.io/, maybe there's an error with your node.
  3. Try replacing the ropsten definition with this -
    ropsten: {
      // must be a thunk, otherwise truffle commands may hang in CI
      provider: () =>
        new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"),
      network_id: '3',
    }
5
  • I checked the rpcURL several times and I don't think this is the problem, also because the migration is done. I don't understand why he keeps using the Truffle address (the one you see in the previous photo) and not the address(of Metamask account) I want to work with.Do you know what the procedure is to use that specific address? I tried using the "from:" keyword but it doesn't work
    – AlexCav
    May 2, 2022 at 18:37
  • The address in the first picture has ether in Ropsten, so I assume the mnemonic is correct and the HD path is too, if it can't see any ether it may have an issue with the node. Did you make sure it's synced? What's the latest block?
    – Kof
    May 2, 2022 at 19:23
  • Yes, but the problem remains as the account I want to use must be an hypothetical user with Metamask who wants to access my dApp and sign contracts and not the one that Truffle provides me(this in the photo).
    – AlexCav
    May 2, 2022 at 19:28
  • 1
    You can export the private key from your MetaMask and place it in truffle config provider: () => new HDWalletProvider({ privateKeys: [pk], providerOrUrl: rpcURL })
    – Kof
    May 3, 2022 at 5:11
  • The answer from Kof is a working one. Jun 14, 2022 at 18:00

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.