> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phantom.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign typed data (EIP-712)

> Sign structured, typed data using the EIP-712 standard on Ethereum and other EVM chains via Phantom.

Sign structured, typed data using the EIP-712 standard. This provides a better user experience by showing human-readable data in the wallet.

<Tabs>
  <Tab title="React">
    ```tsx theme={null}
    import { useEthereum } from "@phantom/react-sdk";

    function SignTypedData() {
      const { ethereum } = useEthereum();

      const sign = async () => {
        const accounts = await ethereum.getAccounts();

        const typedData = {
          types: {
            EIP712Domain: [
              { name: "name", type: "string" },
              { name: "version", type: "string" },
              { name: "chainId", type: "uint256" },
              { name: "verifyingContract", type: "address" },
            ],
            Order: [
              { name: "from", type: "address" },
              { name: "to", type: "address" },
              { name: "amount", type: "uint256" },
              { name: "nonce", type: "uint256" },
            ],
          },
          primaryType: "Order",
          domain: {
            name: "My App",
            version: "1",
            chainId: 1,
            verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
          },
          message: {
            from: accounts[0],
            to: "0x742d35Cc6634C0532925a3b8D4C8db86fB5C4A7E",
            amount: "1000000000000000000",
            nonce: 1,
          },
        };

        const { signature } = await ethereum.signTypedData(typedData, accounts[0]);
        console.log("Signature:", signature);
        return signature;
      };

      return <button onClick={sign}>Sign Order</button>;
    }
    ```
  </Tab>

  <Tab title="React Native">
    ```tsx theme={null}
    import { useEthereum } from "@phantom/react-native-sdk";
    import { View, Button, Alert, StyleSheet } from "react-native";

    function SignTypedData() {
      const { ethereum } = useEthereum();

      const sign = async () => {
        try {
          const accounts = await ethereum.getAccounts();

          const typedData = {
            types: {
              EIP712Domain: [
                { name: "name", type: "string" },
                { name: "version", type: "string" },
                { name: "chainId", type: "uint256" },
                { name: "verifyingContract", type: "address" },
              ],
              Order: [
                { name: "from", type: "address" },
                { name: "to", type: "address" },
                { name: "amount", type: "uint256" },
                { name: "nonce", type: "uint256" },
              ],
            },
            primaryType: "Order",
            domain: {
              name: "My App",
              version: "1",
              chainId: 1,
              verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
            },
            message: {
              from: accounts[0],
              to: "0x742d35Cc6634C0532925a3b8D4C8db86fB5C4A7E",
              amount: "1000000000000000000",
              nonce: 1,
            },
          };

          const { signature } = await ethereum.signTypedData(typedData, accounts[0]);
          Alert.alert("Success", `Signature: ${signature.slice(0, 20)}...`);
          return signature;
        } catch (error) {
          Alert.alert("Error", error.message);
          throw error;
        }
      };

      return (
        <View style={styles.container}>
          <Button title="Sign Order" onPress={sign} />
        </View>
      );
    }

    const styles = StyleSheet.create({
      container: {
        padding: 20,
      },
    });
    ```
  </Tab>
</Tabs>

## Verify with viem

```typescript theme={null}
import { verifyTypedData } from "viem";

const isValid = await verifyTypedData({
  address: signerAddress,
  domain: typedData.domain,
  types: typedData.types,
  primaryType: typedData.primaryType,
  message: typedData.message,
  signature,
});
```
