跳到主要内容
ArcBlock Community

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

shenxiuqiang
支持
chain-and-bridgeqa

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

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

4 条回复

shenxiuqiang2年前
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年前

不知是否正确

wangshijun2年前

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

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

javascriptCopy
const wallet = fromSecretKey(secretKey, 'eth');​
shenxiuqiang2年前

嗯,在写测试

回复