> For the complete documentation index, see [llms.txt](/llms.txt).

# Sign in with Solana

[Sign-In with Solana (SIWS)](https://docs.siws.xyz/) lets users sign in to your dapp by authenticating with their MetaMask wallet, instead of a traditional username and password.

![Sign-in with Solana request](/assets/images/siwe-4c764ff564dac828ab4f91bf72d9b199.png)

## Domain binding[​](#domain-binding "Direct link to Domain binding")

MetaMask supports domain binding with SIWS to help prevent phishing attacks. When a site asks a user to sign a SIWS message, but the domain in the message doesn't match the site the user is on, MetaMask displays a warning in the sign-in interface. The user must explicitly select to proceed, accepting the risk of a phishing attack.

important

MetaMask displays a prominent warning for mismatched domains, but does **not** block users from bypassing the warning and accepting the sign-in request. This avoids breaking existing dapps that may have use cases for mismatched domains.

![MetaMask Sign-In with Solana domain mismatch warning](/assets/images/siwe-bad-domain-dcb08bee1f9104bfe4a0594136758f33.png)

![MetaMask Sign-In with Solana domain mismatch detailed warning popup](/assets/images/siwe-bad-domain-2-f52261a93ea9864d873f0a82b60bd2be.png)

## Example[​](#example "Direct link to Example")

The following example shows how to set up SIWS with MetaMask using [solana:signMessage](/metamask-connect/solana/reference/methods/#supported-wallet-standard-features):

index.js

```
import { createSolanaClient } from '@metamask/connect-solana'

const solanaClient = await createSolanaClient({
  dapp: {
    name: 'My Solana Dapp',
    url: window.location.origin,
  },
})

const wallet = solanaClient.getWallet()
const { accounts } = await wallet.features['standard:connect'].connect()

const siwsSign = async siwsMessage => {
  try {
    const message = new TextEncoder().encode(siwsMessage)
    const [{ signature }] = await wallet.features['solana:signMessage'].signMessage({
      account: accounts[0],
      message,
    })
    siwsResult.innerHTML = signature
  } catch (err) {
    console.error(err)
    siwsResult.innerHTML = `Error: ${err.message}`
  }
}

siws.onclick = async () => {
  const domain = window.location.host
  const from = accounts[0].address
  const siwsMessage = `${domain} wants you to sign in with your Solana account:\n${from}\n\nI accept the MetaMask Terms of Service: https://community.metamask.io/tos\n\nURI: https://${domain}\nVersion: 1\nChain ID: 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z`
  siwsSign(siwsMessage)
}

```

The following HTML displays the SIWS button:

index.html

```
<h4>Sign-In with Solana</h4>
<button type="button" id="siws">Sign-In with Solana</button>
<p class="alert">Result:<span id="siwsResult"></span></p>

```

See the [JavaScript quickstart](/metamask-connect/solana/quickstart/javascript/) for a complete working example.

## Next steps[​](#next-steps "Direct link to Next steps")

- [Sign messages](/metamask-connect/solana/guides/sign-data/sign-message/) for general-purpose offchain signatures without domain binding.
- [Send a legacy transaction](/metamask-connect/solana/guides/send-transactions/legacy/) to transfer SOL or interact with Solana programs.
- See [MetaMask Connect Solana methods](/metamask-connect/solana/reference/methods/) for the full list of Wallet Standard features.
