Skip to main content

Request Permissions

RequestPermissions helps dApps connect with users' wallets. This involves asking for and getting the user's permission to access certain wallet features, which is needed for any actions the dApp wants to perform with the user's account.

Example
import { DAppClient, PermissionScope } from "@airgap/beacon-sdk";

const dAppClient = new DAppClient({ name: "Beacon Docs" });

// You can request specific permissions if you want
const scopes: PermissionScope[] = [
  PermissionScope.OPERATION_REQUEST,
  PermissionScope.SIGN,
];

try {
  console.log("Requesting permissions...");
  const permissions = await dAppClient.requestPermissions({ scopes });
  console.log("Got permissions:", permissions.address);
} catch (error) {
  console.error("Got error:", error);
}
Loading...