Skip to main content

Usage

Parameters

  • transfer / transferAsync both accept an object with:
    • params (TransferHookInput):
      • encryptKey (string): PIN used to decrypt the private key.
      • wallet (WalletData): the wallet object. Pass the full object from createWallet / useGetWallet — publicKey, encryptedPrivateKey, walletType, and signerKind. walletType picks the execution path (SHHH wallets use outside execution). If you omit it, the SDK reads the account class on-chain; pass it anyway, since an undeployed wallet or an RPC error falls back to "READY", which reverts on a SHHH account. signerKind is SHHH-only (defaults to "STARK").
      • token (ChainToken): Token identifier (e.g. ChainToken.USDC).
      • usePasskey (boolean, optional): When true, the hook prompts for the wallet passkey itself and uses the derived key, replacing encryptKey. Requires externalUserId; pass credentialId to pick the passkey. Do not combine with your own setupPasskey/authenticate calls.
      • externalUserId (string, optional): Required with usePasskey.
      • credentialId (string, optional): The wallet passkey’s credential id, used with usePasskey.
      • otherToken (optional): Custom token configuration with:
        • contractAddress (string): ERC-20 token contract address.
        • decimals (number): Token decimals.
      • recipient (string): Destination wallet address.
      • amount (number): Transfer amount (will be converted to a string internally).
    • bearerToken (string): Bearer token for authentication (e.g. from your auth provider).

Return Value

Returns an object containing:
  • transfer: Function to trigger the transfer (fire-and-forget style).
  • transferAsync: Promise-based function that resolves with the transaction hash.
  • data: Transaction hash of the transfer (string | undefined).
  • isLoading: Boolean indicating if the operation is in progress.
  • isError: Boolean indicating if an error occurred.
  • error: Error instance when isError is true, otherwise null.
  • isSuccess: Boolean indicating if the transfer completed successfully.
  • reset: Function to reset the mutation state.

Example Implementation

Security Considerations

  • Always verify recipient addresses
  • Use encrypted private keys
  • Implement proper PIN validation
  • Monitor transaction status

Error Handling

  • Handle insufficient token balance
  • Validate wallet addresses
  • Monitor gas fees
  • Implement retry logic for failed transactions
Always verify recipient addresses. Transfers on StarkNet are irreversible.
  • useApprove - For token allowances (not needed to transfer)
  • useCallAnyContract - For custom contract interactions