// 1) Initialise a PKP‑scoped viem account and permissions manager
const pkpViemAccount = await litClient.getPkpViemAccount({
pkpPublicKey: myPkp.publicKey,
authContext,
chainConfig: litClient.getChainConfig().viemConfig,
});
const pkpPermissionsManager = await litClient.getPKPPermissionsManager({
pkpIdentifier: { tokenId: myPkp.tokenId },
account: pkpViemAccount,
});
// 2) Read current permissions and perform checks
const ctx = await pkpPermissionsManager.getPermissionsContext();
console.log(ctx.addresses, ctx.actions, ctx.authMethods);
const isAddrAllowed = await pkpPermissionsManager.isPermittedAddress({
address: "0xabc...def",
});
// 3) Manage an auth method and its scopes (requires PKP ownership)
const addTx = await pkpPermissionsManager.addPermittedAuthMethod({
authMethodType: 1, // EthWallet
authMethodId: "0x1234567890abcdef1234567890abcdef12345678",
userPubkey:
"0x04abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
scopes: ["sign-anything"],
});
await addTx.receipt;
// Remove a specific scope (e.g. scopeId 1) from that auth method
const removeScopeTx =
await pkpPermissionsManager.removePermittedAuthMethodScope({
authMethodType: 1,
authMethodId: "0x1234567890abcdef1234567890abcdef12345678",
scopeId: 1,
});
await removeScopeTx.receipt;
// Optionally remove the auth method entirely
const removeAuthMethodTx =
await pkpPermissionsManager.removePermittedAuthMethod({
authMethodType: 1,
authMethodId: "0x1234567890abcdef1234567890abcdef12345678",
});
await removeAuthMethodTx.receipt;