How to use the @polkadot/util-crypto.mnemonicGenerate function in @polkadot/util-crypto

To help you get started, we’ve selected a few @polkadot/util-crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / apps / packages / app-accounts / src / modals / Create.tsx View on Github external
function newSeed (seed: string | undefined | null, seedType: SeedType): string {
  switch (seedType) {
    case 'bip':
      return mnemonicGenerate();
    case 'dev':
      return DEV_PHRASE;
    default:
      return seed || u8aToHex(randomAsU8a());
  }
}
github paritytech / substrate-light-ui / packages / light-apps / src / Onboarding / WelcomeScreen.tsx View on Github external
const confirmCreate = () => {
    const mnemonic = mnemonicGenerate();
    const keypair = naclKeypairFromSeed(mnemonicToSeed(mnemonic));

    keyring.encodeAddress(
      keypair.publicKey
    );

    let stashPair = keyring.createAccountMnemonic(mnemonic, stashPassword, { name: 'Stash', type: 'stash' });
    let controllerPair = keyring.createAccountMnemonic(mnemonic, controllerPassword, { name: 'Controller', type: 'controller' });

    const stashAddress = stashPair.address();
    const stashJson = stashPair.toJson(stashPassword);

    const controllerAddress = controllerPair.address();
    const controllerJson = stashPair.toJson(controllerPassword);

    const stashBlob = new Blob([JSON.stringify(stashJson)], { type: 'application/json; charset=utf-8' });
github polkadot-js / extension / packages / extension / src / background / handlers / Extension.ts View on Github external
private seedCreate ({ length = SEED_DEFAULT_LENGTH, type }: RequestSeedCreate): ResponseSeedCreate {
    const seed = mnemonicGenerate(length);

    return {
      address: keyring.createFromUri(seed, {}, type).address,
      seed
    };
  }
github polkadot-js / apps / packages / app-accounts / src / modals / Create.tsx View on Github external
function newSeed (seed: string | undefined | null, seedType: SeedType): string {
  switch (seedType) {
    case 'bip':
      return mnemonicGenerate();
    case 'dev':
      return DEV_PHRASE;
    default:
      return seed || u8aToHex(randomAsU8a());
  }
}
github paritytech / substrate-light-ui / packages / light-apps / src / Onboarding / CreateNewAccountScreen.tsx View on Github external
newMnemonic = () => {
    const mnemonic = mnemonicGenerate();
    const address = this.generateAddressFromMnemonic(mnemonic);

    this.setState({ address, mnemonic });
  }
github polkadot-js / ui / packages / exampleReactNative / App.tsx View on Github external
const _onClickNew = (): void => {
    const phrase = mnemonicGenerate(12);
    const { address } = keyring.createFromUri(phrase);

    setAddress(keyring.encodeAddress(address, ss58Format));
    setPhrase(phrase);
  };
github paritytech / substrate-light-ui / packages / light-apps / src / AddAccount / Create / CreateAccount.tsx View on Github external
export function Create (props: Props): React.ReactElement {
  const { identiconSize, location } = props;

  const { keyring } = useContext(AppContext);

  const [errors, setErrors] = useState>>(none);
  const [mnemonic] = useState(mnemonicGenerate());
  const [name, setName] = useState('');
  const [password, setPassword] = useState('');
  const [step, setStep] = useState('copy');

  const [tagOptions, setTagOptions] = useState([
    { key: '0', text: 'stash', value: 'Stash' },
    { key: '1', text: 'controller', value: 'Controller' }
  ]);
  const [tags, setTags] = useState([]);

  const [firstWord, setFirstWord] = useState();
  const [secondWord, setSecondWord] = useState();
  const [thirdWord, setThirdWord] = useState();
  const [fourthWord, setFourthWord] = useState();

  const [randomFourWords, setRandomFourWords] = useState();