api
api copied to clipboard
signRaw problem
server.post<{ Body: { message: string, signature: string, address: string } }>("/worker/signMessage", async (request, reply) => {
const keyring = new Keyring({ type: 'sr25519' });
const alice = keyring.addFromUri('//Bob', { name: 'Alice default' });
console.log(`${alice.meta.name}: has address ${alice.address} with publicKey [${alice.publicKey}]`);
const message = stringToHex('I\'m verifying my DOT address');
const signature = alice.sign(message);
return { signature: u8aToHex(signature) }
});
const injector = await web3FromSource(targetDotAddress.meta.source)
const signRaw = injector?.signer?.signRaw
const { signature } = await signRaw({
address: targetDotAddress.address,
data: stringToHex('I\'m verifying my DOT address'),
type: 'bytes'
})
hi, what's the difference between this(1) and that(2)? I want to get the result of the first, in the second way
or polkadot api interface curl example
thanks.
From a brief look, they should be equivalent. (Obviously sr25519 signatures are non-deterministic and will differ on each run, so you cannot compare the outputs)
This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.
Closing.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.