1

I started my private network with id = 15452:

geth --networkid 15452

Is it possible to get the number inside solidity smart contract?

1

I don't think that's possible because by design there is clear separation between the EVM (turing machine) and the Ethereum network.

In the same manner as a virtual machine on your PC, it is sandboxed and isolated from the network, whilst still being a part of it. This isolation is what makes it impervious to hack attacks and corruption, essentially fortifying it.

However, you could simply do this in the contrat

pragma solidity ^0.5.2;

contract MyContract {
    uint networkid;

    constructor(uint _networkid) public {
        networkid = _networkid;
    }
}

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.