Vana SDK - v0.1.0
    Preparing search index...

    Function retrieveGrantFile

    • Retrieves detailed grant file data from IPFS or HTTP storage.

      Parameters

      • grantUrl: string

        The grant file URL from OnChainPermissionGrant.grantUrl

      • Optional_relayerUrl: string

        URL of the relayer service (optional, unused)

      Returns Promise<GrantFile>

      Promise resolving to the complete grant file with operation details

      This is Step 2 of the performant two-step permission API.

      Use this method to resolve detailed permission data (operation, parameters, etc.) for specific grants after first getting the fast on-chain data using getUserPermissionGrantsOnChain(). This design eliminates N+1 query problems by allowing selective lazy-loading of expensive off-chain data.

      Performance: Single network request per grant file (typically 100-500ms). Reliability: Tries multiple IPFS gateways as fallbacks if primary URL fails.

      When all retrieval attempts fail

      When grant file format is invalid

      // Step 1: Fast on-chain data (no N+1 queries)
      const grants = await vana.permissions.getUserPermissionGrantsOnChain();

      // Step 2: Lazy-load details for specific grant when needed
      const grantFile = await retrieveGrantFile(grants[0].grantUrl);

      console.log(`Operation: ${grantFile.operation}`);
      console.log(`Grantee: ${grantFile.grantee}`);
      console.log(`Parameters:`, grantFile.parameters);

      // Only fetch details for grants user actually wants to see
      for (const grant of selectedGrants) {
      const details = await retrieveGrantFile(grant.grantUrl);
      displayGrantDetails(details);
      }