1

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);
  });
5
  • 1
    do you actually need a new wallet or is using walletbeacon.io to allow users to connect their own wallets an option? Ideally you should not mandate that users create a new wallet on each site
    – Simon McLoughlin
    May 15 at 17:56
  • I have to create a new wallet for each user to avoid them having a wallet like walletbeacon.io. Because my site is intended for people who do not use the blockchain or web3 and to avoid constraints. I need these wallets because on my site I will use smart contracts on the blockchain.
    – TM Paolo
    May 16 at 8:13
  • 1
    walletbeacon.io allows users to use any wallet they want. People can connect via kukai, temple, airgap etc. This allows them to use their wallet with any dApp. Having a unique wallet per website will be a bad UI/UX experience for users, as they will have to fund each one of these wallets via credit card / bank transfer, which is a cumbersome process. Any wallet can call a smart contract via walletbeacon.io also, this is how all dApps like OBJKT, Quipuswap etc all work already. Do you have a usecase that really requires your app to function differently to every other dApp?
    – Simon McLoughlin
    May 16 at 11:07
  • 1
    Creating a wallet means that you will be generating a pair of private and public keys. If you intend to store this private key on the client side, then I'm not sure if that will be secure. Because these values can be read by anyone on frontend dev tools. To ease user onboarding, you can try creating custodial wallets on your website's backend. May 16 at 11:12
  • 1
    I think for your usecase using the social login method that Kukai provides is a perfect solution. Your user can login via gmail/reddit/etc account and at the same time gets a tz2 address. Just the same way like you would create an account when you login into kukai with a gmail or twitter account. The user gets a tz2 address without even knowing it. For more ask the kukai team in their chat: t.me/KukaiWallet
    – user9011
    May 16 at 19:54

1 Answer 1

1

You could use beacon wallets, like Kukai or Temple. This would be the safest way for your users. Nevertheless, Tezos Taquito Javascript library allows you to create wallets with what is known as "In memory signer". Basically will give you what you want: create new wallets which you'll be able to programmatically interact with.

However, it appears to me that you need something that is easy for your customers. Kukai allows anyone with a Google, Facebook, Twitter or Reddit account to have a Tezos beacon wallet. So, considering easy of use, but most of all, safety, it's better to choose this path (of a beacon wallet).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.