Skip to main content

Usage

Parameters

The hook accepts an object with:
  • params (CallAnyContractParams):
    • encryptKey (string): User’s decryption PIN (or passkey-derived key)
    • wallet (WalletData): the full wallet object — publicKey, encryptedPrivateKey, and (routing-critical) walletType + signerKind from createWallet / useGetWallet. Omitting walletType defaults to "READY" and reverts on a SHHH wallet.
    • contractAddress (string): Target contract address
    • calls (Call[]): Array of contract calls with contractAddress, entrypoint, and calldata
    • usePasskey (boolean, optional): Set true when encryptKey was derived from a passkey
  • bearerToken (string): Bearer token for authentication

Return Value

Returns an object containing:
  • callAnyContract: Function to trigger contract call (fire-and-forget)
  • callAnyContractAsync: Promise-based function that resolves with the transaction hash
  • data: Transaction hash of the call (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 call completed successfully
  • reset: Function to reset the mutation state

Example Implementation

Security Considerations

  • Verify contract addresses
  • Validate calldata format
  • Use encrypted private keys
  • Implement proper PIN validation
  • Review contract ABI before calling

Error Handling

  • Handle invalid contract addresses
  • Validate calldata format
  • Monitor gas fees
  • Implement retry logic for failed calls
Use with caution. Direct contract calls require deep understanding of the target contract’s ABI and security implications.
  • useApprove - For token approvals
  • useTransfer - For token transfers