I'm trying to generate address and create transaction using nodejs and @emurgo/cardano-serialization-lib-nodejs lib (CardanoWasm). Following the docs I'm trying this:
const rootkey = CardanoWasm.Bip32PrivateKey.from_bip39_entropy(
Buffer.from(someEntropy, 'hex'), // entropy is generated from mnemonic
Buffer.from('')
);
const account = rootkey
.derive(harden(1852)) // harden is a function returning 0x80000000+arg
.derive(harden(1815))
.derive(harden(0));
const utxokey = account
.derive(0)
.derive(0)
.to_public();
const stake1 = account
.derive(2)
.derive(0)
.to_public();
const address = CardanoWasm.BaseAddress.new(
CardanoWasm.NetworkInfo.mainnet().network_id(),
CardanoWasm.StakeCredential.from_keyhash(utxokey.to_raw_key().hash()),
CardanoWasm.StakeCredential.from_keyhash(stakekey.to_raw_key().hash())
);
const addressBech32 = address.to_address().to_bech32();
So in my example addressBech32 is an actual public address of a wallet. When I import the wallet to the guarda (for example) by mnemonic it works fine. But what is actually rootkey and account? What is private key and signing key in my example? What key should i use to sign the transaction and how to get that key using cardano wasm? What private key should I use to import the wallet (if I don't want to use mnemonic for some reason)?
User contributions licensed under CC BY-SA 3.0