import { AllowedEvmTransactionType } from '@coinbase/cdp-core'; import { APIError } from '@coinbase/cdp-core'; import { APIErrorType } from '@coinbase/cdp-core'; import { AuthenticateWithJWTResult } from '@coinbase/cdp-core'; import { Config as Config_2 } from '@coinbase/cdp-core'; import { Context } from 'react'; import { CreateDelegationOptions } from '@coinbase/cdp-core'; import { CreateDelegationResult } from '@coinbase/cdp-core'; import { CreateEvmEip7702DelegationOptions } from '@coinbase/cdp-core'; import { CreateEvmEip7702DelegationResult } from '@coinbase/cdp-core'; import { createEvmEoaAccount } from '@coinbase/cdp-core'; import { createEvmSmartAccount } from '@coinbase/cdp-core'; import { CreateEvmSmartAccountOptions } from '@coinbase/cdp-core'; import { createSolanaAccount } from '@coinbase/cdp-core'; import { CreateSpendPermissionOptions as CreateSpendPermissionOptions_2 } from '@coinbase/cdp-core'; import { CreateSpendPermissionResult } from '@coinbase/cdp-core'; import { EIP712TypedData } from '@coinbase/cdp-core'; import { EndUserEvmAccount } from '@coinbase/cdp-core'; import { EndUserEvmSmartAccount } from '@coinbase/cdp-core'; import { EndUserSolanaAccount } from '@coinbase/cdp-core'; import { EvmAddress } from '@coinbase/cdp-core'; import { EvmUserOperation } from '@coinbase/cdp-core'; import { ExecuteEvmEoaSwapResult } from '@coinbase/cdp-core'; import { ExecuteEvmSmartSwapResult } from '@coinbase/cdp-core'; import { ExecuteSwapOptions } from '@coinbase/cdp-core'; import { ExecuteSwapResult } from '@coinbase/cdp-core'; import { ExportEvmAccountOptions } from '@coinbase/cdp-core'; import { ExportEvmAccountResult } from '@coinbase/cdp-core'; import { ExportSolanaAccountOptions } from '@coinbase/cdp-core'; import { ExportSolanaAccountResult } from '@coinbase/cdp-core'; import { FetchWithX402Options } from '@coinbase/cdp-core'; import { FetchWithX402ReturnType } from '@coinbase/cdp-core'; import { getEvmEip7702DelegationOperation } from '@coinbase/cdp-core'; import { GetEvmEip7702DelegationOperationOptions } from '@coinbase/cdp-core'; import { GetMfaConfigResult } from '@coinbase/cdp-core'; import { GetProjectConfigResult } from '@coinbase/cdp-core'; import { GetSwapPriceOptions } from '@coinbase/cdp-core'; import { GetSwapPriceResult } from '@coinbase/cdp-core'; import { GetUserOperationResult } from '@coinbase/cdp-core'; import { Hex } from '@coinbase/cdp-core'; import { Hex as Hex_2 } from 'viem'; import { InitiateMfaEnrollmentResult } from '@coinbase/cdp-core'; import { InitiateMfaOptions } from '@coinbase/cdp-core'; import { InitiateMfaVerificationOptions } from 'node_modules/@coinbase/cdp-core/dist/types/actions/initiateMfaVerification.js'; import { JSX } from 'react/jsx-runtime'; import { linkEmail } from '@coinbase/cdp-core'; import { linkSms } from '@coinbase/cdp-core'; import { ListSpendPermissionsOptions } from '@coinbase/cdp-core'; import { ListSpendPermissionsResult } from '@coinbase/cdp-core'; import { MfaConfig } from '@coinbase/cdp-api-client'; import { MfaVerificationContext } from '@coinbase/cdp-core'; import { OAuth2ProviderType } from '@coinbase/cdp-core'; import { OAuthFlowState } from '@coinbase/cdp-core'; import { ProjectConfig } from '@coinbase/cdp-api-client'; import { ReactNode } from 'react'; import { RecordMfaEnrollmentPromptedResult } from '@coinbase/cdp-core'; import { RefObject } from 'react'; import { RevokeDelegationOptions } from '@coinbase/cdp-core'; import { RevokeSpendPermissionOptions as RevokeSpendPermissionOptions_2 } from '@coinbase/cdp-core'; import { RevokeSpendPermissionResult } from '@coinbase/cdp-core'; import { SecureIframeStatus } from '@coinbase/cdp-core'; import { SecureIframeTheme } from '@coinbase/cdp-core'; import { SendEvmEoaUsdcOptions } from '@coinbase/cdp-core'; import { SendEvmEoaUsdcResult } from '@coinbase/cdp-core'; import { SendEvmSmartAccountUsdcOptions } from '@coinbase/cdp-core'; import { SendEvmSmartAccountUsdcResult } from '@coinbase/cdp-core'; import { SendEvmTransactionOptions } from '@coinbase/cdp-core'; import { SendEvmTransactionResult } from '@coinbase/cdp-core'; import { SendEvmTransactionWithEndUserAccountBodyNetwork } from '@coinbase/cdp-core'; import { SendSolanaTransactionOptions } from '@coinbase/cdp-core'; import { SendSolanaTransactionResult } from '@coinbase/cdp-core'; import { SendSolanaUsdcOptions } from '@coinbase/cdp-core'; import { SendSolanaUsdcResult } from '@coinbase/cdp-core'; import { SendUsdcOptions } from '@coinbase/cdp-core'; import { SendUsdcResult } from '@coinbase/cdp-core'; import { SendUserOperationOptions } from '@coinbase/cdp-core'; import { SendUserOperationResult } from '@coinbase/cdp-core'; import { SignEvmHashOptions } from '@coinbase/cdp-core'; import { SignEvmHashResult } from '@coinbase/cdp-core'; import { SignEvmMessageOptions } from '@coinbase/cdp-core'; import { SignEvmMessageResult } from '@coinbase/cdp-core'; import { SignEvmTransactionOptions } from '@coinbase/cdp-core'; import { SignEvmTransactionResult } from '@coinbase/cdp-core'; import { SignEvmTypedDataOptions } from '@coinbase/cdp-core'; import { SignEvmTypedDataResult } from '@coinbase/cdp-core'; import { SignInWithEmailOptions } from '@coinbase/cdp-core'; import { SignInWithEmailResult } from '@coinbase/cdp-core'; import { SignInWithSiweOptions } from '@coinbase/cdp-core'; import { SignInWithSiweResult } from '@coinbase/cdp-core'; import { SignInWithSmsOptions } from '@coinbase/cdp-core'; import { SignInWithSmsResult } from '@coinbase/cdp-core'; import { SignSolanaMessageOptions } from '@coinbase/cdp-core'; import { SignSolanaMessageResult } from '@coinbase/cdp-core'; import { SignSolanaTransactionOptions } from '@coinbase/cdp-core'; import { SignSolanaTransactionResult } from '@coinbase/cdp-core'; import { SolanaAddress } from '@coinbase/cdp-core'; import { SpendPermission } from '@coinbase/cdp-core'; import { SubmitMfaEnrollmentOptions } from '@coinbase/cdp-core'; import { SubmitMfaEnrollmentResult } from '@coinbase/cdp-core'; import { SubmitMfaVerificationOptions } from '@coinbase/cdp-core'; import { SwapFees } from '@coinbase/cdp-core'; import { SwapIssues } from '@coinbase/cdp-core'; import { SwapUnavailableResult } from '@coinbase/cdp-core'; import { TransactionReceipt } from 'viem'; import { Transport } from 'viem'; import { User } from '@coinbase/cdp-core'; import { UserOperationReceipt } from '@coinbase/cdp-core'; import { VerifyEmailOTPOptions } from '@coinbase/cdp-core'; import { VerifyEmailOTPResult } from '@coinbase/cdp-core'; import { VerifySiweSignatureOptions } from '@coinbase/cdp-core'; import { VerifySiweSignatureResult } from '@coinbase/cdp-core'; import { VerifySmsOTPOptions } from '@coinbase/cdp-core'; import { VerifySmsOTPResult } from '@coinbase/cdp-core'; export { AllowedEvmTransactionType } export { APIError } export { APIErrorType } /** * Context for the CDP provider. */ export declare const CDPContext: Context; /** * Core context value interface for the CDP (Coinbase Developer Platform) provider. */ export declare interface CDPContextValue { /** Whether the CDP SDK has completed initialization */ isInitialized: boolean; /** The currently authenticated user, or null if not signed in */ currentUser: User | null; /** Convenience boolean indicating if there is an authenticated user */ isSignedIn: boolean; /** The CDP config */ config: Config; /** The current OAuth flow state */ oauthState: OAuthFlowState | null; } /** * Provider component that initializes the CDP SDK and manages authentication state. * This must be placed at the root of your application or above any components that need CDP functionality. * * @param {object} props - The component props * @param {ReactNode} props.children - React children to be rendered within the provider * @param {Config} props.config - Configuration object for initializing the CDP SDK * * @returns {JSX.Element} A React context provider wrapping the children with CDP functionality * * @example * ```tsx lines * const cdpConfig = { * projectId: "your-project-id" // Your project ID from the CDP Portal * } * * function App() { * return ( * * * * ); * } * ``` */ export declare function CDPHooksProvider({ children, config }: CDPHooksProviderProps): JSX.Element; /** * Props for the CDP Provider component */ export declare interface CDPHooksProviderProps { /** React children to be rendered within the provider */ children: ReactNode; /** Configuration object for initializing the CDP SDK */ config: Config; } /** * The config for the CDP hooks. * * @param transports - The optional transports to use for the public clients. If not provided, the default `http()` transport is used. * @returns The config for the CDP hooks. */ export declare type Config = Config_2 & { transports?: Partial>; }; export { CreateDelegationOptions } export { CreateDelegationResult } export { CreateEvmEip7702DelegationOptions } export { CreateEvmSmartAccountOptions } /** * Options for the useCreateSpendPermission hook. * * @param evmSmartAccount - The EVM Smart Account to create the spend permission for. * @param network - The network to create the spend permission on. * @param spender - The spender of the spend permission. * @param token - The token of the spend permission. * @param allowance - The allowance of the spend permission. * @param period - The period of the spend permission. * @param start - The start of the spend permission. * @param end - The end of the spend permission. * @param salt - The salt of the spend permission. * @param extraData - The extra data of the spend permission. * @param useCdpPaymaster - Whether to use the CDP Paymaster for the user operation. * @param paymasterUrl - The paymaster URL of the spend permission. */ export declare type CreateSpendPermissionOptions = Omit & { evmSmartAccount?: EvmAddress; }; export { EIP712TypedData } export { EvmAddress } /** Delegation operation result (EvmEip7702DelegationOperation) from the API. */ export declare type EvmEip7702DelegationOperationResult = Awaited>; export { ExecuteEvmEoaSwapResult } export { ExecuteEvmSmartSwapResult } export { ExecuteSwapOptions } export { ExecuteSwapResult } export { ExportEvmAccountOptions } export { ExportEvmAccountResult } export { ExportSolanaAccountOptions } export { ExportSolanaAccountResult } export { GetEvmEip7702DelegationOperationOptions } export { GetSwapPriceOptions } export { GetSwapPriceResult } export { GetUserOperationResult } export { Hex } /** * Callback function invoked when MFA verification is required. * The consumer should show their custom MFA UI when this is called. * * This callback does not need to be memoized - the hook handles stability internally. * * @param context - The MFA verification context containing available methods. */ export declare type MfaRequiredCallback = (context: MfaVerificationContext) => void; export { OAuth2ProviderType } export { OAuthFlowState } export { RevokeDelegationOptions } /** * Options for the useRevokeSpendPermission hook. * * @param evmSmartAccount - The EVM Smart Account to revoke the spend permission for. * @param network - The network to revoke the spend permission on. * @param permissionHash - The hash of the spend permission to revoke. * @param useCdpPaymaster - Whether to use the CDP Paymaster for the user operation. * @param paymasterUrl - The paymaster URL for the spend permission. */ export declare type RevokeSpendPermissionOptions = Omit & { evmSmartAccount?: EvmAddress; }; export { SendEvmTransactionOptions } export { SendEvmTransactionResult } export { SendSolanaTransactionOptions } export { SendSolanaTransactionResult } /** * Represents the data from a USDC transaction across all account types. * Uses a discriminated union to properly represent different transaction types: * - EOA: transactionHash + optional TransactionReceipt (populated when confirmed) * - Smart Account: userOpHash + optional transactionHash + UserOperationReceipt[] * - Solana: transactionSignature */ export declare type SendUsdcTransactionData = { type: "evm-eoa"; transactionHash: Hex; receipt?: TransactionReceipt; } | { type: "evm-smart"; userOpHash: Hex; transactionHash?: Hex; receipts?: UserOperationReceipt[]; userOperation?: GetUserOperationResult; } | { type: "solana"; transactionSignature: string; }; export { SignEvmHashOptions } export { SignEvmHashResult } export { SignEvmMessageOptions } export { SignEvmMessageResult } export { SignEvmTransactionOptions } export { SignEvmTransactionResult } export { SignEvmTypedDataOptions } export { SignEvmTypedDataResult } export { SignInWithEmailOptions } export { SignInWithEmailResult } export { SpendPermission } /** * A page of spend permissions. */ export declare type SpendPermissionPage = { spendPermissions: ListSpendPermissionsResult["spendPermissions"]; hasNextPage: boolean; nextPageToken?: string; }; /** * Represents the status of a request. * - "idle": No request in progress. * - "pending": Request sent, waiting for confirmation. * - "success": Request confirmed, includes result. * - "error": Request failed, includes error details. */ export declare type Status = "idle" | "pending" | "success" | "error"; export { SwapFees } export { SwapIssues } /** * Transaction data for the `useSwap` hook, discriminated by account type. * * @see {@link SwapTransactionEvmEoaData} * @see {@link SwapTransactionEvmSmartData} */ export declare type SwapTransactionData = SwapTransactionEvmEoaData | SwapTransactionEvmSmartData; /** * Transaction data for the `useSwap` hook, when the account is an EOA. * * @interface */ export declare type SwapTransactionEvmEoaData = ExecuteEvmEoaSwapResult & { /** The transaction receipt for the EOA transaction. */ receipt?: TransactionReceipt; }; /** * Transaction data for the `useSwap` hook, when the account is a Smart Account. * * @interface */ export declare type SwapTransactionEvmSmartData = ExecuteEvmSmartSwapResult & { /** The user operation receipts for the Smart Account transaction. */ receipts?: UserOperationReceipt[]; /** The user operation result for the Smart Account transaction. */ userOperation?: EvmUserOperation; /** The hash of the transaction that included this particular user operation. */ transactionHash?: Hex_2; }; export { SwapUnavailableResult } /** * Represents the state of an EVM EOA transaction. * - "idle": No transaction in progress. * - "pending": Transaction sent, waiting for confirmation. * - "success": Transaction confirmed, includes receipt. * - "error": Transaction failed, includes error details. */ export declare type TransactionState = { status: "idle"; } | { status: "pending"; hash: Hex; } | { status: "success"; receipt: TransactionReceipt; } | { status: "error"; error: Error; }; /** * Hook that provides access to authenticate end users with developer-issued JWTs. * Use this when integrating with third-party identity providers (Auth0, Firebase, Cognito, etc.). * * **Important**: Before using this hook, you must: * 1. Configure custom auth in the CDP Portal (JWKS endpoint, issuer, etc.) * 2. Provide a `customAuth.getJwt` callback in your CDP initialization config * * @example * ```tsx lines * // React - With Auth0 * import { useAuth0 } from '@auth0/auth0-react'; * import { useAuthenticateWithJWT } from '@coinbase/cdp-hooks'; * * function AuthButton() { * const { getAccessTokenSilently } = useAuth0(); * const { authenticateWithJWT } = useAuthenticateWithJWT(); * const [error, setError] = useState(null); * * const handleLogin = async () => { * try { * // Authenticate with CDP (uses customAuth.getJwt callback) * const { user, isNewUser } = await authenticateWithJWT(); * * console.log('Authenticated user:', user); * if (isNewUser) { * console.log('New user created with wallet!'); * } * } catch (err) { * setError(err.message); * } * }; * * return ( *
* * {error &&

Error: {error}

} *
* ); * } * ``` * * @example * ```tsx lines * // React Native - With Auth0 * import { useAuth0 } from 'react-native-auth0'; * import { useAuthenticateWithJWT } from '@coinbase/cdp-hooks'; * import { Button, Text, View } from 'react-native'; * * function AuthScreen() { * const { authorize } = useAuth0(); * const { authenticateWithJWT } = useAuthenticateWithJWT(); * const [error, setError] = useState(null); * * const handleLogin = async () => { * try { * // Step 1: Trigger Auth0 login (opens browser) * await authorize(); * * // Step 2: Authenticate with CDP * const { user, isNewUser } = await authenticateWithJWT(); * * console.log('Authenticated user:', user); * if (isNewUser) { * console.log('New user created with wallet!'); * } * } catch (err) { * setError(err.message); * } * }; * * return ( * * * * ); * } * ``` */ export declare function useCancelMfaVerification(): { cancelMfaVerification: () => void; }; /** * Hook to get the CDP being used by the SDK. * * @example * ```tsx lines * function App() { * const { config } = useConfig(); * * return ( *
*

Project ID: {config.projectId}

*
* ); * } * ``` * @returns {{ config: Config }} */ export declare const useConfig: () => { config: Config_2; }; /** * Hook that provides a function to create a delegation allowing a developer to sign on behalf of an end user. * * @returns An object containing the createDelegation function. * * @example * ```tsx * const { createDelegation } = useCreateDelegation(); * const result = await createDelegation({ expiresAt: '2025-12-31T23:59:59Z' }); * console.log(result.delegationId); * ``` */ export declare function useCreateDelegation(): UseCreateDelegationReturnType; /** * Return type of the `useCreateDelegation` hook. */ export declare type UseCreateDelegationReturnType = { /** Function to create a delegation for the current end user. */ createDelegation: (options: CreateDelegationOptions) => Promise; }; /** * Hook that creates an EIP-7702 delegation and then polls until the delegation operation is COMPLETED. * - data: Create result (delegationOperationId). Set when create succeeds. * - status: Delegation operation result (EvmEip7702DelegationOperation). Set when polling reaches COMPLETED. * * @returns createEvmEip7702Delegation, data (CreateEvmEip7702DelegationResult), status (EvmEip7702DelegationOperation), error. * * @example * ```tsx * const { createEvmEip7702Delegation, data, status, error } = useCreateEvmEip7702Delegation(); * await createEvmEip7702Delegation({ address: '0x...', network: 'base-sepolia' }); * // data.delegationOperationId - operation ID from create * // status - delegation operation (status.status === 'COMPLETED', status.transactionHash) * ``` */ export declare function useCreateEvmEip7702Delegation(): UseCreateEvmEip7702DelegationReturnType; /** * Return type of the `useCreateEvmEip7702Delegation` hook. * - data: CreateEvmEip7702DelegationResult (delegationOperationId). * - status: EvmEip7702DelegationOperationResult (operation status). */ export declare type UseCreateEvmEip7702DelegationReturnType = { createEvmEip7702Delegation: (options: CreateEvmEip7702DelegationOptions) => Promise; /** Create result (delegation operation ID). Set when create succeeds. */ data: CreateEvmEip7702DelegationResult | undefined; /** Delegation operation result (EvmEip7702DelegationOperation). Set when polling reaches COMPLETED. */ status: EvmEip7702DelegationOperationResult | undefined; error: Error | undefined; }; /** * A hook for creating an EVM EOA (Externally Owned Account) for the current user. * This function will throw an error if the user already has an EVM EOA account. * * @returns {object} An object containing the createEvmEoaAccount function. * * @example * ```tsx * import { useCreateEvmEoaAccount } from '@coinbase/cdp-hooks'; * * function MyComponent() { * const { createEvmEoaAccount } = useCreateEvmEoaAccount(); * * const handleCreateAccount = async () => { * try { * const account = await createEvmEoaAccount(); * console.log('EVM EOA account created:', account); * } catch (error) { * console.error('Failed to create EVM EOA account:', error); * } * }; * * return ; * } * ``` */ export declare function useCreateEvmEoaAccount(): { createEvmEoaAccount: typeof createEvmEoaAccount; }; /** * A hook for creating a EVM Smart Account for the current user. * If no owner is provided, a new EOA will be created as the owner. * If an owner is provided, it must not already control another smart account for this user. * * @returns {object} An object containing the createSmartAccount function. * * @example * ```tsx * import { useCreateEvmSmartAccount } from '@coinbase/cdp-hooks'; * * function MyComponent() { * const { createEvmSmartAccount } = useCreateEvmSmartAccount(); * * const handleCreateAccount = async () => { * try { * // Create with a new EOA owner * const account = await createEvmSmartAccount({ * enableSpendPermissions: true * }); * console.log('EVM Smart Account created:', account); * * // Or create with a specific owner * const accountWithOwner = await createEvmSmartAccount({ * owner: '0x1234...', * enableSpendPermissions: false * }); * } catch (error) { * console.error('Failed to create EVM Smart Account:', error); * } * }; * * return ; * } * ``` */ export declare function useCreateEvmSmartAccount(): { createEvmSmartAccount: typeof createEvmSmartAccount; }; /** * A hook for creating a Solana account for the current user. * This function will throw an error if the user already has a Solana account. * * @returns {object} An object containing the createSolanaAccount function. * * @example * ```tsx * import { useCreateSolanaAccount } from '@coinbase/cdp-hooks'; * * function MyComponent() { * const { createSolanaAccount } = useCreateSolanaAccount(); * * const handleCreateAccount = async () => { * try { * const account = await createSolanaAccount(); * console.log('Solana account created:', account); * } catch (error) { * console.error('Failed to create Solana account:', error); * } * }; * * return ; * } * ``` */ export declare function useCreateSolanaAccount(): { createSolanaAccount: typeof createSolanaAccount; }; /** * Hook that provides a wrapped function to create spend permissions for EVM Smart Accounts with enhanced developer experience. * This hook automatically resolves token addresses, handles periodInDays, and auto-detects the owner Smart Account from the current user. * * @example * ```tsx lines * function CreateSpendPermission() { * const { createSpendPermission } = useCreateSpendPermission(); * * const handleCreateSpendPermission = async () => { * try { * const result = await createSpendPermission({ * network: "base-sepolia", * spender: "0x742D35Cc6634C0532925a3b8D6Ec6F1C2b9c1E46", * token: "usdc", // Automatically resolves to USDC contract address * allowance: parseUnits("10", 6), // 10 USDC * periodInDays: 7, // 7 days (automatically converted to seconds) * useCdpPaymaster: true * }); * console.log("User Operation Hash:", result.userOperationHash); * } catch (error) { * console.error("Failed to create spend permission:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ createSpendPermission: (input: CreateSpendPermissionInput) => Promise }} */ export declare const useCreateSpendPermission: () => UseCreateSpendPermissionReturnType; /** * Return type for the useCreateSpendPermission hook. * * @param createSpendPermission - The function to create a spend permission. */ export declare type UseCreateSpendPermissionReturnType = { createSpendPermission: (options: CreateSpendPermissionOptions) => Promise; data: GetUserOperationResult | undefined; error: Error | undefined; status: Status; }; /** * Hook to access the currently authenticated user's information. * * @example * ```tsx lines * function UserProfile() { * const { currentUser } = useCurrentUser(); * * if (!currentUser) { * return null; * } * * return ( *
*

User Profile

*

User ID: {currentUser.userId}

*

EVM Accounts: {currentUser.evmAccountObjects.map(acc => acc.address).join(", ")}

*
* ); * } * ``` * @returns {{ currentUser: User | null }} */ export declare const useCurrentUser: () => { currentUser: User | null; }; /** * Higher-order hook that wraps a callback with authentication enforcement. * This ensures that the wrapped function can only be called when the user is signed in. * * @template TArgs - Array type representing the arguments of the callback * @template TReturn - Type representing the return value of the callback * @param {(...args: TArgs) => Promise} callback - The async function to wrap with authentication check * @returns {(...args: TArgs) => Promise} A wrapped version of the callback that checks authentication * @throws {Error} Throws an error if the user is not authenticated when the callback is invoked */ export declare const useEnforceAuthenticated: (callback: (...args: TArgs) => Promise) => ((...args: TArgs) => Promise); /** * Higher-order hook that wraps a callback with unauthenticated enforcement. * This ensures that the wrapped function can only be called when the user is not signed in. * * @template TArgs - Array type representing the arguments of the callback * @template TReturn - Type representing the return value of the callback * @param {(...args: TArgs) => Promise} callback - The async function to wrap with authentication check * @returns {(...args: TArgs) => Promise} A wrapped version of the callback that checks authentication * @throws {Error} Throws an error if the user is authenticated when the callback is invoked */ export declare const useEnforceUnauthenticated: (callback: (...args: TArgs) => Promise) => ((...args: TArgs) => Promise); /** * Hook to access all EVM account objects for the current user. * Returns an array of account objects with address and creation timestamp. * Users can have up to 10 EVM accounts. * * @example * ```tsx lines * function EVMAccountsList() { * const { evmAccounts } = useEvmAccounts(); * * if (!evmAccounts || evmAccounts.length === 0) { * return

No EVM accounts found

; * } * * return ( *
*

Your EVM Accounts

*
    * {evmAccounts.map((account, index) => ( *
  • * Account {index + 1}: {account.address} *
    * Created: {new Date(account.createdAt).toLocaleDateString()} *
  • * ))} *
*
* ); * } * ``` * @returns {{ evmAccounts: EndUserEvmAccount[] | null }} */ export declare const useEvmAccounts: () => { evmAccounts: EndUserEvmAccount[] | null; }; /** * Hook to access the user's primary EVM (Ethereum Virtual Machine) address. * Returns the first Smart Account if available, otherwise returns the first EOA. * If the user has neither, this will return null. * * **Note:** This hook always returns the first account (index 0) as the "primary" address. * If your users may have multiple accounts and need to select between them, use * `useEvmAccounts()` instead to get all accounts with metadata. * * **Priority:** Smart Account [0] → EOA [0] → null * * @example * ```tsx lines * function EVMWalletInfo() { * const { evmAddress } = useEvmAddress(); * * if (!evmAddress) { * return

No EVM wallet connected

; * } * * return ( *
*

Your EVM Wallet

*

Address: {evmAddress}

*
* ); * } * ``` * @returns {{ evmAddress: EvmAddress | null }} * @see useEvmAccounts for multi-account support * @see useEvmSmartAccounts for smart account specific access */ export declare const useEvmAddress: () => { evmAddress: EvmAddress | null; }; /** * A hook for creating a secure iframe to export EVM private keys. * * This hook handles the communication with a secure iframe that safely * exports EVM private keys to the user's clipboard without exposing them to the * JavaScript context. * * The iframe will be automatically cleaned up when the component unmounts * or when the session expires. * * @param {UseKeyExportIframeOptions} options - Configuration options for the EVM key export iframe. * @returns {UseKeyExportIframeResult} An object containing the iframe status and control functions. * * @example * ```tsx * import { useEvmKeyExportIframe } from '@coinbase/cdp-hooks'; * import { useRef } from 'react'; * * function EvmKeyExportButton() { * const containerRef = useRef(null); * const { status } = useEvmKeyExportIframe({ * address: "0x1234...", * containerRef, * label: "Copy Private Key", * }); * * return ( *
*

Status: {status ?? 'initializing'}

*
*
* ); * } * ``` */ export declare function useEvmKeyExportIframe(options: UseKeyExportIframeOptions): UseKeyExportIframeResult; /** * Hook to access all EVM smart account objects for the current user. * Returns an array of smart account objects with address, owner addresses, and creation timestamp. * Each EVM EOA can own one smart account. * * @example * ```tsx lines * function SmartAccountsList() { * const { evmSmartAccounts } = useEvmSmartAccounts(); * * if (!evmSmartAccounts || evmSmartAccounts.length === 0) { * return

No smart accounts found

; * } * * return ( *
*

Your Smart Accounts

*
    * {evmSmartAccounts.map((account, index) => ( *
  • * Smart Account {index + 1}: {account.address} *
    * Owners: {account.ownerAddresses.join(', ')} *
    * Created: {new Date(account.createdAt).toLocaleDateString()} *
  • * ))} *
*
* ); * } * ``` * @returns {{ evmSmartAccounts: EndUserEvmSmartAccount[] | null }} */ export declare const useEvmSmartAccounts: () => { evmSmartAccounts: EndUserEvmSmartAccount[] | null; }; /** * Hook that provides a wrapped function to export EVM account private keys with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to export. * * @example * ```tsx lines * function ExportPrivateKey() { * const { exportEvmAccount } = useExportEvmAccount(); * const { evmAddress } = useEvmAddress(); * * const handleExport = async () => { * if (!evmAddress) return; * * try { * const { privateKey } = await exportEvmAccount({ * evmAccount: evmAddress * }); * console.log("Private Key:", privateKey); * } catch (error) { * console.error("Failed to export private key:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ exportEvmAccount: (options: ExportEvmAccountOptions) => Promise }} * * @deprecated This function will be removed soon. Use `useEvmKeyExportIframe` instead for a more secure key export experience * that never exposes the private key to your application's JavaScript context. * * @see {@link useEvmKeyExportIframe} */ export declare const useExportEvmAccount: () => { exportEvmAccount: (options: ExportEvmAccountOptions) => Promise; }; /** * Hook that provides a wrapped function to export Solana account private keys with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to export. * * @example * ```tsx lines * function ExportSolanaPrivateKey() { * const { exportSolanaAccount } = useExportSolanaAccount(); * const { solanaAddress } = useSolanaAddress(); * * const handleExport = async () => { * if (!solanaAddress) return; * * try { * const { privateKey } = await exportSolanaAccount({ * solanaAccount: solanaAddress * }); * console.log("Private Key:", privateKey); * } catch (error) { * console.error("Failed to export private key:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ exportSolanaAccount: (options: ExportSolanaAccountOptions) => Promise }} * * @deprecated This function will be removed soon. Use `useSolanaKeyExportIframe` instead for a more secure key export experience * that never exposes the private key to your application's JavaScript context. * * @see {@link useSolanaKeyExportIframe} */ export declare const useExportSolanaAccount: () => { exportSolanaAccount: (options: ExportSolanaAccountOptions) => Promise; }; /** * Hook to get the access token for the current user. * * @example * ```tsx lines * const { getAccessToken } = useGetAccessToken(); * * const handleGetAccessToken = async () => { * const accessToken = await getAccessToken(); * console.log("Access Token:", accessToken); * }; * ``` * @returns {{ getAccessToken: () => Promise }} Function to get the access token for the current user */ export declare const useGetAccessToken: () => { getAccessToken: () => Promise; }; /** * A hook for getting the status of an EIP-7702 delegation operation. * Used to check the progress of a delegation operation created via createEvmEip7702Delegation. * * @returns An object containing the getEvmEip7702DelegationOperation function. * * @example * ```tsx * import { useGetEvmEip7702DelegationOperation } from '@coinbase/cdp-hooks'; * * function MyComponent() { * const { getEvmEip7702DelegationOperation } = useGetEvmEip7702DelegationOperation(); * * const handleCheckOperation = async () => { * try { * const operation = await getEvmEip7702DelegationOperation({ * delegationOperationId: 'op-123', * }); * console.log('Operation status:', operation.status); // PENDING | SUBMITTED | COMPLETED | FAILED * } catch (error) { * console.error('Failed to get operation:', error); * } * }; * * return ; * } * ``` */ export declare function useGetEvmEip7702DelegationOperation(): { getEvmEip7702DelegationOperation: typeof getEvmEip7702DelegationOperation; }; /** * A hook for getting the MFA configuration for the current project. * * @returns {object} An object containing the getMfaConfig function. */ export declare function useGetMfaConfig(): { getMfaConfig: () => Promise< GetMfaConfigResult>; }; /** * A hook for getting the project configuration for the current project. * * @returns {object} An object containing the getProjectConfig function. */ export declare function useGetProjectConfig(): { getProjectConfig: () => Promise< GetProjectConfigResult>; }; /** * Reactive query hook that fetches a non-binding indicative price for a token swap. * Automatically fetches when the user is signed in and all required parameters are provided. * Includes preflight `issues` in the response (e.g. insufficient balance or allowance). * * When the token pair, network, account, or userId changes, previous data is cleared. When only the * amount or slippage changes, previous data is preserved while the new price loads * (stale-while-revalidate). * * @param options - Configuration for the swap price query. * * @example * ```tsx * import { useGetSwapPrice } from "@coinbase/cdp-hooks"; * * function SwapPriceDisplay() { * const [fromAmount, setFromAmount] = useState(""); * * const { data, status, error, refetch, reset } = useGetSwapPrice({ * network: "base", * fromToken: "0x4200000000000000000000000000000000000006", * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", * fromAmount, * }); * * return ( *
* setFromAmount(e.target.value)} * placeholder="0" * /> * {status === "pending" &&

Loading price...

} * {data?.liquidityAvailable &&

Expected output: {data.toAmount}

} * {error &&

Error: {error.message}

} * * *
* ); * } * ``` * * @returns An object containing the swap price data, status, error, refetch, and reset functions. */ export declare const useGetSwapPrice: (options?: UseGetSwapPriceOptions) => UseGetSwapPriceReturnType; /** * Options for the `useGetSwapPrice` hook. */ export declare interface UseGetSwapPriceOptions extends Partial { /** Set to `false` to prevent automatic fetching even when all parameters are present. Defaults to `true`. */ enabled?: boolean; } /** Return type of the `useGetSwapPrice` hook. */ export declare type UseGetSwapPriceReturnType = { /** The most recent result from `getSwapPrice`. Cleared when the token pair, network, account, or userId changes. Preserved as stale data during re-fetches triggered by amount or slippage changes. */ data: GetSwapPriceResult | SwapUnavailableResult | undefined; /** The status of the `getSwapPrice` function. */ status: Status; /** The error returned from the `getSwapPrice` function. */ error: Error | undefined; /** A function to refetch the swap price. */ refetch: () => void; /** A function to reset the state of the hook. */ reset: () => void; }; /** * A hook for initiating MFA enrollment for the current user. * * @returns {object} An object containing the initiateMfaEnrollment function. */ export declare function useInitiateMfaEnrollment(): { initiateMfaEnrollment: (options: InitiateMfaOptions) => Promise< InitiateMfaEnrollmentResult>; }; /** * A hook for initiating MFA verification for sensitive operations. * * @returns {object} An object containing the initiateMfaVerification function. */ export declare function useInitiateMfaVerification(): { initiateMfaVerification: (options: InitiateMfaVerificationOptions) => Promise; }; /** * Hook to check if the CDP client has been properly initialized. * This should be used before attempting any CDP operations to ensure the client is ready. * * @example * ```tsx lines * function LoadingGuard({ children }) { * const { isInitialized } = useIsInitialized(); * * if (!isInitialized) { * return
Loading...
; * } * * return children; * } * ``` * @returns {{ isInitialized: boolean }} */ export declare const useIsInitialized: () => { isInitialized: boolean; }; /** * Hook to check if a user is currently signed in. * Use this to gate authenticated-only features in your application. * * @example * ```tsx lines * function AuthGuard({ children }) { * const { isSignedIn } = useIsSignedIn(); * * if (!isSignedIn) { * return ; * } * * return children; * } * ``` * @returns {{ isSignedIn: boolean }} */ export declare const useIsSignedIn: () => { isSignedIn: boolean; }; /** * Options for the EVM and Solana key export iframe hooks. */ export declare interface UseKeyExportIframeOptions { /** * The address of the account to export. */ address: string; /** * A ref to the container element where the iframe will be appended. */ containerRef: RefObject; /** * The label for the button displayed in the iframe. */ label?: string; /** * The label to display when the key is copied successfully. */ copiedLabel?: string; /** * Whether to show an icon in the button. * * @default true */ icon?: boolean; /** * Theme overrides for the iframe button. */ theme?: Partial; } /** * Return type for the key export iframe hooks. */ export declare interface UseKeyExportIframeResult { /** * The current status of the iframe. */ status: SecureIframeStatus | null; /** * Optional message associated with the status. */ message: string | undefined; /** * Function to update the theme of the iframe. */ updateTheme: (theme: Partial) => void; /** * Function to manually clean up the iframe. * Note: Cleanup is automatic when the component unmounts or when the iframe expires. */ cleanup: () => void; } /** * A hook for linking an Apple account to the current user. * This is a convenience wrapper around useLinkOAuth for Apple provider. * * @returns {object} An object containing the linkApple function and oauthState. */ export declare function useLinkApple(): { linkApple: (options?: { idempotencyKey?: string; }) => Promise; oauthState: OAuthFlowState | null; }; /** * A hook for linking an email account to the current user. * * @returns {object} An object containing the linkEmail function. */ export declare function useLinkEmail(): { linkEmail: typeof linkEmail; }; /** * A hook for linking a Google account to the current user. * This is a convenience wrapper around useLinkOAuth for Google provider. * * @returns {object} An object containing the linkGoogle function and oauthState. */ export declare function useLinkGoogle(): { linkGoogle: () => Promise; oauthState: OAuthFlowState | null; }; /** * A hook for linking an OAuth account to the current user. * * @returns {object} An object containing the linkOAuth function and oauthState. * * @example * ```tsx lines * // Google * function LinkOAuthProvider() { * const { linkOAuth } = useLinkOAuth(); * const { currentUser } = useCurrentUser(); * * const handleLinkGoogle = async () => { * if (!currentUser) { * console.error("User must be signed in first"); * return; * } * * try { * await linkOAuth("google"); * } catch (error) { * console.error("Failed to link Google account:", error); * } * }; * * return ( * * ); * } *``` * * @example * ```tsx lines * // Apple * function LinkOAuthProvider() { * const { linkOAuth } = useLinkOAuth(); * const { currentUser } = useCurrentUser(); * * const handleLinkApple = async () => { * if (!currentUser) { * console.error("User must be signed in first"); * return; * } * * try { * await linkOAuth("apple"); * } catch (error) { * console.error("Failed to link Apple account:", error); * } * }; * * return ( * * ); * } *``` * * @example * ```tsx lines * // X * function LinkOAuthProvider() { * const { linkOAuth } = useLinkOAuth(); * const { currentUser } = useCurrentUser(); * * const handleLinkX = async () => { * if (!currentUser) { * console.error("User must be signed in first"); * return; * } * * try { * await linkOAuth("x"); * } catch (error) { * console.error("Failed to link X account:", error); * } * }; * * return ( * * ); * } * ``` */ export declare function useLinkOAuth(): { linkOAuth: (providerType: OAuth2ProviderType, options?: { idempotencyKey?: string; }) => Promise; oauthState: OAuthFlowState | null; }; /** * A hook for linking a SMS account to the current user. * * @returns {object} An object containing the linkSms function. */ export declare function useLinkSms(): { linkSms: typeof linkSms; }; /** * A hook for linking a Telegram account to the current user. * This is a convenience wrapper around useLinkOAuth for Telegram provider. * * @returns {object} An object containing the linkTelegram function and oauthState. */ export declare function useLinkTelegram(): { linkTelegram: () => Promise; oauthState: OAuthFlowState | null; }; /** * Hook that lists spend permissions for an EVM Smart Account with refetch capability. * This hook follows a query-style pattern for one-time data fetching. * * @example * ```tsx lines * function SpendPermissionsList() { * const { data, error, status, refetch } = useListSpendPermissions(); * * if (status === "pending") { * return
Loading spend permissions...
; * } * * if (status === "error") { * return
Error: {error?.message}
; * } * * return ( *
* *

Spend Permissions ({data?.spendPermissions.length})

* {data?.spendPermissions.map((permission) => ( *
*

Hash: {permission.permissionHash}

*

Spender: {permission.permission.spender}

*

Token: {permission.permission.token}

*

Allowance: {permission.permission.allowance}

*

Revoked: {permission.revoked ? "Yes" : "No"}

*
* ))} *
* ); * } * ``` * * @param options - Configuration object with properties: * evmSmartAccount (auto-detected if not provided), * network (defaults to "base-sepolia"), * pageSize (defaults to 20), * pageToken (for pagination), and * enabled (whether the query should run, defaults to true when account is available). * @returns Query result with data, loading state, error information, and refetch function */ export declare const useListSpendPermissions: (options?: UseListSpendPermissionsOptions) => UseListSpendPermissionsReturnType; /** * Options for the useListSpendPermissions hook. */ export declare type UseListSpendPermissionsOptions = Partial & { enabled?: boolean; }; /** * Return type for the useListSpendPermissions hook. */ export declare type UseListSpendPermissionsReturnType = { data: SpendPermissionPage | undefined; error: Error | undefined; status: Status; refetch: () => void; }; /** * A hook for reading the pre-fetched MFA configuration for the current project. * The config is fetched during SDK initialization and cached in core state. * Returns null if MFA is not configured (404 during init). * * @returns The MFA configuration, null if not configured, or undefined if not initialized. */ export declare function useMfaConfig(): { mfaConfig: undefined; } | { mfaConfig: MfaConfig | null; }; /** * Hook to access the current OAuth flow state. * This can be used to track the status of an ongoing OAuth authentication flow. * * @example * ```tsx lines * function OAuthStatus() { * const { oauthState } = useOAuthState(); * * if (!oauthState) { * return null; * } * * return ( *
*

OAuth Status: {oauthState.status}

* {oauthState.status === "error" && ( *

Error: {oauthState.errorDescription}

* )} *
* ); * } * ``` * @returns {{ oauthState: OAuthFlowState | null }} The current OAuth flow state */ export declare const useOAuthState: () => { oauthState: OAuthFlowState | null; }; /** * A hook for reading the pre-fetched project configuration. * The config is fetched during SDK initialization and cached in core state. * Returns null if the project is not configured (404 during init). * * @returns The project configuration, null if not configured, or undefined if not initialized. */ export declare function useProjectConfig(): { projectConfig: undefined; } | { projectConfig: ProjectConfig | null; }; export { User } /** * A hook for recording when the end user was prompted for MFA enrollment. * This should be called when the user is shown the MFA enrollment prompt, * regardless of whether they choose to enroll or skip. * * @returns {object} An object containing the recordMfaEnrollmentPrompted function. */ export declare function useRecordMfaEnrollmentPrompted(): { recordMfaEnrollmentPrompted: (options?: { idempotencyKey?: string; }) => Promise< RecordMfaEnrollmentPromptedResult>; }; /** * Hook to register a listener for MFA verification requirements. * * When a sensitive operation (like signing a transaction) requires MFA verification, * the `onMfaRequired` callback will be invoked. The consumer should show their custom * MFA UI and use `useInitiateMfaVerification` and `useSubmitMfaVerification` to * complete the verification flow. * * After successful MFA verification, the original operation will automatically continue. * * @param onMfaRequired - Callback invoked when MFA verification is required. * @param options - Optional configuration including scope element. * * @example * ```tsx * // In this example, MfaModal would implement the MFA verification flow using * // useInitiateMfaVerification and useSubmitMfaVerification hooks * function App() { * const [showMfaModal, setShowMfaModal] = useState(false); * const [mfaMethods, setMfaMethods] = useState([]); * const { cancelMfaVerification } = useCancelMfaVerification(); * * useRegisterMfaListener(({ methods }) => { * setMfaMethods(methods); * setShowMfaModal(true); * }); * * const handleClose = () => { * cancelMfaVerification(); * setShowMfaModal(false); * }; * * return ( * <> * * * * ); * } * ``` */ export declare function useRegisterMfaListener(onMfaRequired: MfaRequiredCallback, options?: UseRegisterMfaListenerOptions): void; /** * Options for the useRegisterMfaListener hook. */ export declare interface UseRegisterMfaListenerOptions { /** * Optional ref to a container element for scoped handling. * When provided, the handler only responds to MFA triggers from within this element. * When omitted, the handler responds to any MFA trigger (global handler). */ scope?: RefObject; /** * Whether the listener should be registered. * When false, the listener is not registered. * Useful for conditionally enabling/disabling the listener. * * @default true */ enabled?: boolean; } /** * Hook that provides a function to revoke all active delegations for the current end user. * * @returns An object containing the revokeDelegation function. * * @example * ```tsx * const { revokeDelegation } = useRevokeDelegation(); * await revokeDelegation(); * ``` */ export declare function useRevokeDelegation(): UseRevokeDelegationReturnType; /** * Return type of the `useRevokeDelegation` hook. */ export declare type UseRevokeDelegationReturnType = { /** Function to revoke all active delegations for the current end user. */ revokeDelegation: (options?: RevokeDelegationOptions) => Promise; }; /** * Hook that provides a wrapped function to revoke spend permissions for EVM Smart Accounts with enhanced developer experience. * This hook automatically handles user operation tracking and provides status updates. * * @example * ```tsx lines * function RevokeSpendPermission({ permissionHash }) { * const { revokeSpendPermission, data, error, status } = useRevokeSpendPermission(); * * const handleRevokeSpendPermission = async () => { * try { * const result = await revokeSpendPermission({ * network: "base-sepolia", * permissionHash: permissionHash, * useCdpPaymaster: true * }); * console.log("User Operation Hash:", result.userOperationHash); * } catch (error) { * console.error("Failed to revoke spend permission:", error); * } * }; * * return ( *
* {status === "pending" &&

Revoking permission...

} * {status === "success" && data && ( *
*

Permission revoked successfully!

*

Transaction Hash: {data.transactionHash}

*
* )} * {status === "error" &&

Error: {error?.message}

} * *
* ); * } * ``` * @returns {{ revokeSpendPermission: (input: RevokeSpendPermissionInput) => Promise }} */ export declare const useRevokeSpendPermission: () => UseRevokeSpendPermissionReturnType; /** * Return type for the useRevokeSpendPermission hook. * * @param revokeSpendPermission - The function to revoke a spend permission. */ export declare type UseRevokeSpendPermissionReturnType = { revokeSpendPermission: (options: RevokeSpendPermissionOptions) => Promise; data: GetUserOperationResult | undefined; error: Error | undefined; status: Status; }; export { UserOperationReceipt } /** * Hook to send USDC on an EVM network from an EOA (Externally Owned Account). * * This hook waits for the transaction receipt and provides real-time status updates. * * @example * ```tsx * import { useSendEvmEoaUsdc, useEvmAddress } from "@coinbase/cdp-hooks"; * * function MyComponent() { * const { sendEvmEoaUsdc, data } = useSendEvmEoaUsdc(); * const { evmAddress } = useEvmAddress(); * * const handleSendUsdc = async () => { * if (!evmAddress || data.status === "pending") return; * * try { * const result = await sendEvmEoaUsdc({ * evmAccount: evmAddress, * to: "0x1234567890123456789012345678901234567890", * amount: "25.50", * network: "base-sepolia", * }); * * console.log("Transaction Hash:", result.transactionHash); * } catch (error) { * console.error("Failed to send USDC:", error); * } * }; * * const isPending = data.status === "pending"; * * return ( *
* * {data.status === "success" &&

USDC sent successfully

} * {data.status === "error" &&

Error: {data.error?.message ?? "Unable to send USDC"}

} *
* ); * } * ``` * * @returns {{ sendEvmEoaUsdc: (options: SendEvmEoaUsdcOptions) => Promise, data: TransactionState }} */ export declare const useSendEvmEoaUsdc: () => { sendEvmEoaUsdc: (options: SendEvmEoaUsdcOptions) => Promise; data: TransactionState; }; /** * Hook to send USDC on an EVM network from a Smart Account. * * This hook waits for the user operation to complete and provides real-time status updates. * Returns user operation data rather than transaction receipts, since Smart Account * transactions use ERC-4337 user operations. * * @example * ```tsx * import { useSendEvmSmartAccountUsdc, useCurrentUser } from "@coinbase/cdp-hooks"; * * function MyComponent() { * const { sendEvmSmartAccountUsdc, status, data, error } = useSendEvmSmartAccountUsdc(); * const { currentUser } = useCurrentUser(); * const evmSmartAccount = currentUser?.evmSmartAccountObjects?.[0]?.address; * * const handleSendUsdc = async () => { * if (!evmSmartAccount) return; * * try { * const result = await sendEvmSmartAccountUsdc({ * evmSmartAccount, * to: "0x1234567890123456789012345678901234567890", * amount: "10.00", * network: "base-sepolia", * useCdpPaymaster: true, // Optional: sponsor gas fees * }); * * console.log("User Operation Hash:", result.userOpHash); * } catch (error) { * console.error("Failed to send USDC:", error); * } * }; * * return ( *
* {status === "pending" &&
Sending USDC...
} * {status === "success" && data && ( *
*
USDC sent! TX: {data.transactionHash}
*
Status: {data.status}
*
* )} * {status === "error" &&
Error: {error?.message}
} * *
* ); * } * ``` * * @returns {UseSendEvmSmartAccountUsdcReturnType} */ export declare const useSendEvmSmartAccountUsdc: () => UseSendEvmSmartAccountUsdcReturnType; /** * Represents the return type of the `useSendEvmSmartAccountUsdc` hook. * Extends UseWaitForUserOperationReturnType with a send function. */ export declare type UseSendEvmSmartAccountUsdcReturnType = { sendEvmSmartAccountUsdc: (options: SendEvmSmartAccountUsdcOptions) => Promise; } & UseWaitForUserOperationReturnType; /** * Hook that provides a wrapped function to send EVM transactions with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to send. * The hook internally waits for transactions to succeed and returns the related success/error * via the `data` discriminated union object. * * Note: The `data` returned from the hook only represents the *last* sent transaction. If you wish to * call one instance of the hook multiple times in quick succession it is recommended to save the * txHash returned from `sendEvmTransaction` yourself and handle waiting for the receipt. * * @example * ```tsx lines * function SendTransaction() { * const { sendEvmTransaction, data } = useSendEvmTransaction(); * const { evmAddress } = useEvmAddress(); * * const handleSend = async () => { * if (!evmAddress) return; * * try { * const result = await sendEvmTransaction({ * evmAccount: evmAddress, * network: "base-sepolia", * transaction: { * to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * value: 100000000000000n, // 0.0001 ETH in wei * nonce: 0, * gas: 21000n, * maxFeePerGas: 30000000000n, * maxPriorityFeePerGas: 1000000000n, * chainId: 84532, // Base Sepolia * type: "eip1559" * } * }); * console.log("Transaction Hash:", result.transactionHash); * } catch (error) { * console.error("Failed to send transaction:", error); * } * }; * * return ( *
* {(() => { * switch (data.status) { * case "idle": * return

No transaction in progress

; * case "pending": * return ( *
*

Transaction pending...

*

Hash: {data.hash}

*
* ); * case "success": * return ( *
*

Transaction successful!

*

Block: {data.receipt.blockNumber.toString()}

*

Gas used: {data.receipt.gasUsed.toString()}

*
* ); * case "error": * return ( *
*

Transaction failed

*

Error: {data.error.message}

*
* ); * } * })()} *
* * ); * } * ``` * @returns {{ sendEvmTransaction: (options: SendEvmTransactionOptions) => Promise, data: TransactionState }} */ export declare const useSendEvmTransaction: () => { sendEvmTransaction: (options: SendEvmTransactionOptions) => Promise; data: TransactionState; }; /** * Hook that provides a wrapped function to send Solana transactions with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to send. * * @example * ```tsx * import { useSendSolanaTransaction, useSolanaAddress } from "@coinbase/cdp-hooks"; * * function MyComponent() { * const { sendSolanaTransaction } = useSendSolanaTransaction(); * const { data: solanaAddress } = useSolanaAddress(); * * const handleSend = async () => { * if (solanaAddress) { * const result = await sendSolanaTransaction({ * solanaAccount: solanaAddress, * network: "solana-devnet", * transaction: "base64EncodedTransaction..." * }); * console.log("Transaction signature:", result.transactionSignature); * } * }; * * return ; * } * ``` * * @returns {{ sendSolanaTransaction: (options: SendSolanaTransactionOptions) => Promise }} */ export declare const useSendSolanaTransaction: () => { sendSolanaTransaction: (options: SendSolanaTransactionOptions) => Promise; }; /** * Hook to send USDC on the Solana network. * * @example * ```tsx * import { useSendSolanaUsdc, useSolanaAddress } from "@coinbase/cdp-hooks"; * * function MyComponent() { * const { sendSolanaUsdc } = useSendSolanaUsdc(); * const { solanaAddress } = useSolanaAddress(); * * const handleSendUsdc = async () => { * if (!solanaAddress) return; * * try { * const result = await sendSolanaUsdc({ * solanaAccount: solanaAddress, * to: "ExXhNkgYf6efh7YyqDRVxPZuzafobao1A74drUdp8trd", * amount: "10.00", * network: "solana-devnet", * createRecipientAta: true, * }); * console.log("Transaction Signature:", result.transactionSignature); * } catch (error) { * console.error("Failed to send USDC:", error); * } * }; * * return ; * } * ``` * * @returns {{ sendSolanaUsdc: (options: SendSolanaUsdcOptions) => Promise }} */ export declare const useSendSolanaUsdc: () => { sendSolanaUsdc: (options: SendSolanaUsdcOptions) => Promise; }; /** * Hook to send USDC on EVM or Solana networks with automatic address type detection. * * For EVM EOA accounts, this hook waits for transaction receipt. * For EVM Smart Accounts, this hook waits for user operation completion. * For Solana accounts, returns the transaction signature immediately. * * If `from` is not provided, automatically selects the address only when there is exactly * one account to avoid ambiguity. If multiple accounts exist, explicit selection is required. * * @example * ```tsx * import { useSendUsdc } from "@coinbase/cdp-hooks"; * * function SendUsdcComponent() { * const { sendUsdc, data, error, status } = useSendUsdc(); * * // Simplest usage - auto-selects sender address * const handleSendSimple = async () => { * try { * const result = await sendUsdc({ * to: "0x1234567890123456789012345678901234567890", * amount: "10.00", * network: "base-sepolia", * }); * console.log("Sent!", result); * } catch (error) { * console.error("Failed to send USDC:", error); * } * }; * * // Or explicitly specify sender * const handleSendExplicit = async () => { * try { * const result = await sendUsdc({ * from: "0x1234567890123456789012345678901234567890", * to: "0x9876543210987654321098765432109876543210", * amount: "10.00", * network: "base-sepolia", * }); * * if (result.type === "evm-eoa") { * console.log("EOA TX:", result.transactionHash); * } else if (result.type === "evm-smart") { * console.log("Smart Account UserOp:", result.userOpHash); * } else { * console.log("Solana TX:", result.transactionSignature); * } * } catch (error) { * console.error("Failed to send USDC:", error); * } * }; * * return ( *
* * * {status === "success" && data &&

USDC sent successfully!

} * {error &&

Error: {error.message}

} *
* ); * } * ``` * * @returns UseSendUsdcReturnType */ export declare const useSendUsdc: () => UseSendUsdcReturnType; /** * Represents the return type of the `useSendUsdc` hook. */ export declare type UseSendUsdcReturnType = { sendUsdc: (options: SendUsdcOptions) => Promise; data: SendUsdcTransactionData | undefined; error: Error | undefined; status: Status; }; /** * Hook that provides a wrapped function to send user operations from Smart Accounts with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to send user operations. * The hook internally waits for user operations to succeed and returns the related success/error * via the `data` discriminated union object. * * Note: The `data` returned from the hook only represents the *last* sent user operation. If you wish to * call one instance of the hook multiple times in quick succession it is recommended to save the * userOperationHash returned from `sendUserOperation` yourself and handle waiting for the result. * * @example * ```tsx lines * function SendUserOperation() { * const { sendUserOperation, data, isError, error } = useSendUserOperation(); * const { currentUser } = useCurrentUser(); * * const handleSendUserOperation = async () => { * const smartAccount = currentUser?.evmSmartAccounts?.[0]; * if (!smartAccount) return; * * try { * const result = await sendUserOperation({ * evmAccount: smartAccount, * network: "base-sepolia", * calls: [{ * to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * value: "0x0", * data: "0x", * }], * dataSuffix: "0x62617365617070070080218021802180218021802180218021", // Optional: ERC-8021 attribution * }); * console.log("User Operation Hash:", result.userOperationHash); * } catch (error) { * console.error("Failed to send user operation:", error); * } * }; * * return ( *
* {isError &&

Error: {error?.message}

} * {data && ( *
*

User operation successful!

*

Transaction Hash: {data.transactionHash}

*
* )} * *
* ); * } * ``` * @returns {{ sendUserOperation: (options: SendUserOperationOptions) => Promise, data: GetUserOperationResult | undefined, isError: boolean, error: Error | null, isSuccess: boolean }} */ export declare const useSendUserOperation: () => UseSendUserOperationReturnType; /** * Represents the return type of the `useSendUserOperation` hook. */ export declare type UseSendUserOperationReturnType = { sendUserOperation: (options: SendUserOperationOptions) => Promise; data: GetUserOperationResult | undefined; error: Error | undefined; status: Status; }; /** * Hook that provides a wrapped function to sign EVM messages with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign. * * @example * ```tsx lines * function SignHash() { * const { signEvmHash } = useSignEvmHash(); * const { evmAddress } = useEvmAddress(); * * const handleSign = async () => { * if (!evmAddress) return; * * try { * const result = await signEvmHash({ * evmAccount: evmAddress, * hash: "0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0" * }); * console.log("Signature:", result.signature); * } catch (error) { * console.error("Failed to sign hash:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ signEvmHash: (options: SignEvmHashOptions) => Promise }} */ export declare const useSignEvmHash: () => { signEvmHash: (options: SignEvmHashOptions) => Promise; }; /** * Hook that provides a wrapped function to sign EVM messages with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign. * * @example * ```tsx lines * function SignMessage() { * const { signEvmMessage } = useSignEvmMessage(); * const { evmAddress } = useEvmAddress(); * * const handleSign = async () => { * if (!evmAddress) return; * * try { * const result = await signEvmMessage({ * evmAccount: evmAddress, * message: "Welcome to our dApp! Click to sign in." * }); * console.log("Signature:", result.signature); * } catch (error) { * console.error("Failed to sign message:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ signEvmMessage: (options: SignEvmMessageOptions) => Promise }} */ export declare const useSignEvmMessage: () => { signEvmMessage: (options: SignEvmMessageOptions) => Promise; }; /** * Hook that provides a wrapped function to sign EVM transactions with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign. * * @example * ```tsx lines * function SignTransaction() { * const { signEvmTransaction } = useSignEvmTransaction(); * const { evmAddress } = useEvmAddress(); * * const handleSign = async () => { * if (!evmAddress) return; * * try { * const result = await signEvmTransaction({ * evmAccount: evmAddress, * transaction: { * to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * value: 100000000000000n, // 0.0001 ETH in wei * nonce: 0, * gas: 21000n, * maxFeePerGas: 30000000000n, * maxPriorityFeePerGas: 1000000000n, * chainId: 84532, // Base Sepolia * type: "eip1559" * } * }); * console.log("Signed Transaction:", result.signedTransaction); * } catch (error) { * console.error("Failed to sign transaction:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ signEvmTransaction: (options: SignEvmTransactionOptions) => Promise }} */ export declare const useSignEvmTransaction: () => { signEvmTransaction: (options: SignEvmTransactionOptions) => Promise; }; /** * Hook that provides a wrapped function to sign EIP-712 typed data with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign. * * @example * ```tsx lines * function SignTypedData() { * const { signEvmTypedData } = useSignEvmTypedData(); * const { evmAddress } = useEvmAddress(); * * const handleSign = async () => { * if (!evmAddress) return; * * try { * const result = await signEvmTypedData({ * evmAccount: evmAddress, * typedData: { * domain: { * name: "USDC", * version: "2", * chainId: 84532, * verifyingContract: "0x036CbD53842c5426634e7929541eC2318f3dCF7e" * }, * types: { * EIP712Domain: [ * { name: "name", type: "string" }, * { name: "version", type: "string" }, * { name: "chainId", type: "uint256" }, * { name: "verifyingContract", type: "address" } * ], * TransferWithAuthorization: [ * { name: "from", type: "address" }, * { name: "to", type: "address" }, * { name: "value", type: "uint256" }, * { name: "validAfter", type: "uint256" }, * { name: "validBefore", type: "uint256" }, * { name: "nonce", type: "bytes32" } * ] * }, * primaryType: "TransferWithAuthorization", * message: { * from: evmAddress, * to: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB", * value: "1000000", // 1 USDC * validAfter: 0, * validBefore: 2524604400, * nonce: 0 * } * } * }); * console.log("Signature:", result.signature); * } catch (error) { * console.error("Failed to sign typed data:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ signEvmTypedData: (options: SignEvmTypedDataOptions) => Promise }} */ export declare const useSignEvmTypedData: () => { signEvmTypedData: (options: SignEvmTypedDataOptions) => Promise; }; /** * Hook that provides access to the email-based sign-in functionality. * This is the first step in the email authentication flow. * * @example * ```tsx lines * function SignInForm() { * const [email, setEmail] = useState(""); * const [flowId, setFlowId] = useState(""); * const { signInWithEmail } = useSignInWithEmail(); * * const handleSubmit = async (e) => { * e.preventDefault(); * try { * const result = await signInWithEmail({ email }); * setFlowId(result.flowId); * } catch (error) { * console.error("Failed to sign in:", error); * } * }; * * return ( *
* setEmail(e.target.value)} * placeholder="Enter your email" * aria-label="Enter your email" * /> * *
* ); * } * ``` * @returns {{ signInWithEmail: (options: SignInWithEmailOptions) => Promise }} */ export declare const useSignInWithEmail: () => { signInWithEmail: (options: SignInWithEmailOptions) => Promise; }; /** * Hook that provides access to the OAuth sign-in functionality (Google, Apple, and X are currently supported). * This is the first step in the OAuth authentication flow. * In a web application, this will redirect the user to the OAuth provider sign in page. * This sign in method is not yet supported on mobile. * * @returns {{ signInWithOAuth: (providerType: OAuth2ProviderType) => Promise }} * * @example * ```tsx lines * // Google * function SignInForm() { * const { signInWithOAuth } = useSignInWithOAuth(); * * const handleSignInWithGoogle = () => { * void signInWithOAuth("google"); * }; * * return ( * * ); * } * ``` * * @example * ```tsx lines * // Apple * function SignInForm() { * const { signInWithOAuth } = useSignInWithOAuth(); * * const handleSignInWithApple = () => { * void signInWithOAuth("apple"); * }; * * return ( * * ); * } * ``` * * @example * ```tsx lines * // X * function SignInForm() { * const { signInWithOAuth } = useSignInWithOAuth(); * * const handleSignInWithX = () => { * void signInWithOAuth("x"); * }; * * return ( * * ); * } * ``` */ export declare const useSignInWithOAuth: () => { signInWithOAuth: (providerType: OAuth2ProviderType, options?: { idempotencyKey?: string; }) => Promise; oauthState: OAuthFlowState | null; }; /** * Hook that provides access to the Sign In With Ethereum (SIWE/EIP-4361) initiation functionality. * This is the first step in the SIWE authentication flow. After calling `signInWithSiwe`, * sign the returned message with the user's Ethereum wallet and pass the signature to * `useVerifySiweSignature`. * * @example * ```tsx lines * function SignInWithEthereum() { * const { signInWithSiwe } = useSignInWithSiwe(); * * const handleSignIn = async () => { * try { * const result = await signInWithSiwe({ * address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", * chainId: 1, * domain: "example.com", * uri: "https://example.com", * }); * // Sign result.message with the user's wallet * const signature = await wallet.signMessage(result.message); * // Then call verifySiweSignature with result.flowId and signature * } catch (error) { * console.error("Failed to initiate SIWE:", error); * } * }; * * return ; * } * ``` * @returns {{ signInWithSiwe: (options: SignInWithSiweOptions) => Promise }} */ export declare const useSignInWithSiwe: () => { signInWithSiwe: (options: SignInWithSiweOptions) => Promise; }; /** * Hook that provides access to the SMS-based sign-in functionality. * This is the first step in the SMS authentication flow. * * @example * ```tsx lines * function SignInForm() { * const [phoneNumber, setPhoneNumber] = useState(""); * const [flowId, setFlowId] = useState(""); * const { signInWithSms } = useSignInWithSms(); * * const handleSubmit = async (e) => { * e.preventDefault(); * try { * const result = await signInWithSms({ phoneNumber }); * setFlowId(result.flowId); * } catch (error) { * console.error("Failed to sign in:", error); * } * }; * * return ( *
* setPhoneNumber(e.target.value)} * placeholder="Enter your phone number" * aria-label="Enter your phone number" * /> * *
* ); * } * ``` * @returns {{ signInWithSms: (options: SignInWithSmsOptions) => Promise }} */ export declare const useSignInWithSms: () => { signInWithSms: (options: SignInWithSmsOptions) => Promise; }; /** * Hook that provides a wrapped sign-out function with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign out. * * @example * ```tsx lines * function SignOutButton() { * const { signOut } = useSignOut(); * const navigate = useNavigate(); * * const handleSignOut = async () => { * try { * await signOut(); * navigate("/sign-in"); * } catch (error) { * console.error("Failed to sign out:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ signOut: () => Promise }} */ export declare const useSignOut: () => { signOut: () => Promise; }; /** * Hook that provides a wrapped function to sign messages with a Solana account with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign. * * @example * ```tsx lines * function SignSolanaMessage() { * const { signSolanaMessage } = useSignSolanaMessage(); * const { solanaAddress } = useSolanaAddress(); * * const handleSign = async () => { * if (!solanaAddress) return; * * try { * const result = await signSolanaMessage({ * solanaAccount: solanaAddress, * message: "Welcome to our dApp! Click to sign in." * }); * console.log("Signature:", result.signature); * } catch (error) { * console.error("Failed to sign message:", error); * } * }; * * return ; * } * ``` * * @returns {{ signSolanaMessage: (options: SignSolanaMessageOptions) => Promise }} */ export declare const useSignSolanaMessage: () => { signSolanaMessage: (options: SignSolanaMessageOptions) => Promise; }; /** * Hook that provides a wrapped function to sign Solana transactions with authentication checks. * This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign. * * @example * ```tsx lines * function SignSolanaTransaction() { * const { signSolanaTransaction } = useSignSolanaTransaction(); * const { solanaAddress } = useSolanaAddress(); * * const handleSign = async () => { * if (!solanaAddress) return; * * try { * const result = await signSolanaTransaction({ * solanaAccount: solanaAddress, * transaction: "base64-encoded-transaction" * }); * console.log("Signed Transaction:", result.signedTransaction); * } catch (error) { * console.error("Failed to sign transaction:", error); * } * }; * * return ( * * ); * } * ``` * @returns {{ signSolanaTransaction: (options: SignSolanaTransactionOptions) => Promise }} */ export declare const useSignSolanaTransaction: () => { signSolanaTransaction: (options: SignSolanaTransactionOptions) => Promise; }; /** * Hook to access all Solana account objects for the current user. * Returns an array of account objects with address and creation timestamp. * Users can have up to 10 Solana accounts. * * @example * ```tsx lines * function SolanaAccountsList() { * const { solanaAccounts } = useSolanaAccounts(); * * if (!solanaAccounts || solanaAccounts.length === 0) { * return

No Solana accounts found

; * } * * return ( *
*

Your Solana Accounts

*
    * {solanaAccounts.map((account, index) => ( *
  • * Account {index + 1}: {account.address} *
    * Created: {new Date(account.createdAt).toLocaleDateString()} *
  • * ))} *
*
* ); * } * ``` * @returns {{ solanaAccounts: EndUserSolanaAccount[] | null }} */ export declare const useSolanaAccounts: () => { solanaAccounts: EndUserSolanaAccount[] | null; }; /** * Hook to access the user's primary Solana address. * Returns the first Solana address associated with the user's account. * If the user has no Solana accounts, this will return null. * * **Note:** This hook always returns the first account (index 0) as the "primary" address. * If your users may have multiple Solana accounts and need to select between them, use * `useSolanaAccounts()` instead to get all accounts with metadata. * * @example * ```tsx lines * function SolanaWalletInfo() { * const { solanaAddress } = useSolanaAddress(); * * if (!solanaAddress) { * return

No Solana wallet connected

; * } * * return ( *
*

Your Solana Wallet

*

Address: {solanaAddress}

*
* ); * } * ``` * @returns {{ solanaAddress: SolanaAddress | null }} * @see useSolanaAccounts for multi-account support */ export declare const useSolanaAddress: () => { solanaAddress: SolanaAddress | null; }; /** * A hook for creating a secure iframe to export Solana private keys. * * This hook handles the communication with a secure iframe that safely * exports Solana private keys to the user's clipboard without exposing them to the * JavaScript context. * * The iframe will be automatically cleaned up when the component unmounts * or when the session expires. * * @param {UseKeyExportIframeOptions} options - Configuration options for the Solana key export iframe. * @returns {UseKeyExportIframeResult} An object containing the iframe status and control functions. * * @example * ```tsx * import { useSolanaKeyExportIframe } from '@coinbase/cdp-hooks'; * import { useRef } from 'react'; * * function SolanaKeyExportButton() { * const containerRef = useRef(null); * const { status } = useSolanaKeyExportIframe({ * address: "ABC123...", * containerRef, * label: "Copy Private Key", * }); * * return ( *
*

Status: {status ?? 'initializing'}

*
*
* ); * } * ``` */ export declare function useSolanaKeyExportIframe(options: UseKeyExportIframeOptions): UseKeyExportIframeResult; /** * A hook for submitting MFA enrollment with a verification code. * * @returns {object} An object containing the submitMfaEnrollment function. */ export declare function useSubmitMfaEnrollment(): { submitMfaEnrollment: (options: SubmitMfaEnrollmentOptions) => Promise< SubmitMfaEnrollmentResult>; }; /** * A hook for submitting MFA verification with a verification code. * * @returns {object} An object containing the submitMfaVerification function. */ export declare function useSubmitMfaVerification(): { submitMfaVerification: (options: SubmitMfaVerificationOptions) => Promise; }; /** * Hook that executes a token swap and waits for on-chain confirmation. * * For EOA accounts, waits for a transaction receipt. * For smart accounts, polls the user operation until it completes. * * @example * ```tsx * import { useSwap } from "@coinbase/cdp-hooks"; * * function SwapComponent() { * const { swap, data, status, error } = useSwap(); * * const handleSwap = () => { * swap({ * network: "base", * fromToken: "0x4200000000000000000000000000000000000006", * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", * fromAmount: "100000000000000000", * slippageBps: 100, * }); * }; * * return ( *
* * {status === "success" && data &&

Swap confirmed!

} * {error &&

Error: {error.message}

} *
* ); * } * ``` * * @returns UseSwapReturnType */ export declare const useSwap: () => UseSwapReturnType; /** Return type of the `useSwap` hook. */ export declare type UseSwapReturnType = { /** The function to execute a swap. */ swap: (options: ExecuteSwapOptions) => Promise; /** The data returned from the `swap` function. */ data: SwapTransactionData | undefined; /** The status of the `swap` function. */ status: Status; /** The error returned from the `swap` function or due to polling the user operation. */ error: Error | undefined; /** Resets the hook to its initial idle state, clearing data, error, and status. */ reset: () => void; }; /** * Hook that provides access to the email OTP verification functionality. * This is the second step in the email authentication flow, used after signInWithEmail. * * @example * ```tsx lines * function OTPVerification(flowId: string) { * const [otp, setOTP] = useState(""); * const { verifyEmailOTP } = useVerifyEmailOTP(); * * const otpIsValid = useMemo(() => { * // Check if the OTP is a 6 digit number * return /^[0-9]{6}$/.test(otp); * }, [otp]); * * const handleSubmit = async (e) => { * e.preventDefault(); * * try { * const { user } = await verifyEmailOTP({ * flowId, * otp * }); * * // Handle the result * console.log(user); * } catch (error) { * console.error("Failed to verify OTP:", error); * } * }; * * return ( *
* setOTP(e.target.value)} * placeholder="Enter OTP from email" * aria-label="Enter OTP from email" * /> * *
* ); * } * ``` * @returns {{ verifyEmailOTP: (options: VerifyEmailOTPOptions) => Promise }} */ export declare const useVerifyEmailOTP: () => { verifyEmailOTP: (options: VerifyEmailOTPOptions) => Promise; }; /** * Hook that provides access to the SIWE signature verification functionality. * This is the second step in the SIWE authentication flow, used after `useSignInWithSiwe`. * * @example * ```tsx lines * const { verifySiweSignature } = useVerifySiweSignature(); * const { user } = await verifySiweSignature({ flowId, signature }); * ``` * @returns {{ verifySiweSignature: (options: VerifySiweSignatureOptions) => Promise }} */ export declare const useVerifySiweSignature: () => { verifySiweSignature: (options: VerifySiweSignatureOptions) => Promise; }; /** * Hook that provides access to the SMS OTP verification functionality. * This is the second step in the SMS authentication flow, used after signInWithSms. * * @example * ```tsx lines * function OTPVerification(flowId: string) { * const [otp, setOTP] = useState(""); * const { verifySmsOTP } = useVerifySmsOTP(); * * const otpIsValid = useMemo(() => { * // Check if the OTP is a 6 digit number * return /^[0-9]{6}$/.test(otp); * }, [otp]); * * const handleSubmit = async (e) => { * e.preventDefault(); * * try { * const { user } = await verifySmsOTP({ * flowId, * otp * }); * * // Handle the result * console.log(user); * } catch (error) { * console.error("Failed to verify OTP:", error); * } * }; * * return ( *
* setOTP(e.target.value)} * placeholder="Enter OTP from SMS" * aria-label="Enter OTP from SMS" * /> * *
* ); * } * ``` * @returns {{ verifySmsOTP: (options: VerifySmsOTPOptions) => Promise }} */ export declare const useVerifySmsOTP: () => { verifySmsOTP: (options: VerifySmsOTPOptions) => Promise; }; /** * Hook that polls an EIP-7702 delegation operation until it reaches COMPLETED or FAILED. * Use this after creating a delegation to get the final operation result in React state. * * @param parameters - Delegation operation ID to poll, plus optional `enabled`. * @returns `{ data, error }` — when polling reaches COMPLETED, `data` is the EvmEip7702DelegationOperation. * * @example * ```tsx * const { data, error } = useWaitForEvmEip7702Delegation({ * delegationOperationId: 'op-123', * enabled: !!operationId, * }); * // When data is set, data.status === 'COMPLETED' and data.transactionHash may be set. * ``` */ export declare function useWaitForEvmEip7702Delegation(parameters?: UseWaitForEvmEip7702DelegationParameters): UseWaitForEvmEip7702DelegationReturnType; /** * Parameters for the `useWaitForEvmEip7702Delegation` hook. */ export declare type UseWaitForEvmEip7702DelegationParameters = { /** The delegation operation ID to poll. */ delegationOperationId?: string; /** When false, polling does not run. Defaults to true when delegationOperationId is set. */ enabled?: boolean; }; /** * Return type of the `useWaitForEvmEip7702Delegation` hook. */ export declare type UseWaitForEvmEip7702DelegationReturnType = { data: EvmEip7702DelegationOperationResult | undefined; error: Error | undefined; }; /** * Hook that waits for a user operation to be confirmed and provides its current state. * This hook polls the user operation status until it's confirmed or fails. * * Note: The `data` returned from the hook only represents the *last* sent user operation. If you wish to * call one instance of the hook multiple times in quick succession it is recommended to save the * userOpHash returned from `waitForUserOperation` yourself and handle waiting for the result. * * @example * ```tsx lines * function WaitForUserOperation() { * const { status, data, error } = useWaitForUserOperation({ * userOperationHash: "0x1234...", * evmSmartAccount: "0x1234567890123456789012345678901234567890", * network: "base-sepolia" * }); * * return ( *
* {status === "error" &&

Error: {error?.message}

} * {status === "success" && ( *
*

User operation successful!

*

Transaction Hash: {data.transactionHash}

*
* )} *
* ); * } * ``` * * @param parameters - Configuration object for waiting for user operation * @param parameters.userOperationHash - The user operation hash to wait for * @param parameters.evmSmartAccount - The smart account address * @param parameters.network - The network to query * @param parameters.enabled - Whether the query should be enabled (defaults to true when hash is provided) * @returns Query result with data, loading state, and error information */ export declare const useWaitForUserOperation: (parameters?: UseWaitForUserOperationParameters) => UseWaitForUserOperationReturnType; /** * Represents the parameters for the `useWaitForUserOperation` hook. */ export declare type UseWaitForUserOperationParameters = { userOperationHash?: Hex; evmSmartAccount?: EvmAddress; network?: SendEvmTransactionWithEndUserAccountBodyNetwork; enabled?: boolean; }; /** * Represents the return type of the `useWaitForUserOperation` hook. */ export declare type UseWaitForUserOperationReturnType = { status: Status; data: GetUserOperationResult | undefined; error: Error | undefined; }; /** * Hook that provides a fetch function with X402 payment handling. * * @param options - Configuration object for the fetch function * @param options.address - The address to use for the fetch function * @returns A fetch function with X402 payment handling * * @example * ```tsx lines * const { fetchWithPayment } = useX402(); * const response = await fetchWithPayment("https://x402-resource.com", { * method: "GET", * }); * ``` */ export declare function useX402(options?: UseX402Options): UseX402ReturnType; declare type UseX402Options = FetchWithX402Options; declare type UseX402ReturnType = FetchWithX402ReturnType; export { VerifyEmailOTPOptions } export { VerifyEmailOTPResult } export { }