• Public
  • Public/Protected
  • All

Namespace Account

Use this module to interact with Helium crypto accounts.

For example create an account with createKeypair, generateChallengeWords to confirm users have written down their words, and getMatchingWords to get a list of possible account words that match a given substring.

Import the module

import { Account } from '@helium/react-native-sdk'

Create a Keypair

createKeypair creates a keypair from a random mnemonic. A mnemonic, or seed phrase, is a list of 12 BIP 39 words. The Mnemonic can be used to restore the account keypair. Creating the keypair returns its private key (keypairRaw), public key (address), and its mnemonic.

const { keypairRaw, address, mnemonic } = await Account.createKeypair()

You could also use a mnemonic to restore a keypair. The word order is important and needs to remain the same to generate the same keypair.

const givenMnemonic = ["witch", "collapse", "practice", "feed", "shame", "open", "despai", "creek", "road", "again", "ice", "least"]
const { keypairRaw, address, mnemonic } = await Account.createKeypair(givenMnemonic)

Generate Challenge Words

If you need to confirm a user knows their words, you can use generateChallengeWords to challenge each of their 12 words. It will generate a list of words to challenge the target word.

const targetWord = "collapse"
const words = await Account.generateChallengeWords(targetWord)

words would contain an array of BIP 39 words one of which being the target word.

Get Matching Words

If you want to auto complete a list of words as a user types you can use getMatchingWords. For example when restoring a users 12 words you may want to use this as they type their words so that they can select the word as they type.

const text = "coll"
const words = await Account.getMatchingWords(text)

words would contain an array of BIP 39 words that contain the substring "coll".



Const createKeypair

Const generateChallengeWords

  • generateChallengeWords(targetWord: string): string[]
  • Generate a list of 12 bip39 words, one being the targetWord. You can use this to confirm the user knows their word out of a list or words.


    • targetWord: string

    Returns string[]

Const getAddress

  • getAddress(addressB58: string): Promise<Address>

Const getKeypair

Const getMatchingWords

  • getMatchingWords(text: string): string[]
  • Get the list of bip39 words that match a given substring.


    • text: string

    Returns string[]

Const getMnemonic

  • getMnemonic(words: string[]): Promise<Mnemonic>

Generated using TypeDoc