Kondor Wallet Integration¶
Kondor is a browser-extension wallet. A website can request account access and signatures, but it cannot read private keys. Every sensitive action must remain visible to and approved by the user.
Detect Kondor¶
export function isKondorAvailable(browser = globalThis) {
return Boolean(browser.window?.kondor);
}
View complete file · Run example
An online runner cannot access an extension installed in another browser or profile. It will truthfully show that Kondor is unavailable.
Request account access¶
export async function connectKondor(api = kondorApi) {
const accounts = await api.getAccounts();
if (!accounts.length) throw new Error("Kondor returned no accounts");
return accounts[0];
}
View complete file · Run example
Call this from a user gesture such as a Connect button and handle rejection.
Set up signer and provider¶
export async function setupKondorSigner(api = kondorApi) {
const [account, signer, provider] = await Promise.all([
connectKondor(api),
api.getSigner(),
api.getProvider(),
]);
signer.provider = provider;
return { account, signer, provider };
}
View complete file · Run example
The provider comes from the wallet, so the application observes the network the user selected instead of silently forcing a stale endpoint.
Request a signature¶
export async function requestMessageSignature(message, api = kondorApi) {
if (!message.trim()) throw new Error("Enter a message before signing");
const { account, signer } = await setupKondorSigner(api);
const signature = await signer.signMessage(message);
return { account, signature };
}
View complete file · Run example
The demo signs a plain message only and never broadcasts a transaction. The wallet still prompts the user to approve the signature.
Refresh account state¶
export async function refreshAccount(previousAccount, api = kondorApi) {
const accounts = await api.getAccounts();
const account = accounts[0] ?? null;
return { account, changed: account !== previousAccount };
}
View complete file · Run example
Refresh after focus or before an action so a changed or disconnected account is not mistaken for the previous one.
Refresh network state¶
export async function refreshNetwork(previousChainId, api = kondorApi) {
const provider = await api.getProvider();
const chainId = await provider.getChainId();
return { chainId, changed: chainId !== previousChainId };
}
View complete file · Run example
Compare chain IDs, not friendly labels, before preparing a state-changing operation.
Complete client¶
export class KondorClient {
constructor(api = kondorApi) {
this.api = api;
this.account = null;
this.chainId = null;
}
async connect() {
const { account, provider } = await setupKondorSigner(this.api);
this.account = account;
this.chainId = await provider.getChainId();
return { account: this.account, chainId: this.chainId };
}
async signMessage(message) {
return requestMessageSignature(message, this.api);
}
disconnect() {
this.account = null;
this.chainId = null;
}
}
View complete file · Run example
The linked Vite project includes UI wiring, automated mocks, and a production build. Run it in the browser profile where Kondor is installed to exercise wallet approval.