I'm trying to use the cosmpy library as a client for Cosmos network
Trying to do it this way:
from cosmpy.aerial.client import LedgerClient
from cosmpy.aerial.config import NetworkConfig
from cosmpy.aerial.wallet import LocalWallet
from cosmpy.crypto.address import Address
receiver_addr = Address(tests_address2)
generated_wallet = LocalWallet.generate(prefix='cosmos')
cfg = NetworkConfig(
chain_id="Cosmos-Hub",
url="grpc+https://grpc-cosmoshub.blockapsis.com:429",
fee_minimum_gas_price=1,
fee_denomination="uatom",
staking_denomination="uatom",
)
cl = LedgerClient(cfg)
res = cl.query_bank_balance(address=Address(receiver_addr))
but always getting this exception:
E0829 19:01:51.948000000 35660 src/core/ext/transport/chttp2/transport/hpack_parser.cc:1234] Error parsing metadata: error=invalid value key=content-type value=text/html
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2022.1.2\plugins\python\helpers\pydev\pydevd.py", line 1491, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2022.1.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/Python_Projects/Cosmos_Client/tests/test_client.py", line 104, in <module>
res = cl.query_bank_balance(address=Address(wallet_data['address']))
File "D:\Python_Projects\Cosmos_Client\venv\lib\site-packages\cosmpy\aerial\client\__init__.py", line 226, in query_bank_balance
resp = self.bank.Balance(req)
File "D:\Python_Projects\Cosmos_Client\venv\lib\site-packages\grpc\_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "D:\Python_Projects\Cosmos_Client\venv\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Received http2 header with status: 502"
debug_error_string = "{"created":"@1661788911.949000000","description":"Error received from peer ipv4:54.219.236.123:429","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Received http2 header with status: 502","grpc_status":14}"
>
python-BaseException
how to process blockchain operations with cosmpy library?
The error was due inactive chain peer URL. Need to find working URL here: https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/chain.json