EthTx / ethtx

Python package with core transaction decoding functions.
https://www.ethtx.info
Apache License 2.0
454 stars 73 forks source link

No module named 'ethtx.semantics' #135

Closed yuripaoloni closed 2 years ago

yuripaoloni commented 2 years ago

Windows 10. Python version 3.10.4. Latest version for ethtx is installed with pip install ethtx.

I created a file test.py with the following content:

from ethtx import EthTx, EthTxConfig
from ethtx.models.decoded_model import DecodedTransaction

ethtx_config = EthTxConfig(
    etherscan_api_key="my etherscan API key",  ##Etherscan API key,
    web3nodes={
        "mainnet": {
            "hook": "my Infura url",  # multiple nodes supported, separate them with comma
            "poa": False  # represented by bool value
        }
    },
    default_chain="mainnet",
    etherscan_urls={"mainnet": "https://api.etherscan.io/api" }
)

ethtx = EthTx.initialize(ethtx_config)
transaction: DecodedTransaction = ethtx.decoders.decode_transaction(
    '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d')

Once I try to execute the file with py test.py, I get the following error:

Traceback (most recent call last):
  File "C:\Users\Utente\Desktop\ethtx\test.py", line 1, in <module>
    from ethtx import EthTx, EthTxConfig
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\__init__.py", line 13, in <module>
    from .ethtx import EthTx, EthTxConfig
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\ethtx.py", line 18, in <module>
    from .decoders.abi.decoder import ABIDecoder
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\decoders\abi\decoder.py", line 32, in <module>
    from .abc import IABIDecoder
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\decoders\abi\abc.py", line 25, in <module>
    from ethtx.providers.semantic_providers import SemanticsRepository
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\providers\semantic_providers\__init__.py", line 15, in <module>
    from .repository import SemanticsRepository
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\providers\semantic_providers\repository.py", line 30, in <module>
    from ethtx.semantics.protocols_router import amend_contract_semantics
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\semantics\protocols_router.py", line 21, in <module>
    def amend_contract_semantics(semantics: ContractSemantics, router_=Router()):
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\semantics\router.py", line 30, in __new__
    return cls._get_semantics()
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\ethtx\semantics\router.py", line 52, in _get_semantics
    imported_module = importlib.import_module(
  File "C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'ethtx.semanticsC:\\Users\\Utente\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\ethtx\\semantics\\base'

What's the issue? Thanks for the help.

kchojn commented 2 years ago

Hey @yuripaoloni. We do not support windows os. It is not tested there. But... you can try it:

yuripaoloni commented 2 years ago

Yeah, I tried with venv and already checked for ethtx installed in it.

I didn't notice the package it wasn't supported on Windows, sorry for that. I will use an Ubuntu VM.

Thank you for the fast response.

kchojn commented 2 years ago

Np! Let us know if there is anything else we can help with!

yuripaoloni commented 2 years ago

Any update on #18? Is archivenode.io the only option to get a full node with debugging on for free?

I need to get the internal execution trace of a set of transactions to run some analytics on top of them.

kchojn commented 2 years ago

Hey @yuripaoloni, Sorry for the late reply. To be honest, at this moment I don't see any free other archive nodes for Ethereum. There are some paid alternatives, but I don't know what the cost is: getblock.io or quicknode.com

Regards!

enmohsinali commented 2 years ago

Hey @yuripaoloni, getblock.io provides full node which kept historical state of last 64 blocks. So if you wanna decode latest transaction then getblocks might be helpful .

yuripaoloni commented 2 years ago

Thanks @enmohsinali.

I tried with the following code:

from ethtx import EthTx, EthTxConfig
from ethtx.models.decoded_model import DecodedTransaction

ethtx_config = EthTxConfig(
    mongo_connection_string="mongomock://localhost/ethtx",  ##MongoDB connection string,
    etherscan_api_key="<apikey>",  ##Etherscan API key,
    web3nodes={
        "mainnet": {
            "hook": "https://eth.getblock.io/mainnet/?api_key=<apykey>",  # multiple nodes supported, separate them with comma
            "poa": False  # represented by bool value
        }
    },
    default_chain="mainnet",
    etherscan_urls={"mainnet": "https://api.etherscan.io/api", },
)

ethtx = EthTx.initialize(ethtx_config)
transaction: DecodedTransaction = ethtx.decoders.decode_transaction(
    '0x2c2c40743117d5e6fa3ca2931fcfff40dc998c33109fc132a8ca4d640f39b996')

And I'm getting back: ethtx.exceptions.NodeConnectionException: Couldn't connect to node(s). It's strange because the getblock.io dashboard shows that the requests are actually sent.

0x2c2c40743117d5e6fa3ca2931fcfff40dc998c33109fc132a8ca4d640f39b996 is the hash of one of the last executed transaction at the time I executed the code.

kchojn commented 2 years ago

@yuripaoloni , I have tested https://eth.getblock.io/mainnet/?api_key=<my_api_key> endpoint and looks like it works. As @enmohsinali said, you can decode only transactions from the last 64 blocks with this endpoint. And it works perfectly!

Screen from decoding (getblock.io): image

And tx: image

yuripaoloni commented 2 years ago

I tried again and now it suddenly started to work 🤣. Maybe the node needed time to get live.

Anyway, thanks @kchojn for the support 🤝

kchojn commented 2 years ago

Np! Glad to help! If you need any help with ethtx, you can always write to us on discord 🤠 Best regards!