I am trying to create a SignerPayloadJSON
from an encoded partial extrinsic in polkadotjs. The partial extrinsic has the following hex representation
0x00001448656c6c6f000000c22400001600000081bf2e35e70dbc700b2b3a189a6ced2a3f4d098aaf08dbdd63089bc714de2c2e81bf2e35e70dbc700b2b3a189a6ced2a3f4d098aaf08dbdd63089bc714de2c2e
and decodes to the following data when decoded by the polkadot js browser app:
callIndex
0000
remark
14 48656c6c6f
era
00 00
nonce
00
tip
00
specVersion
c2240000
transactionVersion
16000000
genesisHash
81bf2e35e70dbc700b2b3a189a6ced2a3f4d098aaf08dbdd63089bc714de2c2e
blockHash
81bf2e35e70dbc700b2b3a189a6ced2a3f4d098aaf08dbdd63089bc714de2c2e
We create an api connection to a local node like so:
const api = await ApiPromise.create({
provider: new WsProvider("ws://127.0.0.1:9944"),
});
await api.isReady;
How can we create the SignerPayloadJSON
object, given that we have access to the ss58 formatted address of the user? We tried to first decode the data into an ExtrinsicPayload like so:
let extrinsicPayload = api.createType("ExtrinsicPayload", payload_hex, {
version: 4,
});
But this extrinsicPayload
object then has an empty field method: ""
which seems odd.
I tried to craft this payload manually like so:
let hand_crafted_signer_payload = {
address: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
blockHash:
"0x559440460afd0b06684f4cecced86acdb4a278e0b77fa26b0eb67531523d6f34",
blockNumber: "0x02",
era: "0x0000",
genesisHash:
"0x81bf2e35e70dbc700b2b3a189a6ced2a3f4d098aaf08dbdd63089bc714de2c2e",
method: "0x00001448656c6c6f",
nonce: "0x00",
specVersion: "0xc2240000",
tip: "0x00",
transactionVersion: "0x16000000",
signedExtensions: [],
version: 4,
}
But submitting it to the extension to be signed like this:
const injector = await dapp.web3FromSource("polkadot-js");
let { signature } = await injector?.signer?.signPayload(hand_crafted_signer_payload);
always led to an error by the extension:
TLDR: How can we create a valid SignerPayloadJSON
from a hex encoded payload and a given ss58 address, such that we can give it for signing to the polkadotjs
extension?