txwrapper icon indicating copy to clipboard operation
txwrapper copied to clipboard

address Different

Open AriesChain-Dev opened this issue 5 years ago • 2 comments

paritytech/txwrapper create address: const mnemonic = mnemonicGenerate(); console.log(" memonic: ", mnemonic); // fringe history shy cupboard orbit supreme skin ladder soup shallow unaware wasp console.log(keyring.createFromUri(mnemonic).address); // 5GgrbTa5op5Xkv1wY6PAVNFdCyS5BLPhErYLGGiywskBSV8K

use import polkadot{.js} extension The address generated by importing mnemonic words is: 5Gj1TdhEP1TSrcEYwUMUqFS8XwMUqgxDcMCGeW9pxXgyKfRS

why?

AriesChain-Dev avatar Feb 24 '21 10:02 AriesChain-Dev

They are using different crypto types - one is using sr25519 while the other is using ed25519

To illustrate here a code snippet - the comments are what gets logged to the console:

import { Keyring } from '@polkadot/api';
import { cryptoWaitReady } from '@polkadot/util-crypto';

async function main(): Promise<void> {
	await cryptoWaitReady();
	const m =
		'fringe history shy cupboard orbit supreme skin ladder soup shallow unaware wasp';

	const keyring1 = new Keyring({ ss58Format: 42, type: 'sr25519' });
	const keypair1 = keyring1.addFromUri(m);
	console.log(keypair1.address); 
         // 5Gj1TdhEP1TSrcEYwUMUqFS8XwMUqgxDcMCGeW9pxXgyKfRS

	const keyring2 = new Keyring({ ss58Format: 42, type: 'ed25519' });
	const keypair2 = keyring2.addFromUri(m);
	console.log(keypair2.address);
        // 5GgrbTa5op5Xkv1wY6PAVNFdCyS5BLPhErYLGGiywskBSV8K
}

main().catch(console.log);

emostov avatar Feb 24 '21 19:02 emostov

Thanks, solved my problem

AriesChain-Dev avatar Feb 25 '21 02:02 AriesChain-Dev