Vana SDK - v2.2.2
    Preparing search index...

    Function withSignatureCache

    • Wraps signature operations with caching to avoid repeated prompts.

      Parameters

      • cache: VanaCacheAdapter

        The cache adapter to use for storage. Obtain from platform adapter.

      • walletAddress: string

        The wallet address signing the message. Obtain from wallet connection.

      • typedData: Record<string, unknown>

        The EIP-712 typed data being signed. Typically permission or grant data.

      • signFn: () => Promise<`0x${string}`>

        Async function that performs the actual signing. Usually calls wallet.signTypedData().

      • OptionalttlHours: number

        Cache TTL in hours. Defaults to 2 hours.

      Returns Promise<`0x${string}`>

      The signature (cached or newly generated)

      This helper function checks the cache before requesting a signature and stores new signatures for future use. It significantly improves UX for operations that may be retried or called multiple times.

      const signature = await withSignatureCache(
      platformAdapter.cache,
      walletAddress,
      typedData,
      async () => wallet.signTypedData(typedData),
      24 // Cache for 24 hours
      );