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.
The permission grant configuration object
Optionaloptions: TransactionOptionsPromise resolving to permission data from the PermissionAdded event
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.
The permission grant configuration object
Optionaloptions: TransactionOptionsPromise 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.
// 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.
The permission grant parameters
Optionaloptions: TransactionOptionsA 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.
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.
The permission grant configuration object
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.
Submits an already-signed permission grant to the blockchain.
The EIP-712 typed data structure for the permission grant
The user's signature as a hex string
Optionaloptions: TransactionOptionsA Promise that resolves to the transaction hash
Submits an already-signed trust server transaction to the blockchain.
The EIP-712 typed data for TrustServer
The user's signature obtained via signTypedData()
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult for transaction tracking
Submits an already-signed add and trust server transaction to the blockchain.
The EIP-712 typed data for AddAndTrustServer
The user's signature obtained via signTypedData()
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult for transaction tracking
Submits an already-signed permission revoke transaction to the blockchain.
The EIP-712 typed data for PermissionRevoke
The user's signature obtained via signTypedData()
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult for transaction tracking
Submits an already-signed untrust server transaction to the blockchain.
The EIP-712 typed data for UntrustServer
The user's signature obtained via signTypedData()
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult for transaction tracking
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 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.
The permission ID to revoke
Promise resolving to revocation data from PermissionRevoked event
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 for revoking the permission
Optionaloptions: TransactionOptionsOptional transaction options for gas parameters and timeout
Promise resolving to the transaction hash when successfully submitted
Revokes a permission with a signature for gasless transactions.
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.
The permission ID to revoke
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult for transaction tracking
Gets on-chain permission grant data without expensive off-chain resolution.
Options for retrieving permissions (limit, subgraph URL)
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.
// 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 for adding and trusting the server
Parameters for adding and trusting a server
Server address
Server URL
Server public key
Promise resolving to transaction hash
// 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);
Trusts a server for data processing (legacy method).
Parameters for trusting the server
Promise resolving to transaction hash
Adds and trusts a server using a signature (gasless transaction).
Parameters for adding and trusting the server
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult with ServerTrustResult event data
Trusts a server using a signature (gasless transaction - legacy method).
Parameters for trusting the server
Optionaloptions: TransactionOptionsPromise resolving to transaction hash
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 for untrusting the server
Parameters for untrusting a server
Server ID (numeric)
Optionaloptions: TransactionOptionsOptional transaction options for gas parameters and timeout
Promise resolving to transaction hash
// 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 for untrusting the server
Parameters for untrusting a server
Server ID (numeric)
Promise resolving to transaction hash
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.
OptionaluserAddress: `0x${string}`Optional user address to query (defaults to current wallet user)
Promise resolving to array of trusted server IDs (numeric)
// 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 trusted servers with pagination support.
Query options including pagination parameters
Promise resolving to paginated trusted servers
Gets trusted servers with their complete information.
Query options
Promise resolving to array of trusted server info
Gets server information for multiple servers efficiently.
Array of numeric server IDs to query
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.
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.
Numeric server ID to check
OptionaluserAddress: `0x${string}`Optional user address (defaults to current user)
Promise resolving to server trust status with trust index if applicable
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 for registering the grantee
Parameters for registering a grantee
Grantee owner address
Grantee address
Grantee public key
Optionaloptions: TransactionOptionsOptional transaction options for gas parameters and timeout
Promise resolving to the transaction hash
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.
Query options for pagination and filtering
Options for querying grantees
Optionallimit?: numberMaximum number of grantees to return
Optionaloffset?: numberOffset for pagination
OptionalincludePermissions?: booleanWhether to include permission info or just basic info
Promise resolving to paginated grantees with metadata
// 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.
Ethereum wallet address of the grantee to query
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.
Unique numeric ID of the grantee (1-indexed)
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
OptionaluserAddress: `0x${string}`User address to query (defaults to current user)
Promise resolving to array of server IDs
Get server ID at specific index for a user
User address to query
Index in the user's server list
Promise resolving to server ID
Get the number of trusted servers for a user
OptionaluserAddress: `0x${string}`User address to query (defaults to current user)
Promise resolving to number of trusted servers
Get detailed information about trusted servers for a user
OptionaluserAddress: `0x${string}`User address to query (defaults to current user)
Promise resolving to array of trusted server info
Get trusted server info for a specific server ID and user
User address to query
Server ID to get info for
Promise resolving to trusted server info
Get server information by server ID
Server ID to get info for
Promise resolving to server info
Get server information by server address
Server address to get info for
Promise resolving to server info
Get all permission IDs for a user
OptionaluserAddress: `0x${string}`User address to query (defaults to current user)
Promise resolving to array of permission IDs
Get permission ID at specific index for a user
User address to query
Index in the user's permission list
Promise resolving to permission ID
Get the number of permissions for a user
OptionaluserAddress: `0x${string}`User address to query (defaults to current user)
Promise resolving to number of permissions
Get detailed permission information by permission ID
Permission ID to get info for
Promise resolving to permission info
Get all permission IDs for a specific file
File ID to get permissions for
Promise resolving to array of permission IDs
Get all file IDs for a specific permission
Permission ID to get files for
Promise resolving to array of file IDs
Retrieves detailed grant file data from IPFS or HTTP storage.
The grant file URL (from OnChainPermissionGrant.grantUrl)
Promise resolving to the complete grant file with operation details
Get all permissions for a specific file (alias for getFilePermissionIds)
File ID to get permissions for
Promise resolving to array of permission IDs
Retrieves detailed grantee information including all associated permissions.
Unique grantee identifier as bigint
Grantee information containing owner address, grantee address, public key, and permission IDs
Retrieves detailed grantee information by wallet address.
Ethereum wallet address of the grantee to query
Grantee information containing owner address, grantee address, public key, and permission IDs
Get all permission IDs for a specific grantee
Grantee ID to get permissions for
Promise resolving to array of permission IDs
Get all permissions for a specific grantee (alias for getGranteePermissionIds)
Grantee ID to get permissions for
Promise resolving to array of permission IDs
Retrieves permission IDs for a specific grantee with flexible pagination.
Grantee ID to get permissions for
Optionaloptions: { offset?: bigint; limit?: bigint }Optional pagination parameters
Optionaloffset?: bigintZero-based starting index for pagination. Defaults to 0 when fetching all permissions. Required for single-page requests.
Optionallimit?: bigintMaximum number of permission IDs to return per page. Defaults to 100 when fetching all permissions. Required for single-page requests.
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:
bigint[] of all permissions using batched multicallpermissionIds, totalCount, and hasMoreUses gas-aware multicall for efficient batch fetching when retrieving all permissions.
// 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
User address to get server IDs for
Promise resolving to array of server IDs
Get server ID at specific index for a user
User address
Index of the server ID
Promise resolving to server ID
Get the number of servers a user has
User address
Promise resolving to number of servers
Get trusted server info for a specific user and server ID
User address
Server ID
Promise resolving to trusted server info
Get server info by server ID
Server ID
Promise resolving to server info
Get user info including nonce and trusted server IDs
User address
Promise resolving to user info
Update server URL
Server ID to update
New URL for the server
Optionaloptions: TransactionOptionsOptional transaction options for gas parameters and timeout
Promise resolving to transaction hash
Get all permission IDs for a user
User address to get permission IDs for
Promise resolving to array of permission IDs
Get permission ID at specific index for a user
User address
Index of the permission ID
Promise resolving to permission ID
Get the number of permissions a user has
User address
Promise resolving to number of permissions
Get permission info by permission ID
Permission ID
Promise resolving to permission info
Submit permission with signature to the blockchain (supports gasless transactions)
Parameters for adding permission
Promise resolving to transaction hash
Submits an already-signed add permission transaction to the blockchain. This method supports both relayer-based gasless transactions and direct transactions.
The EIP-712 typed data for AddPermission
The user's signature
Optionaloptions: TransactionOptionsPromise resolving to TransactionResult with PermissionGrantResult event data
Submits server files and permissions with signature to the blockchain, supporting schema validation and gasless transactions.
Parameters for adding server files and permissions
Parameters for server files and permissions operations
Grantee ID
Grant URL or grant data
File URLs
Schema IDs for each file - use 0 for files without schema validation
Server address
Server URL
Server public key
File permissions array - permissions for each file
Optionaloptions: TransactionOptionsOptional 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.
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 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.
// 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.
The EIP-712 typed data for AddServerFilesAndPermissions
The user's signature
Optionaloptions: TransactionOptionsOptional 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.
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.
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
Permission ID to revoke
Optionaloptions: TransactionOptionsOptional transaction options for gas parameters and timeout
Promise resolving to transaction hash
Manages data access permissions and trusted server operations with gasless transaction support.
Remarks
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 registrationprepareGrant()- Preview permission structure before signingrevoke()- Remove permissions by ID (gasless or direct)getUserPermissionGrantsOnChain()- Query active permissionstrustServer()/untrustServer()- Manage server accessGasless Support: All permission methods support both gasless (via relayer) and direct transactions. Configure relayer callbacks in Vana initialization for gasless operations.
Example
See
For conceptual overview, visit https://docs.vana.org/docs/permissions