Hey all,
Wanted to share an npm library I created for the sign-in-with-stacks SIP proposal.
The idea is simple, we need a standardized way for users to log into Stacks apps with their wallet. Ethereum has had SIWE (Sign-In with Ethereum) for a while now, and it’s been adopted by many apps and wallets. Stacks should have the same thing.
Right now, if you want wallet-based auth, you’re rolling your own message format and verification logic. This library gives you a clean and easy way to create and verify sign-in messages following the SIP spec:
import { createSiwsMessage, verifySiwsMessage, generateSiwsNonce } from "sign-in-with-stacks";
// Create the message
const message = createSiwsMessage({
address: "SP2X0TZ59D5SZ8ACQ6YMCHHNR2ZN51Z32E2CJ173",
chainId: STACKS_MAINNET.chainId,
domain: "example.com",
nonce: generateSiwsNonce(),
uri: "https://example.com",
version: "1",
});
// Verify on your backend
const valid = verifySiwsMessage({ message, signature, nonce });
It works with any JS backend, and there’s a Better Auth plugin included.
I’ve already opened a proposal for Leather to add native SIWS support to the wallet. You can follow that discussion here: Sign in with Stacks (SIWS) · Issue #1832 · leather-io/mono · GitHub
Links
- Docs: Getting Started | Sign-In with Stacks
- GitHub: GitHub - pradel/sign-in-with-stacks: Sign-in with Stacks is a library for creating and verifying Sign-In with Stacks messages.
- SIP Proposal: Sign-in with stacks by friedger · Pull Request #70 · stacksgov/sips · GitHub
Would love to hear your thoughts, let me know if you have any feedback!