The AbstractClient includes a revokeSessions
method that can be used to revoke session keys from the connected Abstract Global Wallet.
This allows you to invalidate existing session keys, preventing them from being used for future transactions.
Usage
Revoke session(s) by providing either:
import { useAbstractClient } from "@abstract-foundation/agw-react";
export default function RevokeSessions() {
const { data: agwClient } = useAbstractClient();
async function revokeSessions() {
if (!agwClient) return;
// Revoke a single session by passing the session configuration
const { transactionHash } = await agwClient.revokeSessions({
session: existingSession,
});
// Or - revoke multiple sessions at once
const { transactionHash } = await agwClient.revokeSessions({
session: [existingSession1, existingSession2],
});
// Or - revoke sessions using their creation transaction hashes
const { transactionHash } = await agwClient.revokeSessions({
session: "0x1234...",
});
// Or - revoke multiple sessions using their creation transaction hashes
const { transactionHash } = await agwClient.revokeSessions({
session: ["0x1234...", "0x5678..."],
});
// Or - revoke multiple sessions using both session configuration and creation transaction hashes in the same call
const { transactionHash } = await agwClient.revokeSessions({
session: [existingSession, "0x1234..."],
});
}
}
Parameters
session
SessionConfig | Hash | (SessionConfig | Hash)[]
required
The session(s) to revoke. Can be provided in three formats:
-
A single SessionConfig
object
-
A single session key creation transaction hash from createSession.
-
An array of SessionConfig
objects and/or session key creation transaction hashes.
See createSession for more information on the SessionConfig
object.
Returns
The transaction hash of the revocation transaction.