Skip to main content

Create a new wallet

The newWallet() function creates a new wallet with an automatically generated BIP39-compliant mnemonic phrase. The operation is synchronous and does not require an API key, and it returns both the recovery phrase and a ready-to-sign multi-chain wallet.

If you prefer to import an existing wallet — using a keystore file, seed phrase, or other methods — check out the relevant sections of our documentation.

When you create a wallet, you're essentially generating the "master credentials" needed to hold cryptocurrencies (e.g., ETH, BTC, LTC, DOGE, BCH), retrieve balances, and make transfers. ChainGate uses a secure, randomized process to generate your mnemonic phrase, ensuring compatibility with other BIP39-compatible applications (e.g., MetaMask, Ledger).

What is a mnemonic phrase?

A mnemonic phrase (often called a "seed phrase") is a group of simple words (like "cat," "tree," "bridge," etc.) used to derive your private keys. This is a human-readable alternative to handling cryptographic keys directly.

Keep your phrase safe!

Treat your mnemonic phrase like a password. If someone obtains it, they can access all assets associated with your wallet.

Basic wallet creation​

To create a new wallet with the default configuration (a 12-word English mnemonic):

import { newWallet } from 'chaingate'

const { phrase, wallet } = newWallet()
  1. phrase: The generated seed phrase (12 English words by default).
  2. wallet: A PhraseWallet instance that derives private keys from the seed phrase on demand. It gives you programmatic access to address derivation, transaction signing, and more.

Custom configuration​

You can control the language and length of the generated mnemonic phrase:

import { newWallet } from 'chaingate'

const { phrase, wallet } = newWallet('spanish', 24)

Supported parameters​

ParameterTypeValuesDefault
languagePhraseLanguageSee supported languages'english'
numberOfWordsPhraseNumOfWords12, 15, 18, 21, 2412

Supported languages​

ChainGate supports mnemonic generation in Czech, English, French, Italian, Japanese, Korean, Portuguese, Simplified Chinese, Spanish, and Traditional Chinese.

Using the wallet​

To interact with blockchains, connect the wallet to a network via a ChainGate instance. The same wallet talks to every supported chain:

import { newWallet, ChainGate } from 'chaingate'

const { phrase, wallet } = newWallet()
const cg = new ChainGate()

const bitcoin = cg.connect(cg.networks.bitcoin, wallet)
console.log('Address:', await bitcoin.address())

Access generated phrase​

You can read the mnemonic phrase directly from the return value:

const { phrase, wallet } = newWallet()
console.log(phrase) // "abandon abandon abandon ... about"

Or retrieve it later from the wallet instance:

const phraseEntity = await wallet.getPhrase()
console.log(phraseEntity.toString())
caution

Never log your phrase in a production environment! Printing it is for demonstration purposes only.

Exporting a wallet​

To back up or persist your wallet, you need to serialize it.

Learn how to serialize your wallet