Keyring & Signer
Keyring
Signer
Signing transactions using IKeyringPair
IKeyringPairimport { cryptoWaitReady } from '@polkadot/util-crypto';
import { Keyring } from '@polkadot/keyring';
// Setup Keyring & create a KeyringPair
await cryptoWaitReady();
const keyring = new Keyring({ type: 'sr25519' });
const aliceKeyringPair = keyring.addFromUri('//Alice');
// Sign & send transaction
const unsub = await client.tx.balances
.transferKeepAlive(<destAddress>, 2_000_000_000_000n)
.signAndSend(aliceKeyringPair, async ({ status }) => {
console.log('Transaction status', status.type);
if (status.type === 'BestChainBlockIncluded') { // or status.type === 'Finalized'
console.log(`Transaction completed at block hash ${status.value.blockHash}`);
await unsub();
}
});Signing transactions using Signer
SignerLast updated