Is it possible to generate new address and private key for cardano using blockfrost.io api, that later on can use for transactions and adding it into wallet.
thank you
Short answer is no, because it poses a security risk for both them (generating and transmitting keys over the network) and the end-user consuming their service to do so (trusting the API not to log or persist those keys).
As with all other blockchains, the responsibility of generating (and securely storing) keys and addresses generally lie with the end-user who wants to interact with it. As they say, not your keys, not your wallet.
That said, you can generate them through:
It is also worthwhile mentioning that you should practice extreme caution when generating the keys yourself. I highly recommend using an air-gapped machine, never storing the raw recovery-phrase digitally (raw text,photo,etc.) and never sharing it with anyone else.
Looking at the docs at https://docs.blockfrost.io/ I'm pretty sure that's not possible.
Your best option might be to use a package like this, if your in nodejs:
https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs
(or this version for the browser: https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser)
The generation of keys with this library is explained here:
and can look something like this:
const rootKey = Bip32PrivateKey.generate_ed25519_bip32();
const harden = (num: number): number => {
return 0x80000000 + num;
}
const accountKey = rootKey.derive(harden(1852)).derive(harden(1815)).derive(harden(0));
const utxoPubKey = accountKey.derive(0).derive(0);
const stakeKey = accountKey.derive(2).derive(0);
const baseAddress = BaseAddress.new(
NetworkInfo.testnet().network_id(), // Testnet
StakeCredential.from_keyhash(utxoPubKey.to_public().to_raw_key().hash()),
StakeCredential.from_keyhash(stakeKey.to_public().to_raw_key().hash())
)
console.log("New address: ", baseAddress.to_address().to_bech32())
There are of course also other ways to generate the keys, eg. via the CLI: https://developers.cardano.org/docs/stake-pool-course/handbook/keys-addresses/