polkascan / py-substrate-interface

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

Failed to send DOT with "era" value. #72

Closed iwinniepooh closed 2 years ago

iwinniepooh commented 3 years ago

Hi everyone.

Introductory: There is 1.0135 DOT on the balance of my address, I am trying to send via the transfer 1 DOT method.

I am trying to send a transaction according to the example:

call = substrate.compose_call( call_module="Balances", call_function="transfer", call_params={ "dest": "1nRKdB9YwEqnxGPc3wM8jXmZJyomhtLThbDjoEC7z9iT6kY", "value": 1 * 10**10 } ) extrinsic = substrate.create_signed_extrinsic( call=call, keypair=keypair, era={"period": 64} )

If I use era={'period': 64} (with any period value), then I get an error:

{"code": 1010, "message": "Invalid Transaction", "data": "Inability to pay some fees (e.g. account balance too low)"}

If I remove the era parameter altogether, the transaction is executed successfully.

Results with "ERA":

Account info {'nonce': 1, 'refcount': 0, 'data': {'free': 10153000000, 'reserved': 0, 'miscFrozen': 0, 'feeFrozen': 0}}

Compose call info: {'call_module': 'Balances', 'call_function': 'transfer', 'call_args': {'dest': '1nRKdB9YwEqnxGPc3wM8jXmZJyomhtLThbDjoEC7z9iT6kY', 'value': 10000000000}}

Payment info: {'class': 'normal', 'partialFee': 153000000, 'weight': 218434000}

Result: 'error': '{"code": 1010, "message": "Invalid Transaction", "data": "Inability to pay some fees (e.g. account balance too low)"}'}

Results without "ERA":

Account info {'nonce': 1, 'refcount': 0, 'data': {'free': 10153000000, 'reserved': 0, 'miscFrozen': 0, 'feeFrozen': 0}}

Compose call info: {'call_module': 'Balances', 'call_function': 'transfer', 'call_args': {'dest': '1nRKdB9YwEqnxGPc3wM8jXmZJyomhtLThbDjoEC7z9iT6kY', 'value': 10000000000}}

Payment info: {'class': 'normal', 'partialFee': 153000000, 'weight': 218434000}

Result: '0xc4a4377b3cae2898de4daf00177c1aee1f2cc65daa6fc06a5e86a1ba7de9f2d4'

arjanz commented 3 years ago

This is strange.. Both transactions appear to have a valid signature and being interpreted correctly by the node. Have you tried with a slightly higher balance? Maybe the addition of an era increased the transaction fee?

Another guess (but unlikely) is that your scalecodec is out of date, have you updated py-substrate-interface to latest version?