Skip to main content

API Reference

This section documents the minikit instance methods.

Wallet

walletAuth()

Requests the user to connect their Watchee Wallet.

Returns: Promise<AptosAccount>

interface AptosAccount {
address: string;
publicKey: string;
network?: 'mainnet' | 'testnet' | 'devnet';
}

sendTransaction(payload, options?)

Signs and submits a transaction to the Aptos blockchain.

Parameters:

  • payload: The transaction payload (entry function, arguments).
  • options: Optional settings.

Returns: Promise<{ signature: string; transaction_hash: string }>

Payment

pay(details)

Requests a payment from the user.

Parameters:

  • details: PaymentDetails
interface PaymentDetails {
recipient: string;
amount: number;
token?: string; // e.g., '0x1::aptos_coin::AptosCoin'
reference?: string;
}

Returns: Promise<any> (Transaction result)

User

getProfile()

Fetches the current user's profile.

Returns: Promise<any>

getOwnedNFTs(options?)

Fetches NFTs owned by the user, scoped to the current context/channel if applicable.

Returns: Promise<any[]>

Content

publishContent(data)

Publishes content to Watchee.

Parameters:

  • data: PublishContentData
interface PublishContentData {
title: string;
description?: string;
mediaUrl: string;
thumbnailUrl?: string;
metadata?: Record<string, any>;
}

Analytics

trackEvent(event)

Tracks a custom event.

Parameters:

  • event: { name: string; data?: any }

Social

share(content)

Opens the native share sheet.

Parameters:

  • content: ShareContent
interface ShareContent {
message?: string;
url?: string;
title?: string;
}

Device

hapticFeedback(type)

Triggers haptic feedback.

Parameters:

  • type: HapticFeedbackType
type HapticFeedbackType = 'success' | 'warning' | 'error' | 'light' | 'medium' | 'heavy';

Permissions

Manage device permissions for camera, microphone, notifications, and photo library access. Similar to World App's permission system.

Permission Types

enum Permission {
Camera = 'camera',
Microphone = 'microphone',
Notifications = 'notifications',
MediaLibrary = 'media_library',
}

enum PermissionStatus {
Granted = 'granted',
Denied = 'denied',
NotRequested = 'not_requested',
}

requestPermission(permission)

Request a specific permission from the user. Shows a beautiful permission modal for user approval.

Parameters:

  • permission: Permission - The permission to request

Returns: Promise<PermissionResponse>

interface PermissionResponse {
permission: Permission;
status: PermissionStatus;
nativeStatus?: string;
timestamp: string;
}

Example:

import { minikit, Permission, PermissionStatus } from 'watchee-minikit';

const response = await minikit.requestPermission(Permission.Camera);

if (response.status === PermissionStatus.Granted) {
// Camera access allowed - now you can use getUserMedia
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
}

getPermissions()

Get all permission statuses for your mini-app.

Returns: Promise<AllPermissionsResponse>

interface AllPermissionsResponse {
permissions: Record<Permission, PermissionStatus>;
timestamp: string;
}

Example:

const response = await minikit.getPermissions();

// Check individual permissions
if (response.permissions.camera === PermissionStatus.Granted) {
// Camera access is allowed
}

if (response.permissions.microphone === PermissionStatus.NotRequested) {
// Microphone permission hasn't been requested yet
}

checkPermission(permission)

Check the current status of a single permission without requesting it.

Parameters:

  • permission: Permission - The permission to check

Returns: Promise<PermissionResponse>

Example:

const response = await minikit.checkPermission(Permission.MediaLibrary);

if (response.status === PermissionStatus.NotRequested) {
// Show a button to request permission
} else if (response.status === PermissionStatus.Denied) {
// Show message to enable in settings
}

Best Practices

  1. Request at point of use - Don't request all permissions upfront. Request when the user triggers a feature.
  2. Explain why - Before requesting, explain why your app needs the permission.
  3. Handle denial gracefully - Provide alternative functionality or clear guidance on how to enable in settings.
  4. Check before requesting - Use checkPermission() or getPermissions() to avoid showing the modal if already granted.
  5. Combine with haptics - Use hapticFeedback('success') after a permission is granted for better UX.

User Control

Users can manage permissions for your mini-app at any time via:

  • App Menu → "Manage Permissions"
  • Settings → "Spaces" → Your App → "Device Permissions"

Permissions can be revoked individually or all at once.

Media Access (WebRTC)

Mini-apps can access the device camera and microphone using the standard WebRTC getUserMedia API. This is useful for features like video calls, QR code scanning, photo capture, or audio recording.

Usage

// Request camera and microphone access
const stream = await navigator.mediaDevices.getUserMedia({
video: {
facingMode: 'user', // 'user' for front camera, 'environment' for back
width: { ideal: 1280 },
height: { ideal: 720 },
},
audio: {
echoCancellation: true,
noiseSuppression: true,
},
});

// Display video preview
const videoElement = document.querySelector('video');
videoElement.srcObject = stream;
await videoElement.play();

// Stop all tracks when done
stream.getTracks().forEach(track => track.stop());

Supported Constraints

Video:

  • facingMode: 'user' (front) or 'environment' (back)
  • width, height: Resolution constraints
  • frameRate: Frame rate constraints

Audio:

  • echoCancellation: Enable echo cancellation
  • noiseSuppression: Enable noise suppression
  • autoGainControl: Enable automatic gain control

Permission Handling

The Watchee App will automatically prompt the user for camera/microphone permissions when your mini-app calls getUserMedia(). Handle permission errors gracefully:

try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
// Success - use the stream
} catch (error) {
if (error.name === 'NotAllowedError') {
// User denied permission
} else if (error.name === 'NotFoundError') {
// No camera/mic found
} else if (error.name === 'NotReadableError') {
// Device is in use by another app
}
}

Best Practices

  1. Always stop tracks when done to release camera/mic resources
  2. Handle errors gracefully with user-friendly messages
  3. Request only what you need - don't request audio if you only need video
  4. Use playsInline attribute on video elements for inline playback
  5. Set muted on video elements showing local camera to prevent feedback
  6. Mirror the front camera using style={{ transform: 'scaleX(-1)' }} so movements feel natural

Media Picker (Camera Roll)

Mini-apps can access the user's photo library using standard HTML file inputs:

// Image picker
<input type="file" accept="image/*" onChange={handleImageSelect} />

// Video picker
<input type="file" accept="video/*" onChange={handleVideoSelect} />

// Both
<input type="file" accept="image/*,video/*" onChange={handleMediaSelect} />

Use URL.createObjectURL(file) to get a displayable URL, and URL.revokeObjectURL(url) when done to prevent memory leaks.


Note: This reference is a summary. See TypeScript definitions for the most up-to-date signatures.