0

I am using truffle console to deploy contracts and using Nodejs/web3js to interract with it. I wanted to use ethereumjs-tx for signing transaction, here is the reference link. I am not sure ,how can i find chain id and network id of local blockchain which i need to create rawtransaction. i.e

const customCommon = Common.forCustomChain(
  'randomchainNmae',
  {
    name: 'my-network',
    networkId: ???,
    chainId: ???,
  },
  'petersburg',
)
  • networkId and chainId are the same thing AFAIK. And it's not on Truffle side, but on Ganache side (or whatever you're using as a blockchain provider). On Truffle side you can filter specific network IDs via the Truffle configuration file (truffle.js or truffle-config.js). But the configuration of the actual ID is on the provider side. For example, if you ARE using Ganache, then you can use -i or --networkId in order to specify the network id that ganache-cli will use to identify itself (see here). – goodvibration Oct 10 at 8:14
  • 1
    You can probably also obtain it programmatically from the web3 instance which you're initializing in your script. – goodvibration Oct 10 at 8:15
  • 1
    With web3 v1.0 the following works web3.eth.net.getId(). – Ismael Oct 10 at 16:28

Your Answer

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

Browse other questions tagged or ask your own question.