Skip to main content
ArcBlock Community

如何通过以太坊私钥或助记词生成DID wallet?

shenxiuqiang
Support
chain-and-bridgeqa

如何通过以太坊私钥或助记词生成DID wallet?

https://www.arcblock.io/docs/blockchain/en/create-account 没有示例

4 replies

shenxiuqiang2 years ago
javascriptCopy
const mnemonic = 'exist vibrant interest scrub nephew solve thumb seven wrist panic journey produce';
const ethWallet = ethers.Wallet.fromPhrase(mnemonic);
console.log(ethWallet);

const wallet = fromSecretKey(toUint8Array(ethWallet.privateKey), {
    role: types.RoleType.ROLE_ACCOUNT,
    pk: types.KeyType.ETHEREUM,
    hash: types.HashType.SHA3
}); 
shenxiuqiang2 years ago

不知是否正确

wangshijun2 years ago

首先,你这个私钥发出来 = 已经泄漏了,请不要在社区的帖子、回复、私信中贴任何助记词、私钥。

你把 Eth Wallet 打印出来之后,获取到其 secretKey,然后

javascriptCopy
const wallet = fromSecretKey(secretKey, 'eth');​
shenxiuqiang2 years ago

嗯,在写测试

Reply