Polkadot-js中有没有创建HD钱包地址的方法

In Polkadot-js is there a method to create HD wallet addresses

我正在使用 Polkadot-js api 并且想知道是否有一个 API 可以从给定的种子生成分层确定性钱包地址?

我看到Substrate的subkeydocumentation里面有提到软硬派生路径,不知道有没有移植到Polkadot-js或者怎么调用.

SURI 由 Polkadot-js 使用 createFromUriaddFromUri 来创建或添加新帐户到您的密钥环。 您可以 import keyring from '@polkadot/ui-keyring' 然后使用它:

keyring.createFromUri(`${phrase.trim()}${derivePath}`, {}, pairType)

这是definition of the function

编辑:派生路径可以是/[soft]//[hard]的任意组合,可以重复,不必按此顺序,在此之上,您可以额外的 ///[password].

因此您可以将参数作为参数传递给 createFromUri 函数,例如:[mnemonic phrase]//Kusama//DAO/1[mnemonic phrase]//MyMainFunds/0///ThisIsMyPassword.