How we can generateRecoveryPhrase from skey and vkey using cardano-cli?

Hi, Is this possible to generateRecoveryPhrase from skey or vkey using cardano-cli or cardanocli-js?

It’s not possible.

Recovery phrases encode master secrets, from which lots of public and private keys including stake keys can be derived. That’s basically, what wallets are.

skeys and vkeys are just randomly generated single keys, not belonging to a wallet. Totally different approach.

3 Likes

@HeptaSean alright thanks for your quick response. So can we generate seedPhrase from cardanocli-js.

No, but you can generate keys starting from seed phrases.

1 Like

Hey,
you can generate a NEW 15/24 words long seed phrase with cardano-wallet.

# cardano-wallet is located in cardano-wallet-v20<XX>-<XX>-<XX>-linux64
cardano-wallet recovery-phrase generate --size 24 > mnemonic-phrase.dat

Have s look on:
geldtiger.gitbook.io

BR, andi

@georgem1976 yes we can create that using cardano-wallet-js. But the formate of that keys are totally different from cardano-cli generated skey and vkey

That’s because, as said, they are totally different things. Seed phrases give access to whole wallets with lots of keys, while skey and vkey are one single pair.

The keys could be derived from the seed phrase. That’s what wallets do all the time.

But cardano-wallet (and all other wallet apps) do not offer a way to export them as files, just to use them to sign transactions.

HI @Andi1983 @HeptaSean @georgem1976 ,
Any one can tell how I can use my policy ID, Policy mintscript, Vkey, Skey generated from cardano-cli
in cardano-serialization-lib for minting NFT?

Don’t have much time for that right now. I just found these two pointers on Github:
https://github.com/Emurgo/cardano-serialization-lib/issues/381
https://gist.github.com/lovalabs/83d08796ab9ff65cbf188fbca8d03343

In the code referred to in the first answer – https://github.com/Emurgo/yoroi-frontend/blob/develop/packages/yoroi-ergo-connector/example-cardano/index.js#L567-L590 – you can see that one way to create mint scripts (and get policy IDs from them) is not to import a JSON file, but rather to build the same policy programmatically.

As for getting keys to use in CSL from skey files: skey files are JSON. In that JSON you see a field cborHex. That is the key. You can maybe load that into CSL with one of the from_bytes methods. (You probably have to strip the first four characters/two bytes, which are the CBOR header – 5820 – for a 32 byte string.)

@HeptaSean Thank you for your response. I will not take much of your time.
i am using this repo for work. when I pass my SKey created from cardano-cli. SetPrivate key Function works but it can not drive account Key and payment key. If you tell me how can you my skey payment address and v key. it would be great for me to achive my goal.

That cannot work as said close to the beginning of this thread:

You would have to import/create the payment key and the policy key directly from the values in your skey files and not use derive at all.

If you do not need interoperability with cardano-cli, you could also just forget about the skey files and go with the wallet/seed-based approach in Nami’s examples.

Yes you are right we cannot get private key from skey/vkey. What i am saying how i can use the skey and vkey in the example I mentioned about creating policy id and sign transaction.

The skey file contains a private key, so you can surely get that private key from the file.
It just cannot be used to derive other keys, since that is a totally different approach of doing things.

You’d have to rewrite that code to not derive keys from a given extended private key, but rather read the files and instantiate the payment key and the policy key from it.

Is there any example available for that so i can get more idea about that?

Not that I have seen one.

Reading a given JSON file, extracting one of the fields and cutting of the first four characters (the CBOR header) should be standard Javascript problems.

Then, you probably can get a CSL PrivateKey instance from it with from_hex: https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/pkg/cardano_serialization_lib.js.flow#L5097-L5101

Great, It was very Help full. One last question. How to burn and mint nft in single transaction. How to set quantity of nft as -1 for burning. where to set its value

You burn by setting a negative amount/quantity. And you mint by setting a positive amount/quantity.

I never tried doing both in the same transaction. Don’t know if it’s possible. But I would just try adding two mint parameters to the transaction, one with the negative, one with the positive value.

But how to do( 1. Do not have the NFT mentioned anywhere in the outputs)

I don’t understamd what you are trying to do. Of course, you can only burn tokens that you possess. They have to be in the input to the transaction.

If you just want to change the metadata, the usual approach is to mint a new one and burn it again in the next transaction.

It might be possible to mint and burn in the same transaction without the NFT appearing in the input or the output, but I’ve never seen it. Wouldn’ count on it, but it costs nothing to just try.

I just want to burn a token I am using @emurgo/cardano-serialization-lib-browser": “^9.1.2” this library. It always mints nft instead of burning.