VeChain Kit Docs
ResourcesPrivyVeChainChangelog
  • VeChain Kit
    • Intro
    • Quickstart
    • Migrations
      • Migrate from DAppKit
      • Migrate Social Login Users
      • Smart Accounts v1 to v3
    • Troubleshooting
    • Connection Types
    • Send Transactions
    • Sign Messages
    • Text Records (avatar & co.)
    • Hooks
      • Wallet
      • Smart Account
      • Blockchain Hooks
      • Oracle
      • VeBetterDAO
      • veDelegate
      • vetDomains
      • Utils
      • Indexer
      • Ipfs
      • NFTs
      • Transactions
      • Signing
      • Login
    • Components
      • WalletButton
      • Open targeted modals
      • Profile Card
      • Transaction Modal
      • Transaction Toast
  • Configs
  • Utils
  • Social Login
    • Embedded Wallets
    • Smart Accounts
    • Fee Delegation
Powered by GitBook
On this page
  • Example usage
  • Example demo

Was this helpful?

Edit on GitHub
Export as PDF
  1. VeChain Kit
  2. Migrations

Smart Accounts v1 to v3

PreviousMigrate Social Login UsersNextTroubleshooting

Last updated 2 months ago

Was this helpful?

Upgrading to unlocks multi-clause support, enhanced security, and other essential features for transactions on VeChain. This feature is available in VeChain Kit from .

When integrating social login in your app, users might have a version 1 smart account. This version doesn’t support multiclause transactions, potentially causing issues within your app.

To address this scenario, consider wrapping your onClick handler or using another suitable method to prompt users to upgrade their smart accounts to version 3.

The kit makes available both the hooks to know if the upgrade is required and the component for upgrading:

  • useUpgradeRequired(smartAccountAddress, ownerAddress, targetVersion: 3) is the hook that will let you know if the user is on v1 and needs to upgrade to v3

  • useUpgradeSmartAccountModal() is the hook that will allow you to open the upgrade modal, that the user will use to upgrade.

  • You can also handle this with your own UI by using the useUpgradeSmartAccount(smartAccountAddress, targetVersion: 3) hook.

View other useful hooks .

Example usage

"use-client"

import { useConvertB3tr } from "@/hooks"
import { useWallet, useUpgradeRequired, useUpgradeSmartAccountModal } from "@vechain/vechain-kit"

// Example component allowing for B3TR to VOT3 conversion
export const ConvertModal = ({ isOpen, onClose }: Props) => {
  const { account, connectedWallet, connection } = useWallet()

  const isSmartAccountUpgradeRequired = useUpgradeRequired(
    account?.address ?? "",
    connectedWallet?.address ?? "",
    3
  )

  const { open: openUpgradeModal } = useUpgradeSmartAccountModal()
  
  // A custom convert b3tr to vot3 hook
  const convertB3trMutation = useConvertB3tr({
    amount,
  })

  const handleConvertB3tr = useCallback(() => {
    if (connection.isConnectedWithPrivy && isSmartAccountUpgradeRequired) {
      //Open Upgrade Modal
      openUpgradeModal()
      return
    }

    convertB3trMutation.resetStatus()
    convertB3trMutation.sendTransaction(undefined)
  }, [isSmartAccountUpgradeRequired, convertB3trMutation, openUpgradeModal, connection])


  return (
    <button onClick={handleConvertB3tr}> Convert my B3TR to VOT3 </button>
  )
}

You can customize the color button and size of the imported modal from the kit:

const { open: openUpgradeSmartAccountModal } = useUpgradeSmartAccountModal({
    accentColor: '#000000',
    modalSize: 'xl',
});

Example demo

With UI from the Kit

With custom UI

Smart Account v3
v1.5.0
here