index/functions/createWallet.md
createWallet(
input?):GeneratedWallet
A wallet: a new random one (no input), or the one a private key or a mnemonic names.
- no input: a new 12-word mnemonic and its first account;
- 64 hex digits (with or without
0x, any case): that key; - 12 or 24 words: the mnemonic's first account (
m/44'/60'/0'/0/0), read case-insensitively.
Use the key with any signer: new PrivateKeySigner(wallet.privateKey),
new PrivateKeyProvider(wallet.privateKey), or an ethers new Wallet(wallet.privateKey).
generated wallet private key signer provider
Parameters
| Parameter | Type |
|---|---|
input? | string |
Returns
generated wallet
Throws
GalaSDKError INVALID_WALLET_INPUT (empty, unrecognized_format,
unknown_mnemonic_word, mnemonic_checksum), INVALID_PRIVATE_KEY (not_on_curve: zero or not
below the curve order), CSPRNG_UNAVAILABLE (a random wallet with no crypto.getRandomValues).
invalid wallet input unrecognized format unknown mnemonic word checksum private key not on curve csprng unavailable get random values
Example
const fresh = createWallet();
const restored = createWallet(fresh.mnemonic);
restored.privateKey === fresh.privateKey; // true