I'm brand new to Tezos and blockchain technology. I would like when a user creates an account on my website, that it automatically creates a wallet for him on the Tezos blockchain. To be able to make interactions (smart contract) with this wallet on my website. I wanted to know how to go about it. So far I managed to generate private/public keys, Tezos Wallet address etc in JavaScript. But I don't know how to use this wallet, nor whether it really exists on the blockchain since I never interact with it... I would like to know how with this code I can interact with the blockchain. I may be totally wrong, but I would like to have some leads to be able to store a wallet on each of my users and interact with the Tezos blockchain. Thank you for your answers,
const { Sotez, cryptoUtils } = require('sotez');
var mnemonic = "";
const generate = async () => {
try {
// Generate a new random mnemonic
mnemonic = cryptoUtils.generateMnemonic();
const keys = await cryptoUtils.generateKeys(mnemonic, 'bip39_seed_password');
// {
// sk: string;
// pk: string;
// pkh: string;
// }
const encryptedSecretKey = cryptoUtils.encryptSecretKey(keys.sk, 'password');
return {
...keys,
esk: encryptedSecretKey,
};
} catch (error) {
throw new Error('Error generating Tezos wallet:', error);
}
};
generate()
.then(async (wallet) => {
console.log('Tezos Wallet Generated:');
console.log('Public Key:', wallet.pk);
console.log('Private Key:', wallet.sk);
console.log('Account Address:', wallet.pkh);
console.log('Encrypted Secret Key:', wallet.esk);
})
.catch((error) => {
console.error(error);
});