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

    Class VanaBrowserImpl

    Internal implementation class for browser environments. This class is not exported directly - use the Vana factory function instead.

    Hierarchy (View Summary)

    Index

    Properties

    Manages gasless data access permissions and trusted server registry.

    Handles user data file operations.

    Manages data schemas and refiners.

    Provides personal server setup and trusted server interactions.

    Offers low-level access to Vana protocol smart contracts.

    Accessors

    • get chainId(): number

      Gets the current chain ID from the wallet client.

      Returns number

      The numeric chain ID of the connected network

      const chainId = vana.chainId;
      console.log(`Connected to chain: ${chainId}`); // e.g., "Connected to chain: 14800"
    • get chainName(): string

      Gets the current chain name from the wallet client.

      Returns string

      The human-readable name of the connected network

      const chainName = vana.chainName;
      console.log(`Connected to: ${chainName}`); // e.g., "Connected to: Moksha Testnet"

    Methods

    • Validates that storage is available for storage-dependent operations. This method enforces the fail-fast principle by checking storage availability at method call time rather than during expensive operations.

      Returns void

      When storage is required but not configured

      // This will throw if storage is not configured
      vana.validateStorageRequired();
      await vana.data.uploadFile(file); // Safe to proceed
    • Checks whether storage is configured without throwing an error.

      Returns boolean

      True if storage is properly configured

      if (vana.hasStorage()) {
      await vana.data.uploadFile(file);
      } else {
      console.warn('Storage not configured - using pre-stored URLs only');
      }
    • Retrieves the user's wallet address from the connected client.

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

      A Promise that resolves to the user's Ethereum address

      const address = await vana.getUserAddress();
      console.log(`User address: ${address}`); // e.g., "User address: 0x742d35..."
    • Retrieves comprehensive runtime configuration information.

      Returns RuntimeConfig

      The current runtime configuration including chain, storage, and relayer settings

      const config = vana.getConfig();
      console.log(`Chain: ${config.chainName} (${config.chainId})`);
      console.log(`Storage providers: ${config.storageProviders.join(", ")}`);
    • Sets the platform adapter for environment-specific operations. This is useful for testing and advanced use cases where you need to override the default platform detection.

      Parameters

      Returns void

      // For testing with a mock adapter
      const mockAdapter = new MockPlatformAdapter();
      vana.setPlatformAdapter(mockAdapter);

      // For advanced use cases with custom adapters
      const customAdapter = new CustomPlatformAdapter();
      vana.setPlatformAdapter(customAdapter);
    • Encrypts data using the Vana protocol standard encryption. This method automatically uses the correct platform adapter for the current environment.

      Parameters

      • data: string | Blob

        The data to encrypt (string or Blob)

      • key: string

        The key to use as encryption key

      Returns Promise<Blob>

      The encrypted data as Blob

      const encryptionKey = await generateEncryptionKey(walletClient);
      const encrypted = await vana.encryptBlob("sensitive data", encryptionKey);
    • Decrypts data that was encrypted using the Vana protocol. This method automatically uses the correct platform adapter for the current environment.

      Parameters

      • encryptedData: string | Blob

        The encrypted data (string or Blob)

      • walletSignature: string

        The wallet signature to use as decryption key

      Returns Promise<Blob>

      The decrypted data as Blob

      const encryptionKey = await generateEncryptionKey(walletClient);
      const decrypted = await vana.decryptBlob(encryptedData, encryptionKey);
      const text = await decrypted.text();