The challenge format, the flow, and how to verify a sign-in on your server.
The challenge text
The wallet signs a short, readable text (modelled on EIP-4361, adapted for Dogecoin). This one was produced by createSignInMessage in the Node example below:
Challenge
shop.example wants you to sign in with your Dogecoin address:
ncKhVJVYFCoFfFpMp8yTPjzwt3yykFcDcC
Sign in to Example Shop.
URI: https://shop.example/login
Version: 1
Network: testnet
Nonce: e9106b1bf4f051cb357b72bb4330ccc4
Issued At: 2026-11-29T01:03:08.953Z
Expiration Time: 2026-11-29T01:08:08.953Z
Part
Rule
Line 1: domain
Lowercase host, with port if any, exactly as location.host; then the fixed words "wants you to sign in with your Dogecoin address:". The words say "Dogecoin" on purpose, so a message from another chain cannot be passed off as this one.
Line 2: address
Base58Check P2PKH address, checked against the stated network.
Statement (optional)
One line, 1 to 1024 characters, no leading or trailing space, no control or invisible characters. Absent: two empty lines in a row.
URI
Where the sign-in happens: an absolute URI of printable ASCII, up to 2048 characters.
Version
Always 1.
Network
mainnet or testnet (testnet covers regtest).
Nonce
16 to 128 letters or digits. The one your server issued.
Issued At
UTC time, YYYY-MM-DDThh:mm:ss[.mmm]Z.
Expiration Time (optional)
Must be after Issued At. The element sets it from expires-in (default 600 seconds).
Not Before, Request ID, Resources (optional)
In that order; up to 32 resource URIs.
Fixed order, one space after each colon, at most 8192 characters, no carriage returns. The parser accepts exactly what createSignInMessage produces and rejects everything else, so a statement such as URI: x cannot be mistaken for the URI line.
The flow
No coins move, no fee is paid and nothing goes on chain. A signature proves that someone holding the key signed this exact text at that time. It does not prove who they are or that they own any coins.
Add it to your page
Copy signin.js (112,103 bytes on this site) to your own host. The page asks your server for a nonce, gives it to the element, and posts the proof to your server when the wallet has signed:
HTML
<script src="signin.js?v=202611291136" defer></script>
<doge-signin id="signin" mode="button" network="mainnet"
statement="Sign in to Example Shop." expires-in="300"></doge-signin>
<script>
const el = document.getElementById('signin');
// 1. Ask YOUR server for a fresh one-use nonce, and give it to the element.
async function newChallenge() {
const { nonce } = await (await fetch('/challenge', { method: 'POST' })).json();
el.setAttribute('nonce', nonce);
}
newChallenge();
// 2. The wallet signed. Send the proof to your server; it decides whether to log the person in.
el.addEventListener('doge-signin:verified', async (e) => {
const { message, signature } = e.detail;
const res = await fetch('/login', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ message, signature }),
});
console.log('server says', res.status, JSON.stringify(await res.json()));
if (!res.ok) newChallenge(); // a nonce is used once, so ask for a new one
});
</script>
Tested in Chrome against the server below, with MyDoge simulated by a stand-in extension: the console showed server says 200 {"address":"DPcyZZYN9Z5fyRBLkEqbqwFkfdf9oQ9nfc"}.
Verify on your server
Never trust the browser's "verified". The server rebuilds what it expects and checks the proof against that, not against what the message says about itself:
JavaScript (server.mjs)
// Node 20+, no framework. POST /challenge issues a nonce; POST /login verifies the signed text and starts a session.
import { createServer } from 'node:http';
import { randomBytes } from 'node:crypto';
import { generateNonce, parseSignInMessage, verifySignIn } from '@dogejs/signin/verify';
const DOMAIN = 'shop.example'; // exactly what location.host shows in the browser
const URI_PREFIX = 'https://shop.example/';
const nonces = new Map(); // nonce -> expiry (ms). Use Redis or a database if you run several servers.
const sessions = new Map(); // session id -> address
const json = (res, status, body, headers = {}) => {
res.writeHead(status, { 'content-type': 'application/json', ...headers });
res.end(JSON.stringify(body));
};
const readJson = async (req) => { let s = ''; for await (const c of req) s += c; return JSON.parse(s || '{}'); };
createServer(async (req, res) => {
if (req.method === 'POST' && req.url === '/challenge') {
const nonce = generateNonce();
nonces.set(nonce, Date.now() + 5 * 60_000);
return json(res, 200, { nonce });
}
if (req.method === 'POST' && req.url === '/login') {
const { message, signature } = await readJson(req);
let nonce;
try { nonce = parseSignInMessage(message).nonce; } catch { return json(res, 400, { error: 'malformed' }); }
const expiry = nonces.get(nonce);
nonces.delete(nonce); // single use, whatever happens next
if (!expiry || expiry < Date.now()) return json(res, 401, { error: 'unknown_or_used_nonce' });
const r = verifySignIn({ message, signature, expected: { domain: DOMAIN, nonce, network: 'mainnet' } });
if (!r.ok) return json(res, 401, { error: r.reason });
if (!r.fields.uri.startsWith(URI_PREFIX)) return json(res, 401, { error: 'uri_mismatch' });
const sid = randomBytes(24).toString('hex');
sessions.set(sid, r.address); // r.address is the proven address
return json(res, 200, { address: r.address },
{ 'set-cookie': `sid=${sid}; HttpOnly; Secure; SameSite=Lax; Path=/; Max-Age=86400` });
}
json(res, 404, { error: 'not_found' });
}).listen(3000);
Run: issue, sign, verify and replay
JavaScript
// The whole Sign in with Doge server flow in one file: challenge, wallet signature, verification.
import { generatePrivateKey, getPublicKey, encodeWif, p2pkhAddress, signMessage, testnet } from '@dogejs/core';
import { createSignInMessage, generateNonce, verifySignIn } from '@dogejs/signin/verify';
// ---- Server: a nonce store. One use only; entries expire after 10 minutes.
const nonces = new Map();
const issueNonce = () => { const n = generateNonce(); nonces.set(n, Date.now() + 10 * 60_000); return n; };
const consumeNonce = (n) => { const exp = nonces.get(n); nonces.delete(n); return exp !== undefined && exp > Date.now(); };
// ---- Wallet (stands in for the visitor's wallet): signs whatever text it is shown.
const key = generatePrivateKey();
const address = p2pkhAddress(getPublicKey(key), testnet);
const wallet = (text) => signMessage(text, encodeWif(key, { network: testnet }));
// 1. GET /challenge: the server picks the nonce and the page builds the text (the <doge-signin> element does this for you).
const nonce = issueNonce();
const message = createSignInMessage({
domain: 'shop.example', address, uri: 'https://shop.example/login', network: 'testnet',
statement: 'Sign in to Example Shop.', nonce, issuedAt: new Date(), expirationTime: new Date(Date.now() + 5 * 60_000),
});
console.log(message);
console.log('---');
// 2. The wallet shows the text, the person approves, the wallet signs.
const signature = wallet(message);
// 3. POST /login: verify against what YOU expect, never against what the message says about itself.
function login({ message, signature }, expectedNonce) {
const r = verifySignIn({ message, signature, expected: { domain: 'shop.example', nonce: expectedNonce, network: 'testnet', uri: 'https://shop.example/login' } });
if (!r.ok) return { ok: false, why: r.reason };
if (!consumeNonce(expectedNonce)) return { ok: false, why: 'nonce_reused' }; // YOUR bookkeeping: one use only
return { ok: true, address: r.address };
}
const first = login({ message, signature }, nonce);
console.log('first attempt :', first.ok, first.address === address ? '(address proven)' : '');
console.log('replayed :', JSON.stringify(login({ message, signature }, nonce)));
Output
shop.example wants you to sign in with your Dogecoin address:
naLpXpKgcqZXHiVzXLr8Khwr4A73MtYqXn
Sign in to Example Shop.
URI: https://shop.example/login
Version: 1
Network: testnet
Nonce: 4c6c248e35f4acf2a529f06d9ed9c48e
Issued At: 2026-11-29T01:06:30.012Z
Expiration Time: 2026-11-29T01:11:30.012Z
---
first attempt : true (address proven)
replayed : {"ok":false,"why":"nonce_reused"}
The rules, and what each failure looks like
Run: every check failing in turn
JavaScript
import { generatePrivateKey, getPublicKey, encodeWif, p2pkhAddress, signMessage, testnet } from '@dogejs/core';
import { createSignInMessage, generateNonce, verifySignIn, parseSignInMessage } from '@dogejs/signin/verify';
const key = generatePrivateKey();
const address = p2pkhAddress(getPublicKey(key), testnet);
const sign = (m) => signMessage(m, encodeWif(key, { network: testnet }));
const base = { domain: 'shop.example', address, uri: 'https://shop.example/login', network: 'testnet', nonce: generateNonce(), statement: 'Sign in to Example Shop.' };
const expected = { domain: 'shop.example', nonce: base.nonce, network: 'testnet' };
const now = new Date('2026-11-28T12:00:00Z');
const make = (extra = {}, over = {}) => { const m = createSignInMessage({ ...base, issuedAt: now, expirationTime: new Date(now.getTime() + 600_000), ...extra }); return { message: m, signature: sign(m), ...over }; };
const check = (label, input, exp = expected, at = new Date(now.getTime() + 60_000)) => {
const r = verifySignIn({ ...input, expected: exp, now: at });
console.log(label.padEnd(34), r.ok ? 'ok' : `${r.reason}`);
};
check('good, one minute after issue', make());
check('three minutes past expiry', make(), expected, new Date(now.getTime() + 600_000 + 180_000));
check('just inside the 60 s skew', make(), expected, new Date(now.getTime() + 600_000 + 30_000));
check('signed for another domain', make({ domain: 'evil.example' }));
check('another nonce than the one issued', make(), { ...expected, nonce: generateNonce() });
check('mainnet expected, testnet message', make(), { ...expected, network: 'mainnet' });
check('uri differs', make(), { ...expected, uri: 'https://shop.example/admin' });
check('one character of the text changed', (() => { const g = make(); return { ...g, message: g.message.replace('Example Shop.', 'Example Shop!') }; })());
check('signature from another key', (() => { const g = make(); const other = generatePrivateKey(); return { ...g, signature: signMessage(g.message, encodeWif(other, { network: testnet })) }; })());
check('not a signature', make({}, { signature: 'AAAA' }));
check('issued in the future', make({ issuedAt: new Date(now.getTime() + 3_600_000), expirationTime: new Date(now.getTime() + 4_200_000) }));
check('not even a message', { message: 'hello', signature: 'x' });
console.log('parse a message back:', Object.keys(parseSignInMessage(make().message)).join(', '));
Output
good, one minute after issue ok
three minutes past expiry expired
just inside the 60 s skew ok
signed for another domain domain_mismatch
another nonce than the one issued nonce_mismatch
mainnet expected, testnet message wrong_network
uri differs uri_mismatch
one character of the text changed signature_mismatch
signature from another key signature_mismatch
not a signature malformed_signature
issued in the future not_yet_valid
not even a message malformed_message
parse a message back: domain, address, uri, version, network, nonce, issuedAt, statement, expirationTime
Rule
What the server must do
Domain
Pass your own domain in expected.domain. Never read it from the message. A signature made for another site fails with domain_mismatch.
Nonce
Issue it yourself, store it, accept it once, expire it. verifySignIn checks that it matches; whether it was used already is your bookkeeping (replay protection).
Expiry
The message carries Expiration Time; a 60 second clock skew is allowed (clockSkewSeconds). Keep it short.
Network and URI
Pass expected.network, and expected.uri when one domain hosts several apps.
Signature
Dogecoin Core signmessage format, 65 bytes, base64. Checked last because it is the costly step.
All reasons returned
reason
Meaning
invalid_arguments
Unusable input (no expected domain or nonce, non-string message). Fails closed.
malformed_message
Not exactly the grammar; detail says which line.
unsupported_address_type
A P2SH address. Script addresses cannot sign messages.
Pop-up window and postMessage; the wallet shows the site and the text and signs after approval. It needs an https page (or localhost) and a challenge with an expiry of at most one day.
Any other wallet
Manual path: copy the challenge, sign it with "sign message" (Dogecoin Core: dogecoin-cli signmessage "D..." "<challenge>"), paste the signature.
Only P2PKH addresses (D… on mainnet) can sign in. Multisig and other script (P2SH) wallets cannot, because a plain message signature has no script to commit to.
Session handling
After ok, create your own session (random id, HttpOnly; Secure; SameSite=Lax cookie) as the example does. The signature itself is not a session.
Consume the nonce before anything else, even on failure.
Use a shared store (Redis or a database) for nonces if you run more than one server.
A signature proves control of a key, not ownership of coins. For token-gating, check the chain yourself.
Verification in the browser alone is personalisation, not access control: anything the page can check, the visitor can bypass.
git clone https://github.com/DogeJS-Dev/sign-in
cd sign-in
npm install
npm run build # dist/signin.js for a script tag; dist/ also has the ESM entries
npm test
Copy dist/signin.js to your host. The server entry @dogejs/signin/verify needs no DOM and runs in Node 20+ and edge runtimes. The element makes no request of its own to anyone except a wallet window you open.
FAQ
Does the person pay anything?
No. Nothing goes on chain.
Can I skip the server?
For showing "signed in as D..." on a static page, yes. For anything that needs protecting, no.
Why did my verification return domain_mismatch?
The domain in the challenge must equal what you pass in expected.domain, which should match location.host in the browser, port included.
Can a multisig wallet sign in?
No. Only single-key P2PKH addresses can sign messages.
How long is a challenge valid?
600 seconds by default (expires-in), plus 60 seconds of clock skew on the server.