# Sign message

Request a message signature on your wallet's Ethereum provider using `useEmbeddedEthereumWallet`.

## Personal sign

:::info
This method uses Ethereum's `personal_sign` RPC method. The message must be hex-encoded — use viem's `toHex` (or `stringToHex`) before signing.
:::

```tsx [SignMessage.tsx]
import { Button } from 'react-native'
import { toHex } from 'viem'
import { useEmbeddedEthereumWallet } from '@openfort/react-native'

function SignMessage() {
  const ethereum = useEmbeddedEthereumWallet()

  const handleSignMessage = async () => {
    if (ethereum.status !== 'connected') return

    const address = ethereum.activeWallet.address
    const signature = await ethereum.provider.request({
      method: 'personal_sign',
      params: [toHex('Hello from Openfort!'), address],
    })
    console.log('Signature:', signature)
  }

  return (
    <Button
      title="Sign Message"
      onPress={handleSignMessage}
      disabled={ethereum.status !== 'connected'}
    />
  )
}
```

:::info
Smart and Delegated accounts use [EIP-1271](https://eips.ethereum.org/EIPS/eip-1271) for
signature verification. The provider API is identical — the SDK handles the difference under the hood.
:::

## Typed data — EIP-712

Use `eth_signTypedData_v4` for structured, domain-separated signatures. The typed data is passed as a JSON string:

```tsx [SignTypedData.tsx]
import { Button } from 'react-native'
import { useEmbeddedEthereumWallet } from '@openfort/react-native'

const typedData = {
  domain: {
    chainId: 1,
    name: 'Example DApp',
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
    version: '1',
  },
  types: {
    Mail: [
      { name: 'from', type: 'Person' },
      { name: 'to', type: 'Person' },
      { name: 'content', type: 'string' },
    ],
    Person: [
      { name: 'name', type: 'string' },
      { name: 'wallet', type: 'address' },
    ],
  },
  message: {
    from: { name: 'Alice', wallet: '0x2111111111111111111111111111111111111111' },
    to: { name: 'Bob', wallet: '0x3111111111111111111111111111111111111111' },
    content: 'Hello!',
  },
  primaryType: 'Mail',
}

function SignTypedData() {
  const ethereum = useEmbeddedEthereumWallet()

  const handleSign = async () => {
    if (ethereum.status !== 'connected') return

    const address = ethereum.activeWallet.address
    const signature = await ethereum.provider.request({
      method: 'eth_signTypedData_v4',
      params: [address, JSON.stringify(typedData)],
    })
    console.log('Signature:', signature)
  }

  return (
    <Button
      title="Sign Typed Data"
      onPress={handleSign}
      disabled={ethereum.status !== 'connected'}
    />
  )
}
```
