Class Keyring

@polkadot/keyring

Overview

Name

Keyring

Summary

Keyring management of user accounts

Description

Allows generation of keyring pairs from a variety of input combinations, such as json object containing account address or public key, account metadata, and account encoded using addFromJson, or by providing those values as arguments separately to addFromAddress, or by providing the mnemonic (seed phrase) and account metadata as arguments to addFromMnemonic. Stores the keyring pairs in a keyring pair dictionary. Removal of the keyring pairs from the keyring pair dictionary is achieved using removePair. Retrieval of all the stored pairs via getPairs or perform lookup of a pair for a given account address or public key using getPair. JSON metadata associated with an account may be obtained using toJson accompanied by the account passphrase.

Hierarchy

  • Keyring

Implements

  • KeyringInstance

Constructors

  • Parameters

    • Optional options: KeyringOptions

    Returns Keyring

Properties

#private: any
decodeAddress: ((encoded?: string | Uint8Array, ignoreChecksum?: boolean, ss58Format?: number) => Uint8Array)

Type declaration

    • (encoded?: string | Uint8Array, ignoreChecksum?: boolean, ss58Format?: number): Uint8Array
    • Parameters

      • Optional encoded: string | Uint8Array
      • Optional ignoreChecksum: boolean
      • Optional ss58Format: number

      Returns Uint8Array

encodeAddress: ((address: string | Uint8Array, ss58Format?: number) => string)

Type declaration

    • (address: string | Uint8Array, ss58Format?: number): string
    • Name

      encodeAddress

      Description

      Encodes the input into an ss58 representation

      Parameters

      • address: string | Uint8Array
      • Optional ss58Format: number

      Returns string

Accessors

  • get pairs(): KeyringPair[]
  • Description

    retrieve the pairs (alias for getPairs)

    Returns KeyringPair[]

  • get publicKeys(): Uint8Array[]
  • Description

    retrieve the publicKeys (alias for getPublicKeys)

    Returns Uint8Array[]

  • get type(): KeypairType
  • Description

    Returns the type of the keyring, ed25519, sr25519 or ecdsa

    Returns KeypairType

Methods

  • Name

    addFromAddress

    Summary

    Stores an account, given an account address, as a Key/Value (public key, pair) in Keyring Pair Dictionary

    Description

    Allows user to explicitly provide separate inputs including account address or public key, and optionally the associated account metadata, and the default encoded value as arguments (that may be obtained from the json file of an account backup), and then generates a keyring pair from them that it passes to addPair to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.

    Parameters

    • address: string | Uint8Array
    • Optional meta: KeyringPair$Meta
    • Optional encoded: Uint8Array
    • Optional type: KeypairType
    • Optional ignoreChecksum: boolean
    • Optional encType: EncryptedJsonEncoding[]

    Returns KeyringPair

  • Name

    addFromJson

    Summary

    Stores an account, given JSON data, as a Key/Value (public key, pair) in Keyring Pair Dictionary

    Description

    Allows user to provide a json object argument that contains account information (that may be obtained from the json file of an account backup), and then generates a keyring pair from it that it passes to addPair to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.

    Parameters

    • json: KeyringPair$Json
    • Optional ignoreChecksum: boolean

    Returns KeyringPair

  • Name

    addFromMnemonic

    Summary

    Stores an account, given a mnemonic, as a Key/Value (public key, pair) in Keyring Pair Dictionary

    Description

    Allows user to provide a mnemonic (seed phrase that is provided when account is originally created) argument and a metadata argument that contains account information (that may be obtained from the json file of an account backup), and then generates a keyring pair from it that it passes to addPair to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.

    Parameters

    • mnemonic: string
    • Optional meta: KeyringPair$Meta
    • Optional type: KeypairType

    Returns KeyringPair

  • Name

    addFromPair

    Summary

    Stores an account created from an explicit publicKey/secreteKey combination

    Parameters

    • pair: Keypair
    • Optional meta: KeyringPair$Meta
    • Optional type: KeypairType

    Returns KeyringPair

  • Name

    addFromSeed

    Summary

    Stores an account, given seed data, as a Key/Value (public key, pair) in Keyring Pair Dictionary

    Description

    Stores in a keyring pair dictionary the public key of the pair as a key and the pair as the associated value. Allows user to provide the account seed as an argument, and then generates a keyring pair from it that it passes to addPair to store in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.

    Parameters

    • seed: Uint8Array
    • Optional meta: KeyringPair$Meta
    • Optional type: KeypairType

    Returns KeyringPair

  • Name

    addFromUri

    Summary

    Creates an account via an suri

    Description

    Extracts the phrase, path and password from a SURI format for specifying secret keys <secret>/<soft-key>//<hard-key>///<password> (the ///password may be omitted, and /<soft-key> and //<hard-key> maybe repeated and mixed). The secret can be a hex string, mnemonic phrase or a string (to be padded)

    Parameters

    • suri: string
    • Optional meta: KeyringPair$Meta
    • Optional type: KeypairType

    Returns KeyringPair

  • Name

    addPair

    Summary

    Stores an account, given a keyring pair, as a Key/Value (public key, pair) in Keyring Pair Dictionary

    Parameters

    • pair: KeyringPair

    Returns KeyringPair

  • Name

    createFromJson

    Description

    Creates a pair from a JSON keyfile

    Parameters

    • __namedParameters: KeyringPair$Json
    • Optional ignoreChecksum: boolean

    Returns KeyringPair

  • Name

    createFromPair

    Summary

    Creates a pair from an explicit publicKey/secreteKey combination

    Parameters

    • pair: Keypair
    • Optional meta: KeyringPair$Meta
    • Optional type: KeypairType

    Returns KeyringPair

  • Name

    createFromUri

    Summary

    Creates a Keypair from an suri

    Description

    This creates a pair from the suri, but does not add it to the keyring

    Parameters

    • _suri: string
    • Optional meta: KeyringPair$Meta
    • Optional type: KeypairType

    Returns KeyringPair

  • Name

    getPair

    Summary

    Retrieves an account keyring pair from the Keyring Pair Dictionary, given an account address

    Description

    Returns a keyring pair value from the keyring pair dictionary by performing a key lookup using the provided account address or public key (after decoding it).

    Parameters

    • address: string | Uint8Array

    Returns KeyringPair

  • Name

    getPairs

    Summary

    Retrieves all account keyring pairs from the Keyring Pair Dictionary

    Description

    Returns an array list of all the keyring pair values that are stored in the keyring pair dictionary.

    Returns KeyringPair[]

  • Name

    getPublicKeys

    Summary

    Retrieves Public Keys of all Keyring Pairs stored in the Keyring Pair Dictionary

    Description

    Returns an array list of all the public keys associated with each of the keyring pair values that are stored in the keyring pair dictionary.

    Returns Uint8Array[]

  • Name

    removePair

    Description

    Deletes the provided input address or public key from the stored Keyring Pair Dictionary.

    Parameters

    • address: string | Uint8Array

    Returns void

  • Name

    setSS58Format;

    Description

    Sets the ss58 format for the keyring

    Parameters

    • ss58: number

    Returns void

  • Name

    toJson

    Summary

    Returns a JSON object associated with the input argument that contains metadata assocated with an account

    Description

    Returns a JSON object containing the metadata associated with an account when valid address or public key and when the account passphrase is provided if the account secret is not already unlocked and available in memory. Note that in Polkadot-JS Apps the user may backup their account to a JSON file that contains this information.

    Parameters

    • address: string | Uint8Array
    • Optional passphrase: string

    Returns KeyringPair$Json

Generated using TypeDoc