TransWikia.com

How to use private blockchains in [email protected]?

Ethereum Asked on August 26, 2021

I know this method

var transaction = new Tx(rawTransaction, {chain:'ropsten'});

I tried

var transaction = new Tx(rawTransaction, {chain:'192.168.XX.XX:8545'});

But get Error: Chain with name 192.168.XX.XX:8545 not supported

Any help with this is much appreciated, thank you!

One Answer

You can do this way :

    const EthereumTx = require('ethereumjs-tx').Transaction;
    import Common from 'ethereumjs-common';

        const customCommon = Common.forCustomChain(
        'mainnet',
        {
            name: 'my-private-blockchain',
            networkId: NETWORK_ID,
            chainId: CHAIN_ID,
        },
        'istanbul',
    );

    const tx = new EthereumTx(txParams, { common: customCommon });

With CHAIN_ID and NETWORK_ID numbers.

Here is the full exemple from the official documentation : https://github.com/ethereumjs/ethereumjs-tx/blob/master/examples/custom-chain-tx.ts .

Correct answer by clement on August 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP