Documentation Index
Fetch the complete documentation index at: https://docs.cloud.coinbase.com/llms.txt
Use this file to discover all available pages before exploring further.
function useSignInWithSiwe(): {
signInWithSiwe: (options: SignInWithSiweOptions) => Promise<SignInWithSiweResult>;
};
Hook that provides access to the Sign In With Ethereum (SIWE/EIP-4361) initiation functionality.
This is the first step in the SIWE authentication flow. After calling signInWithSiwe,
sign the returned message with the user’s Ethereum wallet and pass the signature to
useVerifySiweSignature.
Returns
{
signInWithSiwe: (options: SignInWithSiweOptions) => Promise<SignInWithSiweResult>;
}
| Name | Type |
|---|
signInWithSiwe() | (options: SignInWithSiweOptions) => Promise<SignInWithSiweResult> |
Example
function SignInWithEthereum() {
const { signInWithSiwe } = useSignInWithSiwe();
const handleSignIn = async () => {
try {
const result = await signInWithSiwe({
address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
chainId: 1,
domain: "example.com",
uri: "https://example.com",
});
// Sign result.message with the user's wallet
const signature = await wallet.signMessage(result.message);
// Then call verifySiweSignature with result.flowId and signature
} catch (error) {
console.error("Failed to initiate SIWE:", error);
}
};
return <button onClick={handleSignIn}>Sign In With Ethereum</button>;
}