9

Problem

I am trying to send some transactions to my private chain, and all transactions are getting failed. I am receiving this error:

Error importing transaction: Transaction(InvalidChainId)

Environment

I am starting a private chain and defined networkID in the genesis file inside params as:

"networkID" : "0xB8A081"

While starting the node, I am specifying the networkID in the toml file as

[network] id = 12099713

After restarting everything, I reconnect metamask to my RPC and then send transaction using remix and metamask.

2
  • Did this work? Im getting same issue when syncing : Error(Transaction(InvalidChainId) Commented Dec 16, 2018 at 17:48
  • 1
    @blockwala Try using a different browser or reinstalling metamask, this issue may be caused because metamask stores chainID in its cache. Commented Dec 18, 2018 at 7:48

3 Answers 3

0

Try to edit the chainId in your genesis files (Use decimal notation) and this format

Format example:

"networkID":123 

(Use no spaces or Quotations "" for chainId)

In toml file:

[network] id = 123 

It worth a try.

0

If transactions were imported from another chain, it may fail due to Ethereum reply-protection feature that prevents using Ethereum Classic transactions to work on Ethereum.

-1

The error Transaction(InvalidChainId) typically indicates that the transaction you're trying to send is targeting a chain with an invalid or mismatched chain ID. This issue often arises when using a private Proof of Authority (POA) blockchain or custom network, where the chain ID must be explicitly set in the transaction.

Here are some steps you can follow to resolve this issue:

1. Check the Network's Chain ID

Ensure that you have the correct chain ID for your private POA network. Each Ethereum-like network has a unique chain ID, and this needs to be specified correctly in the transaction.

To check the chain ID of your private POA network, you can run the following command (if you're using Geth or a similar client):

eth.chainId 

This will return the chain ID of the connected network. Make sure it matches the one you have configured in your transaction.

2. Set the Correct Chain ID in Your Transaction

When you sign a transaction, you need to ensure that the chain ID in the transaction is set to the correct value. If you're using a custom or private network, you'll typically need to set this chain ID manually.

For example, in a web3.js or ethers.js context, you can specify the chain ID like this:

With web3.js:

web3.eth.sendTransaction({ from: senderAddress, to: receiverAddress, value: amount, chainId: 12345 // Replace with your network's chain ID }); 

With ethers.js:

const tx = { to: receiverAddress, value: ethers.utils.parseEther("1.0"), chainId: 12345 // Replace with your network's chain ID }; const response = await signer.sendTransaction(tx); 

3. Verify the Provider Configuration

If you're using a custom provider to connect to your private POA network, make sure the provider is correctly configured with the network's chain ID.

For example, if you're using Web3.js, you might have something like this:

const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); web3.eth.net.getId().then(console.log); // This should print the correct chain ID 

For ethers.js:

const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const chainId = await provider.getNetwork(); console.log(chainId); // Check if this matches your private POA network's chain ID 

4. Check the Node's Network Configuration

If you’re running your own private POA network, verify that your node (Geth, Besu, etc.) is configured to use the correct chain ID. You typically define the chain ID when starting the node:

For Geth:

geth --datadir /path/to/data --networkid 12345 --rpc --rpcapi "db,eth,net,web3,personal,miner" 

For Besu:

besu --network-id=12345 --rpc-http-enabled --rpc-http-api=ETH,NET,WEB3 

Ensure that the --networkid (for Geth) or --network-id (for Besu) matches the chain ID that you're using in your transactions.

5. Confirm the Correct Network in Metamask (if using)

If you’re using Metamask or another wallet, make sure you’ve selected the correct network. The chain ID in the wallet must match the chain ID of the private POA network.

  • Go to Settings > Networks in Metamask.
  • Add a custom network and ensure the Chain ID matches your private POA network’s chain ID.

6. Sync Issues

If your node is not fully synced or there are network issues, this could also cause problems. Make sure the node is fully synced with the network before attempting to send transactions.

By ensuring the chain ID is correct both in your transaction and in the network configuration, the Transaction(InvalidChainId) error should be resolved.

2
  • No ChatGPT on StackExchange site allowed. Commented May 3 at 18:44
  • Hey, appreciate the heads up — but this isn’t from ChatGPT. I put this together myself based on what I've worked with on private chains and contract deployment tracking. Happy to adjust or clarify anything if it’s helpful! Commented May 3 at 19:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.