diff --git a/advanced/wallets/react-wallet-v2/src/components/SmartAccountCard.tsx b/advanced/wallets/react-wallet-v2/src/components/SmartAccountCard.tsx
index 3c3354bb8..4df793dec 100644
--- a/advanced/wallets/react-wallet-v2/src/components/SmartAccountCard.tsx
+++ b/advanced/wallets/react-wallet-v2/src/components/SmartAccountCard.tsx
@@ -1,6 +1,6 @@
import ChainCard from '@/components/ChainCard'
import SettingsStore from '@/store/SettingsStore'
-import { truncate } from '@/utils/HelperUtil'
+import { styledToast, truncate } from '@/utils/HelperUtil'
import { updateSignClientChainId } from '@/utils/WalletConnectUtil'
import { Avatar, Button, Text, Tooltip, Loading } from '@nextui-org/react'
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
@@ -134,7 +134,7 @@ export default function SmartAccountCard({
css={{ marginTop: 10, width: '100%' }}
onClick={onCreateSmartAccount}
>
- {loading ? : 'Create Smart Account'}
+ {loading ? : 'Create Smart Account'}
>
)}
diff --git a/advanced/wallets/react-wallet-v2/src/hooks/useSmartAccount.ts b/advanced/wallets/react-wallet-v2/src/hooks/useSmartAccount.ts
index aae507209..a3f307487 100644
--- a/advanced/wallets/react-wallet-v2/src/hooks/useSmartAccount.ts
+++ b/advanced/wallets/react-wallet-v2/src/hooks/useSmartAccount.ts
@@ -1,5 +1,7 @@
import { SmartAccountLib } from "@/lib/SmartAccountLib";
+import { styledToast } from "@/utils/HelperUtil";
import { useCallback, useEffect, useState } from "react";
+import { TransactionExecutionError } from "viem";
export default function useSmartAccount(signerPrivateKey: `0x${string}`) {
const [loading, setLoading] = useState(false)
@@ -14,6 +16,12 @@ export default function useSmartAccount(signerPrivateKey: `0x${string}`) {
setLoading(false)
}
catch (e) {
+ if (e instanceof TransactionExecutionError) {
+ // shorten the error message
+ styledToast(e.cause.message, 'error')
+ } else if (e instanceof Error) {
+ styledToast(e.message, 'error')
+ }
console.error(e)
setLoading(false)
}