diff --git a/docs/base-account/framework-integrations/wagmi/setup.mdx b/docs/base-account/framework-integrations/wagmi/setup.mdx index cd96ec631..36d86e5a0 100644 --- a/docs/base-account/framework-integrations/wagmi/setup.mdx +++ b/docs/base-account/framework-integrations/wagmi/setup.mdx @@ -335,9 +335,7 @@ export function SignInWithBase({ connector }: SignInWithBaseProps) { if (provider) { try { // Generate a fresh nonce (this will be overwritten with the backend nonce) - const clientNonce = - Math.random().toString(36).substring(2, 15) + - Math.random().toString(36).substring(2, 15); + const clientNonce = crypto.randomUUID(); console.log("clientNonce", clientNonce); // Connect with SIWE to get signature, message, and address const accounts = await (provider as any).request({ diff --git a/docs/base-account/guides/sign-and-verify-typed-data.mdx b/docs/base-account/guides/sign-and-verify-typed-data.mdx index 180fb15ec..78fac33d1 100644 --- a/docs/base-account/guides/sign-and-verify-typed-data.mdx +++ b/docs/base-account/guides/sign-and-verify-typed-data.mdx @@ -172,6 +172,7 @@ export async function verifyTypedData(req, res) { ## Example Express Server ```ts title="server/typed-data.ts" +import crypto from 'crypto'; import express from 'express'; import { createPublicClient, http } from 'viem'; import { base } from 'viem/chains'; @@ -190,7 +191,7 @@ const usedNonces = new Set(); app.get('/typed-data/prepare', (req, res) => { const { userAddress, action, resource } = req.query; - const nonce = Math.floor(Math.random() * 1000000); + const nonce = crypto.randomInt(1_000_000); const expiry = Math.floor(Date.now() / 1000) + 3600; // 1 hour const typedData = { diff --git a/docs/base-account/reference/ui-elements/sign-in-with-base-button.mdx b/docs/base-account/reference/ui-elements/sign-in-with-base-button.mdx index 03809c855..df314567c 100644 --- a/docs/base-account/reference/ui-elements/sign-in-with-base-button.mdx +++ b/docs/base-account/reference/ui-elements/sign-in-with-base-button.mdx @@ -325,7 +325,7 @@ const handleSignInWithSIWE = async () => { address: account, chainId: base.id, domain: window.location.host, - nonce: Math.random().toString(36).substring(7), + nonce: crypto.randomUUID(), uri: window.location.origin, version: '1', statement: 'Sign in to MyApp with your Base Account'