UNPKG

618 BJavaScriptView Raw
1// Copyright 2017-2023 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3
4import { decodeAddress } from "./decode.js";
5import { encodeAddress } from "./encode.js";
6import { createKeyDerived } from "./keyDerived.js";
7
8/**
9 * @name encodeDerivedAddress
10 * @summary Creates a derived address as used in Substrate utility.
11 * @description
12 * Creates a Substrate derived address based on the input address/publicKey and the index supplied.
13 */
14export function encodeDerivedAddress(who, index, ss58Format) {
15 return encodeAddress(createKeyDerived(decodeAddress(who), index), ss58Format);
16}
\No newline at end of file