debeem-wallet

create a new wallet, or import a wallet from a specified mnemonic, keystore, private key or wallet address.

//	create a new instance of WalletFactory
const instance = new WalletFactory();

Constructors

Methods

  • Create a wallet from a mnemonic phrase. If the parameter is not specified, a random wallet will be created.

    //
    // create a random wallet
    //
    const walletObj = new WalletFactory().createWalletFromMnemonic();

    // should return a WalletEntityBaseItem object:
    {
    isHD: true,
    mnemonic: 'million butter obtain fuel address truck grunt recall gain rotate debris flee',
    password: '',
    address: '0x03a06e86556C819199E602851e4453a89718cB36',
    publicKey: '0x0384636daeaf2f410f7c4a6749a143096838a0482bcee94e412ca3a683bca3ac00',
    privateKey: '0x44dd0864d00e37090622a17e66c0914bd71a1245a3a2e4f88611775854f4eafc',
    index: 0,
    path: "m/44'/60'/0'/0/0"
    }
    //
    // Create a wallet from a mnemonic phrase
    //
    const mnemonic = 'olympic cradle tragic crucial exit annual silly cloth scale fine gesture ancient';
    const walletObj = new WalletFactory().createWalletFromMnemonic( mnemonic );

    // should return a WalletEntityBaseItem object:
    {
    isHD: true,
    mnemonic: 'olympic cradle tragic crucial exit annual silly cloth scale fine gesture ancient',
    password: '',
    address: '0xC8F60EaF5988aC37a2963aC5Fabe97f709d6b357',
    publicKey: '0x03ed2098910ab9068abd54e1562eb9dee3cb2d9fc1426dfe91541970a89b5aa622',
    privateKey: '0xf8ba731e3d09ce93ee6256d7393e993be01cd84de044798372c0d1a8ad9b952a',
    index: 0,
    path: "m/44'/60'/0'/0/0"
    }

    Parameters

    • Optional mnemonic: string

      {string} mnemonic string

    Returns WalletEntityBaseItem

  • Create a wallet from a wallet private key

    //
    // Create a wallet from a private key
    //
    const privateKey = '0xc7f832621897e67d973f0f1c497198ed1b89a138f2fe3cc6ce6a59cd3fb7cd4c';
    const walletObj = new WalletFactory().createWalletFromPrivateKey( privateKey );

    // should return a WalletEntityBaseItem object:
    {
    isHD: false,
    mnemonic: '',
    password: '',
    address: '0xcc361bdf821563d2a8ac5b57a9e34ec5ca48c5f3',
    publicKey: '0x03f2a1155a81b2b5c5e61ec0c148d5465432e9f4b4904e3a25513b27055b0719bb',
    privateKey: '0xc7f832621897e67d973f0f1c497198ed1b89a138f2fe3cc6ce6a59cd3fb7cd4c',
    index: 0,
    path: null
    }

    Parameters

    • privateKey: any = null

      {any}

    Returns WalletEntityBaseItem

  • derive a business wallet from a wallet

    Parameters

    • wallet: TWalletBaseItem

      {TWalletBaseItem} wallet object

    • Optional addressIndex: number

      {number}

    Returns TWalletBaseItem

  • Resolved to the JSON Keystore Wallet for {wallet} encrypted with {password}.

    Parameters

    • wallet: WalletEntityBaseItem

      {WalletEntityBaseItem} wallet entity base item object

    • password: string = ''

      {string} encrypt {wallet} with {password}

    Returns Promise<string>

  • Check the input value is a valid address

    //	should return true
    isValidAddress( '0xcc361bdf821563d2a8ac5b57a9e34ec5ca48c5f3' );

    // should return false
    isValidAddress( '0x1111' );
    isValidAddress( null );
    isValidAddress( undefined );

    Parameters

    • address: string

      {string} - wallet address

    Returns boolean