Skip to content

Generating addresses & keys for In Wallet cryptocurrencies

martiliones edited this page Dec 17, 2023 · 14 revisions

ADAMANT offers an opportunity to store and send in-Chat other cryptocurrencies, Ethereum for example. Their addresses and private keys are derived from account's ADM key pair. The library provides modules to get coin's key pairs.

Ethereum

Refer to eth module of the library:

import { eth } from 'adamant-api'

keys()

Generates ETH address and private keys with provided passphrase of ADAMANT account.

  • Typing

    function keys(passphrase: string): {
      address: string;
      privateKey: string;
    }
  • Parameters

    • passphrase — 12 words Mnemonic ADAMANT passphrase to generate Ethereum's key pair, string.
  • Returns

    • address — Ethereum address, bound to ADAMANT account of provided passphrase.
    • privateKey — Ethereum account's private key.
  • Example

    import { eth } from 'adamant-api'
    
    const { address } = eth.keys(process.env.PASSPHRASE);
    console.log(`Your eth address: ${address}`)

Bitcoin

Refer to btc module of the library:

import { btc } from 'adamant-api'

keys()

Generates BTC address and private keys with provided passphrase of ADAMANT account.

  • Typing

    function keys(passphrase: string): {
      network: Network;
      keyPair: ECPairInterface;
      address: string | undefined;
      privateKey: string | undefined;
      privateKeyWIF: string;
    }
  • Parameters

    • passphrase — 12 words Mnemonic ADAMANT passphrase to generate Bitcoin's key pair, string.
  • Returns

    • addressP2PKH Bitcoin address, bound to ADAMANT account of provided passphrase.
    • keyPairECPair's key pair.
    • privateKey — Regular 256-bit (32 bytes, 64 characters) private key.
    • privateKeyWIFWallet Import Format (52 base58 characters).
    • networkcoininfo's network info.
  • Example

    import { btc } from 'adamant-api'
    
    const { address } = btc.keys(process.env.PASSPHRASE);
    console.log(`Your bitcoin address: ${address}`)

isValidAddress()

Checks if a given string is valid bitcoin address in any format.

  • Typing

    function isValidAddress(address: string): boolean
  • Parameters

    • address — a string to test.
  • Example

    import { btc } from 'adamant-api'
    
    const result = btc.isValidAddress('13rK42XbSJV9BdvKQvDJeH3n45zNBbXsUV');
    
    if (result) {
      console.log('This address is valid.')
    }

Dash

Refer to dash module of the library:

import { dash } from 'adamant-api'

keys()

Generates DASH address and private keys with provided passphrase of ADAMANT account.

  • Typing

    function keys(passphrase: string): {
      network: Network;
      keyPair: ECPairInterface;
      address: string | undefined;
      privateKey: string | undefined;
      privateKeyWIF: string;
    }
  • Parameters

    • passphrase — 12 words Mnemonic ADAMANT passphrase to generate Dash's key pair, string.
  • Returns

    • addressP2PKH Dash address, bound to ADAMANT account of provided passphrase.
    • keyPairECPair's key pair.
    • privateKey — Regular 256-bit (32 bytes, 64 characters) private key.
    • privateKeyWIFWallet Import Format (52 base58 characters).
    • networkcoininfo's network info.
  • Example

    import { dash } from 'adamant-api'
    
    const { address } = dash.keys(process.env.PASSPHRASE);
    console.log(`Your dash address: ${address}`)

isValidAddress()

Checks if a given string is valid dash address in any format.

  • Typing

    function isValidAddress(address: string): boolean
  • Parameters

    • address — a string to test.
  • Example

    import { dash } from 'adamant-api'
    
    const result = dash.isValidAddress('XdY9tHBVQ1hjLaWuGoXXVojZtRa4GfEdNP');
    
    if (result) {
      console.log('This address is valid.')
    }

Doge

Refer to doge module of the library:

import { doge } from 'adamant-api'

keys()

Generates DOGE address and private keys with provided passphrase of ADAMANT account.

  • Typing

    function keys(passphrase: string): {
      network: Network;
      keyPair: ECPairInterface;
      address: string | undefined;
      privateKey: string | undefined;
      privateKeyWIF: string;
    }
  • Parameters

    • passphrase — 12 words Mnemonic ADAMANT passphrase to generate Doge's key pair, string.
  • Returns

    • addressP2PKH Doge address, bound to ADAMANT account of provided passphrase.
    • keyPairECPair's key pair.
    • privateKey — Regular 256-bit (32 bytes, 64 characters) private key.
    • privateKeyWIFWallet Import Format (52 base58 characters).
    • networkcoininfo's network info.
  • Example

    import { doge } from 'adamant-api'
    
    const { address } = doge.keys(process.env.PASSPHRASE);
    console.log(`Your doge address: ${address}`)

isValidAddress()

Checks if a given string is valid doge address in any format.

  • Typing

    function isValidAddress(address: string): boolean
  • Parameters

    • address — a string to test.
  • Example

    import { doge } from 'adamant-api'
    
    const result = doge.isValidAddress('D7zQbHUEjiPRie6v9WCsC3DNwDifUdbFdd');
    
    if (result) {
      console.log('This address is valid.')
    }

Lisk

Refer to lsk module of the library:

import { lsk } from 'adamant-api'

keys()

Generates LISK address and private keys with provided passphrase of ADAMANT account.

  • Typing

    function keys(passphrase: string): {
      network: {
        name: string;
        port: number;
        wsPort: number;
        unit: string;
      };
      keyPair: {
        publicKey: Buffer;
        secretKey: Buffer;
      };
      address: string;
      addressHexBinary: Buffer;
      addressHex: string;
      privateKey: string;
    }
  • Parameters

    • passphrase — 12 words Mnemonic ADAMANT passphrase to generate Lisk's key pair, string.
  • Example

    import { lsk } from 'adamant-api'
    
    const { address } = lsk.keys(process.env.PASSPHRASE);
    console.log(`Your lisk address: ${address}`)