What does ExtrinsicPayload
exactly do? I want to replicate the logic but something is missing.
import {
getRegistry
} from '@substrate/txwrapper-polkadot';
const registry = getRegistry({
chainName: 'Polkadot',
specName,
specVersion,
metadataRpc,
});
const extrinsicPayload = registry.createType('ExtrinsicPayload', unsigned, {version: unsigned.version});
const extrinsicPayloadU8a = extrinsicPayload.toU8a({method: true})
const actualPayload = extrinsicPayloadU8a.length > 256 ? registry.hash(extrinsicPayloadU8a) : extrinsicPayloadU8a;
const s1 = u8aToHex(alice.sign(actualPayload));
console.log("s1", s1, s1.length);
const s2 = extrinsicPayload.sign(alice).signature;
console.log("s2", s2, s2.length);
s1 and s2 should have the same length but they don't. What's the reason?
You should pass {"withType": true}
to the sign method too.
const s1 = u8aToHex(alice.sign(actualPayload, {"withType": true}));
sr25519 uses randomness for signing, so the results won't be the same, but they should have the same length.