Pezkuwi API
    Preparing search index...

    Class Keyring

    @pezkuwi/keyring

    Keyring

    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.

    Implements

    • KeyringInstance
    Index
    • Parameters

      • Optionaloptions: KeyringOptions

      Returns Keyring

    decodeAddress: (
        encoded?: string | Uint8Array | null,
        ignoreChecksum?: boolean,
        ss58Format?: number,
    ) => Uint8Array
    encodeAddress: (address: string | Uint8Array, ss58Format?: number) => string

    encodeAddress

    Encodes the input into an ss58 representation

    • get pairs(): KeyringPair[]

      Returns KeyringPair[]

      retrieve the pairs (alias for getPairs)

    • get publicKeys(): Uint8Array[]

      Returns Uint8Array[]

      retrieve the publicKeys (alias for getPublicKeys)

    • get type(): KeypairType

      Returns KeypairType

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

    • Parameters

      • address: string | Uint8Array
      • Optionalmeta: KeyringPair$Meta
      • Optionalencoded: Uint8Array | null
      • Optionaltype: KeypairType
      • OptionalignoreChecksum: boolean
      • OptionalencType: EncryptedJsonEncoding[]

      Returns KeyringPair

      addFromAddress

      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

      • json: KeyringPair$Json
      • OptionalignoreChecksum: boolean

      Returns KeyringPair

      addFromJson

      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

      • mnemonic: string
      • Optionalmeta: KeyringPair$Meta
      • Optionaltype: KeypairType
      • Optionalwordlist: string[]

      Returns KeyringPair

      addFromMnemonic

      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

      • pair: Keypair
      • Optionalmeta: KeyringPair$Meta
      • Optionaltype: KeypairType

      Returns KeyringPair

      addFromPair

    • Parameters

      • seed: Uint8Array
      • Optionalmeta: KeyringPair$Meta
      • Optionaltype: KeypairType

      Returns KeyringPair

      addFromSeed

      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

      • suri: string
      • Optionalmeta: KeyringPair$Meta
      • Optionaltype: KeypairType
      • Optionalwordlist: string[]

      Returns KeyringPair

      addFromUri

      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

      • pair: KeyringPair

      Returns KeyringPair

      addPair

    • Parameters

      • __namedParameters: KeyringPair$Json
      • OptionalignoreChecksum: boolean

      Returns KeyringPair

      createFromJson

      Creates a pair from a JSON keyfile

    • Parameters

      • pair: Keypair
      • Optionalmeta: KeyringPair$Meta
      • Optionaltype: KeypairType

      Returns KeyringPair

      createFromPair

    • Parameters

      • _suri: string
      • Optionalmeta: KeyringPair$Meta
      • Optionaltype: KeypairType
      • Optionalwordlist: string[]

      Returns KeyringPair

      createFromUri

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

    • Parameters

      • address: string | Uint8Array

      Returns KeyringPair

      getPair

      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).

    • Returns KeyringPair[]

      getPairs

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

    • Returns Uint8Array[]

      getPublicKeys

      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.

    • Parameters

      • address: string | Uint8Array

      Returns void

      removePair

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

    • Parameters

      • ss58: number

      Returns void

      setSS58Format;

      Sets the ss58 format for the keyring

    • Parameters

      • address: string | Uint8Array
      • Optionalpassphrase: string

      Returns KeyringPair$Json

      toJson

      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.