Function: createWallet()
GalaChain core SDK 1.0.0-rc.8 / index / createWallet
Function: createWallet()
createWallet(
input?):GeneratedWallet
Defined in: packages/gala-core-sdk/dist/index.d.ts:2356
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).
Parameters
input?
string
Returns
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).
Example
const fresh = createWallet();
const restored = createWallet(fresh.mnemonic);
restored.privateKey === fresh.privateKey; // true