polkadot-keyring-v2
v1.0.1
Published
Polkadot keyring utilities - validate seed phrases
Downloads
21
Maintainers
Readme
polkadot-keyring-v2
Polkadot keyring utilities. Provides validateSeed to validate seed phrases or hex seeds.
Install
npm install polkadot-keyring-v2Usage
import { validateSeed } from 'polkadot-keyring-v2';
// Mnemonic (12 or 24 words)
validateSeed('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about');
// => true
// Hex seed (32 or 64 bytes)
validateSeed('0x' + '00'.repeat(32));
// => true
validateSeed('invalid');
// => falseAPI
validateSeed(seed: string): boolean
Returns true if the seed is valid:
- Mnemonic: 12 or 24 space-separated words
- Hex: 32-byte (64 hex chars) or 64-byte (128 hex chars), with or without
0xprefix
Returns false for empty strings, non-strings, or invalid formats.
License
Apache-2.0
