2
await cryptoWaitReady();

const json = JSON.parse(xxx);
const keyring = new Keyring({ ss58Format: 42 });
const pair = keyring.addFromPair(decoded, json.meta, 'sr25519');
// const pair = keyring.addFromUri('//Alice', null, 'sr25519');
const sig = pair.sign(..);

Everything works well if I use //Alice to sign. But if I use json key to sign then I got this error.

If I remove the await cryptoWaitReady(); I'll get The WASM interface has not been initialized..

1 Answer 1

0

Because the xxx is an ed25519 style key.

I shouldn't set it to sr25519.

And the runtime doesn't provide an interface to sign this; check https://github.com/polkadot-js/common/issues/929#issuecomment-813324953.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.