Docs / Wallet provider / Accounts, signing & events

window.dogesoft

Accounts, signing & events

Read the active account, prove ownership with signMessage, and subscribe to account/connection events.

Live

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.

sign-in.js
const { accounts } = await dogesoft.connect();
const address = accounts[0];

const message = `Sign in to My App: ${nonceFromYourServer}`;
const { signature } = await dogesoft.signMessage(message, address);
// signature: base64 compact signature ("Dogecoin Signed Message" format)

await fetch("/api/session", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ address, message, 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.

signMessage(message, address) resolves with an object containing signature. The extension accepts messages up to 10,000 characters. To check it on your server, any Bitcoin-style message verifier works with the Dogecoin prefix. See the verify example.

Events

Subscribe with on(event, handler) and remove a listener with off(event, handler). Three events are emitted:

EventFires whenPayload
accountsChangedThe user switches the active wallet/accountNew accounts array
connectYour origin gains an approved connectionAccounts array
disconnectThe user revokes access—
events.js
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.