0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Symbol-SDK@3.2.2でNEMる01 -アカウント生成-

Posted at

NEM時代はニーモニックでアカウントを作成するウォレットは無かったのかもしれませんが(あったらスミマセン)、今はSymbol-SDKがあるのでSymbolと同じように出来ます。

symbol-sdk@3.2.2です。
ちょっと使い方が変わりました。

ニーモニック生成

SymbolとNEMは秘密鍵は共用出来るので、ニーモニックも共通です。

import { Bip32 } from 'symbol-sdk'

/** ニーモニック生成 */
const bip32 = new Bip32()
const mnemonic = bip32.random()
console.log(`mnemonic: ${mnemonic}`)

アドレス生成

Envにはtesutnetとかニーモニックが格納されているだけです。

import { Bip32 } from 'symbol-sdk'
import { NemAccount, NemFacade } from 'symbol-sdk/nem'
import { Env } from './Env.js'

const facade = new NemFacade(Env.NEM_NETWORK_IDENTIFIER)
const maxAccounts = 10
const mnemonic = Env.MNEMONIC

/** ニーモニックからアカウント生成 */
const passwd = ''
const bip32Node = new Bip32().fromMnemonic(mnemonic, passwd)
for (let i = 0; i < maxAccounts; i++) {
  const bip32Path = facade.bip32Path(i)
  const childBip32Node = bip32Node.derivePath(bip32Path)
  const keypair = NemFacade.bip32NodeToKeyPair(childBip32Node)
  const account = new NemAccount(facade, keypair)
  console.log(`PrivateKey : ${account.keyPair.privateKey}`)
  console.log(`PublicKey  : ${account.publicKey}`)
  console.log(`Address    : ${account.address}`)
  console.log(
    '============================================================================='
  )
}

とりあえず、アカウント生成まで。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?