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

    Class PermissionsController

    Manages data access permissions and trusted server operations with gasless transaction support.

    Enables applications to access user data through EIP-712 signatures, eliminating gas fees for users. Handles permission lifecycle from creation through revocation, plus trusted server management for data processing operations.

    Architecture: Permissions use dual storage: complex parameters on IPFS, references on blockchain. This minimizes on-chain data while maintaining decentralization and auditability.

    Method Selection:

    • grant() - Create permissions with automatic IPFS upload and blockchain registration
    • prepareGrant() - Preview permission structure before signing
    • revoke() - Remove permissions by ID (gasless or direct)
    • getUserPermissionGrantsOnChain() - Query active permissions
    • trustServer()/untrustServer() - Manage server access

    Gasless Support: All permission methods support both gasless (via relayer) and direct transactions. Configure relayer callbacks in Vana initialization for gasless operations.

    // Grant data access permission
    const result = await vana.permissions.grant({
    grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
    operation: "llm_inference",
    fileIds: [1, 2, 3],
    parameters: { model: "gpt-4", maxTokens: 1000 }
    });
    console.log(`Permission ${result.permissionId} granted`);

    // Trust server for processing
    await vana.permissions.trustServer({
    serverAddress: "0x123...",
    serverUrl: "https://personal-server.vana.org"
    });

    // Query active permissions
    const permissions = await vana.permissions.getUserPermissionGrantsOnChain();
    permissions.forEach(p => console.log(`Permission ${p.id}: ${p.grantee}`));

    For conceptual overview, visit https://docs.vana.org/docs/permissions

    Hierarchy

    • BaseController
      • PermissionsController
    Index

    Methods

    • Grants permission for an application to access user data with gasless transactions.

      This method provides a complete end-to-end permission grant flow that returns the permission ID and other relevant data immediately after successful submission. For advanced users who need more control over the transaction lifecycle, use submitPermissionGrant() instead.

      Parameters

      • params: GrantPermissionParams

        The permission grant configuration object

      • Optionaloptions: TransactionOptions

      Returns Promise<PermissionGrantResult>

      Promise resolving to permission data from the PermissionAdded event

      When gasless transaction submission fails

      When user rejects the signature request

      When grant data cannot be serialized

      When permission grant fails or event parsing fails

      When transaction confirmation times out

      const result = await vana.permissions.grant({
      grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
      operation: "llm_inference",
      parameters: {
      model: "gpt-4",
      maxTokens: 1000,
      temperature: 0.7,
      },
      });

      console.log(`Permission ${result.permissionId} granted to ${result.user}`);
      console.log(`Transaction: ${result.transactionHash}`);

      // Can immediately use the permission ID for other operations
      await vana.permissions.revoke({ permissionId: result.permissionId });
    • Submits a permission grant transaction and returns a handle for flexible result access.

      Parameters

      • params: GrantPermissionParams

        The permission grant configuration object

      • Optionaloptions: TransactionOptions

      Returns Promise<TransactionResult<"DataPortabilityPermissions", "addPermission">>

      Promise resolving to TransactionResult with hash and event parsing capabilities

      This lower-level method provides maximum control over transaction timing. Returns a TransactionResult that can be serialized and passed across API boundaries. Use this when handling multiple transactions or when you need granular control.

      When gasless transaction submission fails

      When user rejects the signature request

      When grant data cannot be serialized

      When permission grant preparation fails

      // Submit transaction and get immediate hash access
      const tx = await vana.permissions.submitPermissionGrant(params);
      console.log(`Transaction submitted: ${tx.hash}`);

      // To wait for events, use SDK's waitForTransactionEvents
      const eventData = await vana.waitForTransactionEvents(tx.hash);
      console.log(`Permission ID: ${eventData.permissionId}`);
    • Prepares a permission grant with preview before signing.

      Parameters

      • params: GrantPermissionParams

        The permission grant parameters

      • Optionaloptions: TransactionOptions

      Returns Promise<{ preview: GrantFile; confirm: () => Promise<PermissionGrantResult> }>

      A promise resolving to a preview object and confirm function

      This method implements a two-phase commit workflow that allows applications to show users a preview of what they're authorizing before requesting a signature. Unlike createAndSign(), this method does NOT upload to IPFS or prompt for signatures until the returned confirm() function is called.

      When grant parameters are invalid or cannot be serialized

      When grant validation fails or preparation encounters an error

      const { preview, confirm } = await vana.permissions.prepareGrant({
      grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
      operation: "llm_inference",
      files: [1, 2, 3],
      parameters: { model: "gpt-4", prompt: "Analyze my social media data" }
      });

      console.log(`Granting ${preview.operation} access to ${preview.files?.length} files`);
      const transactionHash = await confirm();
    • Creates typed data and signature for a permission grant without submitting.

      Parameters

      • params: GrantPermissionParams

        The permission grant configuration object

      Returns Promise<{ typedData: PermissionGrantTypedData; signature: `0x${string}` }>

      A promise resolving to the typed data structure and signature for gasless submission

      This method handles the first phase of permission granting: creating the grant file, storing it on IPFS, and generating the user's EIP-712 signature. Use this when you want to handle submission separately or batch multiple operations. The method validates the grant file against the JSON schema before creating the signature.

      For interactive user flows, consider using prepareGrant() instead, which allows showing a preview before signing.

      When the user rejects the signature request

      When grant data cannot be properly formatted

      When permission grant preparation fails

      When storage operations fail

      const { typedData, signature } = await vana.permissions.createAndSign({
      grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
      operation: "data_analysis",
      parameters: { analysisType: "sentiment" },
      });

      const transactionHash = await vana.permissions.submitSignedGrant(typedData, signature);
    • Submits an already-signed permission grant to the blockchain.

      Parameters

      • typedData: PermissionGrantTypedData

        The EIP-712 typed data structure for the permission grant

      • signature: `0x${string}`

        The user's signature as a hex string

      • Optionaloptions: TransactionOptions

      Returns Promise<TransactionResult<"DataPortabilityPermissions", "addPermission">>

      A Promise that resolves to the transaction hash

      This method supports both relayer-based gasless transactions and direct transactions. It automatically converts bigint values to JSON-safe strings when using relayer callbacks and handles transaction submission with proper error handling and retry logic.

      When gasless transaction submission fails

      When permission submission fails

      When network communication fails

      const txHash = await vana.permissions.submitSignedGrant(
      typedData,
      "0x1234..."
      );
    • Submits an already-signed trust server transaction to the blockchain.

      Parameters

      • typedData: TrustServerTypedData

        The EIP-712 typed data for TrustServer

      • signature: `0x${string}`

        The user's signature obtained via signTypedData()

      • Optionaloptions: TransactionOptions

      Returns Promise<TransactionResult<"DataPortabilityServers", "trustServerWithSignature">>

      Promise resolving to TransactionResult for transaction tracking

      This method extracts the trust server input from typed data and submits it directly. Used internally by trust server methods after signature collection.

      When contract submission fails

      When blockchain communication fails

      const txHandle = await vana.permissions.submitSignedTrustServer(
      typedData,
      "0x1234..."
      );
      const result = await txHandle.waitForEvents();
    • Submits an already-signed add and trust server transaction to the blockchain.

      Parameters

      • typedData: AddAndTrustServerTypedData

        The EIP-712 typed data for AddAndTrustServer

      • signature: `0x${string}`

        The user's signature obtained via signTypedData()

      • Optionaloptions: TransactionOptions

      Returns Promise<
          TransactionResult<
              "DataPortabilityServers",
              "addAndTrustServerWithSignature",
          >,
      >

      Promise resolving to TransactionResult for transaction tracking

      This method extracts the add and trust server input from typed data and submits it directly. Combines server registration and trust operations in a single transaction.

      When contract submission fails

      When blockchain communication fails

      const txHandle = await vana.permissions.submitSignedAddAndTrustServer(
      typedData,
      "0x1234..."
      );
      const result = await txHandle.waitForEvents();
    • Submits an already-signed permission revoke transaction to the blockchain.

      Parameters

      • typedData: GenericTypedData

        The EIP-712 typed data for PermissionRevoke

      • signature: `0x${string}`

        The user's signature obtained via signTypedData()

      • Optionaloptions: TransactionOptions

      Returns Promise<
          TransactionResult<
              "DataPortabilityPermissions",
              "revokePermissionWithSignature",
          >,
      >

      Promise resolving to TransactionResult for transaction tracking

      This method handles the revocation of previously granted permissions. Used internally by revocation methods after signature collection.

      When contract submission fails

      When blockchain communication fails

      const txHandle = await vana.permissions.submitSignedRevoke(
      typedData,
      "0x1234..."
      );
      const result = await txHandle.waitForEvents();
    • Submits an already-signed untrust server transaction to the blockchain.

      Parameters

      • typedData: GenericTypedData

        The EIP-712 typed data for UntrustServer

      • signature: `0x${string}`

        The user's signature obtained via signTypedData()

      • Optionaloptions: TransactionOptions

      Returns Promise<
          TransactionResult<
              "DataPortabilityServers",
              "untrustServerWithSignature",
          >,
      >

      Promise resolving to TransactionResult for transaction tracking

      This method handles the removal of trusted servers. Used internally by untrust server methods after signature collection.

      When contract submission fails

      When blockchain communication fails

      const txHandle = await vana.permissions.submitSignedUntrustServer(
      typedData,
      "0x1234..."
      );
      const result = await txHandle.waitForEvents();
    • Revokes a previously granted permission.

      This method provides complete revocation with automatic event parsing to confirm the permission was successfully revoked. For advanced users who need more control, use submitPermissionRevoke() instead.

      Parameters

      • params: RevokePermissionParams

        Parameters for revoking the permission

        Parameters for revoking a previously granted data access permission.

        Used with PermissionsController.revoke() to remove an application's access to user data. Once revoked, the application can no longer use the permission to access the specified files.

        • permissionId: bigint

          The permission ID to revoke

      Returns Promise<PermissionRevokeResult>

      Promise resolving to revocation data from PermissionRevoked event

      When revocation fails or event parsing fails

      When user rejects the transaction

      When transaction confirmation times out

      // Revoke a permission and get confirmation
      const result = await vana.permissions.revoke({
      permissionId: 123n
      });
      console.log(`Permission ${result.permissionId} revoked in transaction ${result.transactionHash}`);
      console.log(`Revoked in block ${result.blockNumber}`);
    • Submits a permission revocation transaction and returns the transaction hash immediately.

      This is the lower-level method that provides maximum control over transaction timing. Use this when you want to handle transaction confirmation and event parsing separately.

      Parameters

      • params: RevokePermissionParams

        Parameters for revoking the permission

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout

      Returns Promise<TransactionResult<"DataPortabilityPermissions", "revokePermission">>

      Promise resolving to the transaction hash when successfully submitted

      When revocation transaction fails

      When user rejects the transaction

      // Submit revocation and handle confirmation later
      const txHash = await vana.permissions.submitPermissionRevoke({
      permissionId: 123n
      });
      console.log(`Revocation submitted: ${txHash}`);
    • Revokes a permission with a signature for gasless transactions.

      Parameters

      • params: RevokePermissionParams

        Parameters for revoking the permission

        Parameters for revoking a previously granted data access permission.

        Used with PermissionsController.revoke() to remove an application's access to user data. Once revoked, the application can no longer use the permission to access the specified files.

        • permissionId: bigint

          The permission ID to revoke

      • Optionaloptions: TransactionOptions

      Returns Promise<
          TransactionResult<
              "DataPortabilityPermissions",
              "revokePermissionWithSignature",
          >,
      >

      Promise resolving to TransactionResult for transaction tracking

      This method creates an EIP-712 signature for permission revocation and submits it either through relayer callbacks or directly to the blockchain. Provides gasless revocation when relayer is configured.

      When chain ID is not available

      When retrieving user nonce fails

      When user rejects the signature request

      When gasless submission fails

      When revocation fails for any other reason

      const txHandle = await vana.permissions.submitRevokeWithSignature({
      permissionId: 123n
      });
      const result = await txHandle.waitForEvents();
      console.log(`Permission ${result.permissionId} revoked`);
    • Gets on-chain permission grant data without expensive off-chain resolution.

      Parameters

      Returns Promise<OnChainPermissionGrant[]>

      A Promise that resolves to an array of OnChainPermissionGrant objects

      This method provides a fast, performance-focused way to retrieve permission grants by querying only the subgraph without making expensive IPFS or individual contract calls. It eliminates the N+1 query problem of the legacy getUserPermissions() method.

      The returned data contains all on-chain information but does NOT include resolved operation details, parameters, or file IDs. Use retrieveGrantFile() separately for specific grants when detailed data is needed.

      Performance: Completes in ~100-500ms regardless of permission count. Reliability: Single point of failure (subgraph) with clear RPC fallback path.

      When subgraph query fails

      When network requests fail

      // Fast: Get all on-chain permission data
      const grants = await vana.permissions.getUserPermissionGrantsOnChain({ limit: 20 });

      // Display in UI immediately
      grants.forEach(grant => {
      console.log(`Permission ${grant.id}: ${grant.grantUrl}`);
      });

      // Lazy load detailed data for specific permission when user clicks
      const grantFile = await retrieveGrantFile(grants[0].grantUrl);
      console.log(`Operation: ${grantFile.operation}`);
      console.log(`Parameters:`, grantFile.parameters);
    • Registers a new server and immediately trusts it in the DataPortabilityServers contract.

      This is a combined operation that both registers a new data portability server and adds it to the user's trusted servers list in a single transaction. Trusted servers can handle data export and portability requests from the user.

      Parameters

      • params: AddAndTrustServerParams

        Parameters for adding and trusting the server

        Parameters for adding and trusting a server

        • serverAddress: `0x${string}`

          Server address

        • serverUrl: string

          Server URL

        • publicKey: string

          Server public key

      Returns Promise<ServerTrustResult>

      Promise resolving to transaction hash

      When user rejects the transaction

      When chain ID is unavailable or transaction fails

      When server address is already registered

      When wallet account is not available

      // Add and trust a server by providing all required details
      const txHash = await vana.permissions.addAndTrustServer({
      owner: '0x1234567890abcdef1234567890abcdef12345678',
      serverAddress: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
      serverUrl: 'https://myserver.example.com',
      publicKey: '0x456789abcdef456789abcdef456789abcdef456789abcdef'
      });
      console.log('Server added and trusted in transaction:', txHash);

      // Verify the server is now trusted
      const trustedServers = await vana.permissions.getTrustedServers();
      console.log('Now trusting servers:', trustedServers);
    • Adds and trusts a server using a signature (gasless transaction).

      Parameters

      Returns Promise<
          TransactionResult<
              "DataPortabilityServers",
              "addAndTrustServerWithSignature",
          >,
      >

      Promise resolving to TransactionResult with ServerTrustResult event data

    • Trusts a server using a signature (gasless transaction - legacy method).

      Parameters

      • params: TrustServerParams

        Parameters for trusting the server

      • Optionaloptions: TransactionOptions

      Returns Promise<TransactionResult<"DataPortabilityServers", "trustServerWithSignature">>

      Promise resolving to transaction hash

      Use addAndTrustServerWithSignature instead

      When chain ID is not available

      When retrieving user nonce fails

      When user rejects the signature request

      When gasless submission fails

      When server URL doesn't match existing registration

      When trust operation fails for any other reason

    • Removes a server from the user's trusted servers list in the DataPortabilityServers contract.

      This revokes the server's authorization to handle data portability requests for the user. The server remains registered in the system but will no longer be trusted by this user.

      Parameters

      • params: UntrustServerParams

        Parameters for untrusting the server

        Parameters for untrusting a server

        • serverId: number

          Server ID (numeric)

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout

      Returns Promise<TransactionResult<"DataPortabilityServers", "untrustServer">>

      Promise resolving to transaction hash

      When wallet account is not available

      When retrieving user nonce fails

      When user rejects the transaction

      When the server is not currently trusted

      When untrust transaction fails

      // Untrust a specific server
      const txHash = await vana.permissions.untrustServer({
      serverId: 1
      });
      console.log('Server untrusted in transaction:', txHash);

      // Verify the server is no longer trusted
      const trustedServers = await vana.permissions.getTrustedServers();
      console.log('Still trusting servers:', trustedServers);
    • Untrusts a server using a signature (gasless transaction).

      Parameters

      • params: UntrustServerParams

        Parameters for untrusting the server

        Parameters for untrusting a server

        • serverId: number

          Server ID (numeric)

      Returns Promise<
          TransactionResult<
              "DataPortabilityServers",
              "untrustServerWithSignature",
          >,
      >

      Promise resolving to transaction hash

      When wallet account is not available

      When retrieving user nonce fails

      When user rejects the signature request

      When gasless submission fails

      When untrust transaction fails

    • Retrieves all servers trusted by a user from the DataPortabilityServers contract.

      Returns an array of server IDs that the specified user has explicitly trusted. Trusted servers are those that users have authorized to handle their data portability requests.

      Parameters

      • OptionaluserAddress: `0x${string}`

        Optional user address to query (defaults to current wallet user)

      Returns Promise<number[]>

      Promise resolving to array of trusted server IDs (numeric)

      When reading from contract fails or chain is unavailable

      When unable to connect to the blockchain network

      // Get trusted servers for current user
      const myServers = await vana.permissions.getTrustedServers();
      console.log(`I trust ${myServers.length} servers: ${myServers.join(', ')}`);

      // Get trusted servers for another user
      const userServers = await vana.permissions.getTrustedServers("0x1234...");
      console.log(`User trusts servers: ${userServers.join(', ')}`);
    • Gets the total count of trusted servers for a user.

      Parameters

      • OptionaluserAddress: `0x${string}`

        Optional user address (defaults to current user)

      Returns Promise<number>

      Promise resolving to the number of trusted servers

      When reading from contract fails or chain is unavailable

    • Gets server information for multiple servers efficiently.

      Parameters

      • serverIds: number[]

        Array of numeric server IDs to query

      Returns Promise<BatchServerInfoResult>

      Promise resolving to batch result containing successful lookups and failed IDs

      This method uses multicall to fetch information for multiple servers in a single blockchain call, improving performance when querying many servers. Failed lookups are returned separately for error handling.

      When reading from contract fails or chain is unavailable

      const result = await vana.permissions.getServerInfoBatch([1, 2, 3, 999]);

      // Process successful lookups
      result.servers.forEach((server, id) => {
      console.log(`Server ${id}: ${server.url}`);
      });

      // Handle failed lookups
      if (result.failed.length > 0) {
      console.log(`Failed to fetch: ${result.failed.join(', ')}`);
      }
    • Checks whether a specific server is trusted by a user.

      Parameters

      • serverId: number

        Numeric server ID to check

      • OptionaluserAddress: `0x${string}`

        Optional user address (defaults to current user)

      Returns Promise<ServerTrustStatus>

      Promise resolving to server trust status with trust index if applicable

      This method queries the user's trusted server list and checks if the specified server is present. Returns both the trust status and the index in the trust list if trusted.

      When reading from contract fails

      const status = await vana.permissions.checkServerTrustStatus(1);
      if (status.isTrusted) {
      console.log(`Server is trusted at index ${status.trustIndex}`);
      } else {
      console.log('Server is not trusted');
      }
    • Registers a new grantee in the DataPortabilityGrantees contract.

      A grantee is an entity (like an application) that can receive data permissions from users. Once registered, users can grant the grantee access to their data.

      This method supports gasless transactions via relayer when configured. If no relayer is available, it falls back to direct wallet transactions.

      Parameters

      • params: RegisterGranteeParams

        Parameters for registering the grantee

        Parameters for registering a grantee

        • owner: `0x${string}`

          Grantee owner address

        • granteeAddress: `0x${string}`

          Grantee address

        • publicKey: string

          Grantee public key

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout

      Returns Promise<TransactionResult<"DataPortabilityGrantees", "registerGrantee">>

      Promise resolving to the transaction hash

      When the grantee registration transaction fails

      When user rejects the transaction

      When gasless transaction submission fails

      const txHash = await vana.permissions.registerGrantee({
      owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
      granteeAddress: "0xApp1234567890123456789012345678901234567890",
      publicKey: "0x1234567890abcdef..."
      });
      console.log(`Grantee registered in transaction: ${txHash}`);
    • Retrieves all registered grantees from the DataPortabilityGrantees contract.

      Returns a paginated list of all grantees (applications) that have been registered in the system and can receive data permissions from users.

      Parameters

      • options: GranteeQueryOptions = {}

        Query options for pagination and filtering

        Options for querying grantees

        • Optionallimit?: number

          Maximum number of grantees to return

        • Optionaloffset?: number

          Offset for pagination

        • OptionalincludePermissions?: boolean

          Whether to include permission info or just basic info

      Returns Promise<PaginatedGrantees>

      Promise resolving to paginated grantees with metadata

      When contract read operation fails

      When unable to connect to the blockchain network

      // Get first 10 grantees
      const result = await vana.permissions.getGrantees({
      limit: 10,
      offset: 0
      });

      console.log(`Found ${result.total} total grantees`);
      result.grantees.forEach(grantee => {
      console.log(`Grantee ${grantee.id}: ${grantee.granteeAddress}`);
      });

      // Check if there are more results
      if (result.hasMore) {
      console.log('More grantees available');
      }
    • Retrieves a specific grantee by their Ethereum wallet address.

      Parameters

      • granteeAddress: `0x${string}`

        Ethereum wallet address of the grantee to query

      Returns Promise<Grantee | null>

      Grantee information including ID, addresses, public key, and permission IDs, or null if not found

      Looks up a registered grantee (application) using their Ethereum address and returns their complete registration information including all associated permissions.

      Returns null if the address is not registered as a grantee or if an error occurs.

      const granteeAddress = "0xApp1234567890123456789012345678901234567890";
      const grantee = await vana.permissions.getGranteeByAddress(granteeAddress);

      if (grantee) {
      console.log(`Found grantee ${grantee.id}`);
      console.log(`Owner: ${grantee.owner}`);
      console.log(`Public Key: ${grantee.publicKey}`);
      console.log(`Permissions: ${grantee.permissionIds.join(', ')}`);
      } else {
      console.log('Grantee not found');
      }
    • Retrieves a specific grantee by their unique ID.

      Parameters

      • granteeId: number

        Unique numeric ID of the grantee (1-indexed)

      Returns Promise<Grantee | null>

      Grantee information including ID, addresses, public key, and permission IDs, or null if not found

      Looks up a registered grantee (application) using their numeric ID assigned during registration and returns their complete information including all associated permissions.

      Returns null if the grantee is not found or if an error occurs during fetching.

      const grantee = await vana.permissions.getGranteeById(1);

      if (grantee) {
      console.log(`Grantee ID: ${grantee.id}`);
      console.log(`Address: ${grantee.address}`);
      console.log(`Owner: ${grantee.owner}`);
      console.log(`Total permissions: ${grantee.permissionIds.length}`);
      } else {
      console.log('Grantee with ID 1 not found');
      }
    • Get all trusted server IDs for a user

      Parameters

      • OptionaluserAddress: `0x${string}`

        User address to query (defaults to current user)

      Returns Promise<bigint[]>

      Promise resolving to array of server IDs

    • Get server ID at specific index for a user

      Parameters

      • userAddress: `0x${string}`

        User address to query

      • serverIndex: bigint

        Index in the user's server list

      Returns Promise<bigint>

      Promise resolving to server ID

    • Get the number of trusted servers for a user

      Parameters

      • OptionaluserAddress: `0x${string}`

        User address to query (defaults to current user)

      Returns Promise<bigint>

      Promise resolving to number of trusted servers

    • Get all permission IDs for a user

      Parameters

      • OptionaluserAddress: `0x${string}`

        User address to query (defaults to current user)

      Returns Promise<bigint[]>

      Promise resolving to array of permission IDs

    • Get permission ID at specific index for a user

      Parameters

      • userAddress: `0x${string}`

        User address to query

      • permissionIndex: bigint

        Index in the user's permission list

      Returns Promise<bigint>

      Promise resolving to permission ID

    • Get the number of permissions for a user

      Parameters

      • OptionaluserAddress: `0x${string}`

        User address to query (defaults to current user)

      Returns Promise<bigint>

      Promise resolving to number of permissions

    • Get all permission IDs for a specific file

      Parameters

      • fileId: bigint

        File ID to get permissions for

      Returns Promise<bigint[]>

      Promise resolving to array of permission IDs

    • Get all file IDs for a specific permission

      Parameters

      • permissionId: bigint

        Permission ID to get files for

      Returns Promise<bigint[]>

      Promise resolving to array of file IDs

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

      Parameters

      • grantUrl: string

        The grant file URL (from OnChainPermissionGrant.grantUrl)

      Returns Promise<GrantFile>

      Promise resolving to the complete grant file with operation details

      This method automatically uses the SDK's configured downloadRelayer to bypass CORS restrictions. Use this instead of importing the standalone retrieveGrantFile utility.

      When all retrieval attempts fail

      const grants = await vana.permissions.getUserPermissionGrantsOnChain();
      const grantFile = await vana.permissions.retrieveGrantFile(grants[0].grantUrl);
      console.log(`Operation: ${grantFile.operation}`);
    • Get all permissions for a specific file (alias for getFilePermissionIds)

      Parameters

      • fileId: bigint

        File ID to get permissions for

      Returns Promise<bigint[]>

      Promise resolving to array of permission IDs

    • Retrieves detailed grantee information including all associated permissions.

      Parameters

      • granteeId: bigint

        Unique grantee identifier as bigint

      Returns Promise<GranteeInfo>

      Grantee information containing owner address, grantee address, public key, and permission IDs

      Returns grantee metadata and associated permission IDs. Uses the newer paginated contract method internally for efficient permission fetching.

      When grantee ID is not found or contract read fails

      const granteeInfo = await vana.permissions.getGranteeInfo(BigInt(1));
      console.log(`Grantee ${granteeInfo.granteeAddress} has ${granteeInfo.permissionIds.length} permissions`);
    • Retrieves detailed grantee information by wallet address.

      Parameters

      • granteeAddress: `0x${string}`

        Ethereum wallet address of the grantee to query

      Returns Promise<GranteeInfo>

      Grantee information containing owner address, grantee address, public key, and permission IDs

      Looks up the grantee ID from the provided address, then fetches complete grantee information including all associated permissions.

      When grantee address is not registered or contract read fails

      const granteeInfo = await vana.permissions.getGranteeInfoByAddress("0x742d35Cc6634c0532925a3b844Bc9e8e1ee3b2De");
      console.log(`Found grantee with ${granteeInfo.permissionIds.length} permissions`);
    • Get all permission IDs for a specific grantee

      Parameters

      • granteeId: bigint

        Grantee ID to get permissions for

      Returns Promise<bigint[]>

      Promise resolving to array of permission IDs

    • Get all permissions for a specific grantee (alias for getGranteePermissionIds)

      Parameters

      • granteeId: bigint

        Grantee ID to get permissions for

      Returns Promise<bigint[]>

      Promise resolving to array of permission IDs

    • Retrieves permission IDs for a specific grantee with flexible pagination.

      Parameters

      • granteeId: bigint

        Grantee ID to get permissions for

      • Optionaloptions: { offset?: bigint; limit?: bigint }

        Optional pagination parameters

        • Optionaloffset?: bigint

          Zero-based starting index for pagination. Defaults to 0 when fetching all permissions. Required for single-page requests.

        • Optionallimit?: bigint

          Maximum number of permission IDs to return per page. Defaults to 100 when fetching all permissions. Required for single-page requests.

      Returns Promise<
          | bigint[]
          | { permissionIds: bigint[]; totalCount: bigint; hasMore: boolean },
      >

      When called without options: Array of all permission IDs as bigint[]. When called with offset and limit: Paginated result object containing permissionIds array, totalCount, and hasMore boolean.

      Pagination Behavior: Returns different types based on parameters:

      • Without offset/limit: Returns bigint[] of all permissions using batched multicall
      • With offset/limit: Returns paginated object with permissionIds, totalCount, and hasMore

      Uses gas-aware multicall for efficient batch fetching when retrieving all permissions.

      When contract read operation fails

      // Fetch all permissions (no pagination params)
      const allPermissions = await vana.permissions.getGranteePermissionsPaginated(BigInt(1));
      console.log(`Total permissions: ${allPermissions.length}`);

      // Fetch a specific page (with pagination params)
      const page = await vana.permissions.getGranteePermissionsPaginated(BigInt(1), {
      offset: BigInt(0),
      limit: BigInt(100)
      });
      console.log(`Fetched ${page.permissionIds.length} permissions`);
      console.log(`Total: ${page.totalCount}, Has more: ${page.hasMore}`);

      // Fetch next page
      if (page.hasMore) {
      const nextPage = await vana.permissions.getGranteePermissionsPaginated(BigInt(1), {
      offset: BigInt(100),
      limit: BigInt(100)
      });
      }
    • Get all server IDs for a user

      Parameters

      • userAddress: `0x${string}`

        User address to get server IDs for

      Returns Promise<bigint[]>

      Promise resolving to array of server IDs

    • Get server ID at specific index for a user

      Parameters

      • userAddress: `0x${string}`

        User address

      • serverIndex: bigint

        Index of the server ID

      Returns Promise<bigint>

      Promise resolving to server ID

    • Get the number of servers a user has

      Parameters

      • userAddress: `0x${string}`

        User address

      Returns Promise<bigint>

      Promise resolving to number of servers

    • Get user info including nonce and trusted server IDs

      Parameters

      • userAddress: `0x${string}`

        User address

      Returns Promise<{ nonce: bigint; trustedServerIds: bigint[] }>

      Promise resolving to user info

    • Update server URL

      Parameters

      • serverId: bigint

        Server ID to update

      • url: string

        New URL for the server

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout

      Returns Promise<TransactionResult<"DataPortabilityServers", "updateServer">>

      Promise resolving to transaction hash

    • Get all permission IDs for a user

      Parameters

      • userAddress: `0x${string}`

        User address to get permission IDs for

      Returns Promise<bigint[]>

      Promise resolving to array of permission IDs

    • Get permission ID at specific index for a user

      Parameters

      • userAddress: `0x${string}`

        User address

      • permissionIndex: bigint

        Index of the permission ID

      Returns Promise<bigint>

      Promise resolving to permission ID

    • Get the number of permissions a user has

      Parameters

      • userAddress: `0x${string}`

        User address

      Returns Promise<bigint>

      Promise resolving to number of permissions

    • Submits an already-signed add permission transaction to the blockchain. This method supports both relayer-based gasless transactions and direct transactions.

      Parameters

      • typedData: GenericTypedData

        The EIP-712 typed data for AddPermission

      • signature: `0x${string}`

        The user's signature

      • Optionaloptions: TransactionOptions

      Returns Promise<TransactionResult<"DataPortabilityPermissions", "addPermission">>

      Promise resolving to TransactionResult with PermissionGrantResult event data

      When gasless transaction submission fails

      When permission addition fails

      When network communication fails

    • Submits server files and permissions with signature to the blockchain, supporting schema validation and gasless transactions.

      Parameters

      • params: ServerFilesAndPermissionParams

        Parameters for adding server files and permissions

        Parameters for server files and permissions operations

        • granteeId: bigint

          Grantee ID

        • grant: string

          Grant URL or grant data

        • fileUrls: string[]

          File URLs

        • schemaIds: number[]

          Schema IDs for each file - use 0 for files without schema validation

        • serverAddress: `0x${string}`

          Server address

        • serverUrl: string

          Server URL

        • serverPublicKey: string

          Server public key

        • filePermissions: Permission[][]

          File permissions array - permissions for each file

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout. Note: These options are only applied for direct blockchain transactions. When using relayer callbacks (gasless transactions), these options are ignored.

      Returns Promise<
          TransactionResult<
              "DataPortabilityPermissions",
              "addServerFilesAndPermissions",
          >,
      >

      TransactionResult with immediate hash access and optional event data

      This method validates files against their specified schemas before submission. Schema validation ensures data conforms to expected formats before on-chain registration. Files with schemaId = 0 bypass validation. The method supports atomic batch operations where all files and permissions are registered in a single transaction.

      When schemaIds array length doesn't match fileUrls array length

      When file data doesn't match the specified schema. Verify data structure matches schema definition from vana.schemas.get(schemaId).

      When gasless transaction submission fails. Retry without relayer configuration to submit direct transaction.

      When user rejects the signature request

      When server files and permissions addition fails

      When network communication fails. Check network connection or configure alternative gateways.

      // Submit with custom gas parameters and timeout
      const result = await vana.permissions.submitAddServerFilesAndPermissions({
      granteeId: BigInt(1),
      grant: "ipfs://QmXxx...",
      fileUrls: ["https://storage.example.com/data.json"],
      schemaIds: [123], // LinkedIn profile schema ID
      serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
      serverUrl: "https://server.example.com",
      serverPublicKey: serverInfo.publicKey,
      filePermissions: [[{
      account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
      key: encryptedKey
      }]]
      }, {
      maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
      maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
      });

      // Wait for confirmation with custom timeout
      const receipt = await vana.waitForTransactionReceipt(result, {
      timeout: 180000 // 3 minutes
      });
      console.log(`Transaction confirmed: ${receipt.transactionHash}`);
    • Submits an already-signed add server files and permissions transaction to the blockchain.

      Parameters

      • typedData: ServerFilesAndPermissionTypedData

        The EIP-712 typed data for AddServerFilesAndPermissions

      • signature: `0x${string}`

        The user's signature

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout. Note: These options are only applied for direct blockchain transactions. When using relayer callbacks (gasless transactions), these options are ignored.

      Returns Promise<
          TransactionResult<
              "DataPortabilityPermissions",
              "addServerFilesAndPermissions",
          >,
      >

      TransactionResult with immediate hash access and optional event data

      This method returns a TransactionResult that provides immediate access to the transaction hash. The eventData field may contain parsed event details after transaction confirmation.

      When gasless transaction submission fails

      When server files and permissions addition fails

      When network communication fails

      const tx = await vana.permissions.submitSignedAddServerFilesAndPermissions(
      typedData,
      signature
      );
      console.log(`Transaction submitted: ${tx.hash}`);

      // Wait for confirmation and get the permission ID
      const { permissionId } = await tx.waitForEvents();
      console.log(`Permission created with ID: ${permissionId}`);
    • Submit permission revocation with signature to the blockchain

      Parameters

      • permissionId: bigint

        Permission ID to revoke

      • Optionaloptions: TransactionOptions

        Optional transaction options for gas parameters and timeout

      Returns Promise<TransactionResult<"DataPortabilityPermissions", "revokePermission">>

      Promise resolving to transaction hash