IV. Ephemeral Wallets with VeChain SDK

veSave application leverages the VeChain SDK for a variety of tasks, one important element of VeChainSDK are Ephemeral Wallets.

What are Ephemeral Wallets

Ephemeral wallets are temporary wallets generated in-browser during a user session. They enable lightweight, session-based interactions that are ideal for social logins or guest users.

Ephemeral wallets can:

  • Sign transactions via SDK

  • Be fee-delegated for gasless UX

  • Be discarded after the session ends (no persistent storage required)

How It Works

In the ./src/hooks/useEphemeralWallets.ts file, you will find how you can generate private and public keys on VeChain.

You can generate them using the .generatePrivateKey() method and process the public key of that wallet using the Address.ofPrivateKey() method.

That looks like this:

const buildMockWalletSession = async (): Promise<WalletSession> => {
  const vechainKey = await Secp256k1.generatePrivateKey()
  const vechainAddress = Address.ofPrivateKey(vechainKey).digits

  return {
    sessionId: `mock-session-${Date.now().toString(16)}`,
    ethereum: { address: `0x${randomHex(40)}` },
    vechain: { address: `0x${vechainAddress}` },
  }
}

Security Note:
These wallets are meant for temporary use only. They are not persisted or encrypted, and should never be used for storing user funds. Always prompt users to switch to a connected wallet (e.g., VeWorld) before executing real transactions.