window.dogesoft
Accounts, signing & events
Read the active account, prove ownership with signMessage, and subscribe to account/connection events.
Proving ownership
signMessage() is the standard way to authenticate a wallet address
without moving a coin or collecting a secret — sign a challenge string, verify the signature against the
address server-side, and you have a login.
const { accounts } = await dogesoft.connect();
const address = accounts[0];
const signature = await dogesoft.signMessage(
`Sign in to My App — ${Date.now()}`,
address
);
await fetch("/api/session", {
method: "POST",
body: JSON.stringify({ address, signature })
});
Include something unique — a timestamp or a server-issued nonce — in the message you ask the user to sign, so a captured signature can't be replayed later.
Events
Subscribe with on(event, handler) and remove a listener with
off(event, handler). Three events are emitted:
| Event | Fires when | Payload |
|---|---|---|
accountsChanged | The user switches the active wallet/account | New accounts array |
connect | Your origin gains an approved connection | Accounts array |
disconnect | The user revokes access | — |
function onAccountsChanged(accounts) {
syncUi(accounts[0] ?? null);
}
dogesoft.on("accountsChanged", onAccountsChanged);
dogesoft.on("disconnect", () => syncUi(null));
// later, if your component unmounts
dogesoft.off("accountsChanged", onAccountsChanged);
Always drive your UI off accountsChanged rather than caching the
address from connect() — wallets can switch accounts at any time
without a page reload.