Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

How to create Preimage hash? #79

Closed
Marware opened this issue Feb 18, 2021 · 1 comment
Closed

How to create Preimage hash? #79

Marware opened this issue Feb 18, 2021 · 1 comment

Comments

@Marware
Copy link

Marware commented Feb 18, 2021

This is not clear in any related documentation

Sample code:

`call = substrate.compose_call(
call_module='Balances',
call_function='transfer',
call_params={
'dest': "5Gv8v85YeymUorg7No8vNAaaqpmSD71oT6RQYABnzEUXP9Af",
'value': 11111
})

hx = str(call).encode().hex() #1
storageFee = ((len(hx) - 2) / 2) * PreimageDepositConst
blake2_256(hx) #2`
Values of #1 and #2 (and storageFee) are different from what's generated on polkadot.js UI, and the results didn't work anyway

Any help or pointers would be appreciated
Thanks

@arjanz
Copy link
Member

arjanz commented Feb 19, 2021

The way you used to determine the bytes of the call is not correct, the bytes of the call (and any ScaleType) are stored in the call.data attribute (this is of type ScaleBytes). So the actual bytes are stored in call.data.data. Also there is a convenience function that the string representation of a ScaleBytes is in 0x1234 hex-format, so you can also just use str(call.data)

@arjanz arjanz closed this as completed Jun 11, 2021
@polkascan polkascan locked and limited conversation to collaborators Jan 3, 2023
@arjanz arjanz converted this issue into discussion #305 Jan 3, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants