polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 114 forks source link

Can't run an example #182

Closed fasghq closed 2 years ago

fasghq commented 2 years ago

Trying this (code from readme):

substrate = SubstrateInterface(
    url="wss://kusama-rpc.polkadot.io/",
    ss58_format=2,
    type_registry_preset='kusama'
)

Receive: TypeError: __init__() got an unexpected keyword argument 'ss58_format' I removed ss58_format=2 param and then tried to run following example:

# Set block_hash to None for chaintip
block_hash = "0x51d15792ff3c5ee9c6b24ddccd95b377d5cccc759b8e76e5de9250cf58225087"

# Retrieve extrinsics in block
result = substrate.get_block(block_hash=block_hash)

for extrinsic in result['extrinsics']:

    if 'address' in extrinsic.value:
        signed_by_address = extrinsic.value['address']
    else:
        signed_by_address = None

    print('\nPallet: {}\nCall: {}\nSigned by: {}'.format(
        extrinsic.value["call"]["call_module"],
        extrinsic.value["call"]["call_function"],
        signed_by_address
    ))

    # Loop through call params
    for param in extrinsic.value["call"]['call_args']:

        if param['type'] == 'Balance':
            param['value'] = '{} {}'.format(param['value'] / 10 ** substrate.token_decimals, substrate.token_symbol)

        print("Param '{}': {}".format(param['name'], param['value']))

and got: AttributeError: 'SubstrateInterface' object has no attribute 'get_block' What I'm doing wrong?

arjanz commented 2 years ago

Are you sure you installed pip install substrate-interface? There is also a package without the '-' on PYPI

fasghq commented 2 years ago

Are you sure you installed pip install substrate-interface? There is also a package without the '-' on PYPI

You are right, ty!