Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to send #28

Closed
oggy95 opened this issue Sep 9, 2020 · 4 comments
Closed

Failed to send #28

oggy95 opened this issue Sep 9, 2020 · 4 comments

Comments

@oggy95
Copy link

oggy95 commented Sep 9, 2020

Try to create and send signed extrinsic using example in readme with modification to using polkadot mainnet:

from substrateinterface import SubstrateInterface, SubstrateRequestException, Keypair

substrate = SubstrateInterface(url="ws://127.0.0.1:9944", address_type=0)

keypair = Keypair.create_from_mnemonic(MY_MNEMONIC, address_type=0)

call = substrate.compose_call(
    call_module='Balances',
    call_function='transfer',
    call_params={
        'dest': DEST_ACCOUNT
        'value': AMOUNT * 10**10
    }
)

extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)

try:
    result = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
    print("Extrinsic '{}' sent and included in block '{}'".format(result['extrinsic_hash'], result['block_hash']))

except SubstrateRequestException as e:
    print("Failed to send: {}".format(e))

But got an error:

Failed to send: {'code': 1002, 'message': 'Verification Error: Execution: Trap: Trap { kind: Unreachable }', 'data': 'RuntimeApi("Execution: Trap: Trap { kind: Unreachable }")'}

@arjanz
Copy link
Member

arjanz commented Sep 9, 2020

I tried your example and works for me when using the public Polkadot node (wss://rpc.polkadot.io). Perhaps there is a connectivity problem with your node, e.g. are you sure it can reach peers through your firewall?

@oggy95
Copy link
Author

oggy95 commented Sep 9, 2020

Open firewall, same errors at my own node and public node.

@arjanz
Copy link
Member

arjanz commented Sep 9, 2020

I see the problem, you didn't specify the type_registry:

substrate = SubstrateInterface(
    url="wss://rpc.polkadot.io",
    address_type=0,
    type_registry_preset='polkadot'
)

As habit I guess I automatically added this when I was testing

@oggy95
Copy link
Author

oggy95 commented Sep 9, 2020

@arjanz Yes, this working! Thank you!

@oggy95 oggy95 closed this as completed Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants