Konubinix' opinionated web of thoughts

Ethereum Local Development Environment

Fleeting

eth local dev env

I have to work on a project using an hardhat node. And I would like to find out what is put in the blockchain. Having a local explorer would be great.

This are the options I could find,

  • ethernal,

    • waaaay tooo complicated. Uses firebase and other stuff that makes it very hard to understand.
  • blockscout,

    • seems promising,
    • but cannot work because of a tracing issue. Even when enabling hardhat-tracer or disabling the tracing, it still complains
  • https://github.com/blockchain-etl/ethereum-etl to extract the data

    • not compatible with python3.11. I don’t want to be forced to downgrade to a too old version of python3.
  • https://github.com/web3labs/chainlens-free

    • admin_nodeInfo - Method not supported
    • eth_getBlockByNumber (5707) and keeps growing
  • navigating using web3.py.

    Using some code like this:

    from eth_account import Account
    Account.enable_unaudited_hdwallet_features()
    a = Account.from_mnemonic(mnemonic)
    
    from web3 import Web3
    w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))
    
    from web3.middleware import construct_sign_and_send_raw_middleware
    w3.middleware_onion.add(construct_sign_and_send_raw_middleware(a))
    
    c = w3.eth.contract("address", abi=json.loads(Path(".../contracts/X.sol/X.json").read_text())["abi"])
    
    c.caller.totalSupply()
    

chainlens and blockscout did not work with hardhat, because apparently some tracing features where missing.

By moving to ganache, chainlens and blockscout worked like a charm.

It was as simple as calling:

ganache --server.host 0.0.0.0 --wallet.mnemonic "${mnemonic}"

To run chainlens, I did.

git clone https://github.com/web3labs/chainlens-free
cd chainlens-free/docker-compose
NODE_ENDPOINT=http://172.17.0.1:8545 docker-compose up

And to run, blockscout,

git clone https://github.com/blockscout/blockscout
cd blockscout/docker-compose
docker-compose -f docker-compose-no-build-ganache.yml up

contract verification

Only blockscout allows to verify the smart contract, so that I can play with it in the browser. That is quite nice.

To do so, I need to flatten it

npx hardhat flatten contracts/X.sol > X.sol

verifying a contract issued by a factory

This is apparently possible with blockscout, but not with ganache

@nisarg2023 it is not currently possible with Ganache. You should run any of these: Erigon, Reth, Geth, Nethermind, OpenEthereum with enabled tracing module.

https://github.com/blockscout/blockscout/issues/8230

finding the correct technology

Ok, so hardhat was to limited to be scanned properly. With ganache, things where better, but I could still find use case that I could not do.

The suggested candidates are

  • Erigon,
  • Reth,
  • Geth,
  • Nethermind,
  • OpenEthereum with enabled tracing module.

I could only make reth work in development mode, and yet I figured out I could not call the increaseTime function.

clarifying what I want

After this exploration, it is time to try to write down what I want.

  1. a blockchain that can:
    1. easily run in single node,
    2. have prefilled accounts with chosen private key (using a mnemonic would be a comfortable addition),
  2. easily move forward in time (like using evm_increaseTime) to test time dependant contracts,
  3. providing the necessary features to be introspected using a block explorer with the features
    1. automatic detection of known contracts (like ERC-20),
    2. possibility to verify the code,

my options

I appears that there is a dichotomy in the ethereum world for now. Blockchains are either production ready and feature-full, but not appropriate for development mode. Or the opposite.

hardhat ganache erigon reth geth nethermind openethereum
evm_increaseTime yes yes no no no no no
easy dev mode yes yes no almost no no no
blockscout no almost yes yes yes yes yes