0

I have the full geth node on my machine and want to deploy my smart contract on ropsten using truffle.

In truffle.js fileI have connected to the node as the following:

ropsten: {

 host: "Localhost",     // Localhost (default: none)
 port: 8545 ,           // Standard Ethereum port (default: none)
 network_id: "*",       // Any network (default: none)
 // from: "",      // Ropsten's id
  // gas: 5500000,        // Ropsten has a lower block limit than mainnet
  // confirmations: 2,    // # of confs to wait between deployments. (default: 0)
  // timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
  // skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
},

In the terminal, I run the node by the following command:

geth --syncmode "fast" --cache=1048 --ropsten --rpc --rpcapi "eth,net,web3" --rpccorsdomain '*' --rpcaddr localhost --rpcport 8545 console

How can I use the funds that in my accounts in Metamask to deploy the contract on truffle?

When I check my accounts balances in geth console, it returns 0 where it has some ether in Metamask Chorome extension

Any help is much appreciated. Thanks

1

Are you trying to deploy your contracts on ropsten network or on your own private geth node.? If you want to deploy to ropsten you can simply use infura's API.

Also If you are trying to deploy from your metamask account.

  • First you need to get your metamask seedphrase from somewhere in metamask's setting
  • Then use @truffle/hdwallet-provider package on truffle-config.js to deploy from your metamask account

How? here is the truffle-config.js file below

const HDWalletProvider = require('@truffle/hdwallet-provider');
const mnemonic = <your mnemonic from metamask>
ropsten: {
  provider: function () {
    return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/<your infura key>")
  },
  network_id: 3, // Ropsten's id
  gas: 7000000, // Ropsten has a lower block limit than mainnet
  confirmations: 2, // # of confs to wait between deployments. (default: 0)
  timeoutBlocks: 200, // # of blocks before a deployment times out  (minimum/default: 50)
  skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
},

PS: make sure that you have deposited some ether in your first account of metamask.

Note: you need to store your mnemonic somewhere safe in config or .env file

  • Thanks for your answer, but infura does not support events. My front end is python with web3.py and it can not listen to many events so for this I have deownloded a full node. I want to deploy on ropsten but without using Infura and instead use the node on my machine – Yamjan Sep 7 '20 at 12:19
  • I did all you mention in your answer but if I would like to listen to more than one events, it says: "RuntimeError: cannot call recv while another coroutine is already waiting for the next message" – Yamjan Sep 7 '20 at 12:22
  • Have you used websocket enpoint of your node to listen/subscribe to contract events? If so, there shouldnt be any problem – MYANZIK shrestha Sep 7 '20 at 14:12
  • yes, my code look like PROVIDER = "wss://ropsten.infura.io/ws/v3/f5000000000000" web3 = Web3(Web3.WebsocketProvider(PROVIDER)) If I run it for more than one event filter, this error raise: RuntimeError: cannot call recv while another coroutine is already waiting for the next message – Yamjan Sep 7 '20 at 14:18
  • Okay, then there should be some bug on your code. - make sure that your code is running asynchronously. - make sure you have instantiated your contract properly and contract exist on blockchaini.e contract-address - make sure that contract have the event - on your contract check your event parameters are indexed if you are filtering based on event topics - – MYANZIK shrestha Sep 7 '20 at 14:38

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.