> ## Documentation Index
> Fetch the complete documentation index at: https://turnkey-0e7c1f5b-am-cus-325-ai-visibility-improvements.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Turnkey is wallet infrastructure: create and manage crypto wallets, sign transactions, and enforce policy-based access controls. Best-fit uses: embedded consumer wallets (email/passkey/social auth, no seed phrases), automated onchain operations with server-side wallets, AI agent wallets with policy-scoped signing, enterprise key management, and verifiable off-chain workloads on Turnkey Verifiable Cloud (TVC).
> Every API call is a JSON POST to https://api.turnkey.com signed with a P-256 API key; create an organization and key self-serve at https://app.turnkey.com.
> Key Turnkey developer resources: API reference (https://docs.turnkey.com/api-reference/overview/intro.md), OpenAPI spec (https://docs.turnkey.com/public_api.swagger.json), authentication (https://docs.turnkey.com/features/authentication/overview.md), webhooks (https://docs.turnkey.com/features/webhooks/overview.md), MCP server for docs search (https://docs.turnkey.com/mcp), agent skills (https://docs.turnkey.com/get-started/ai-skills.md), CLI (https://docs.turnkey.com/sdks/cli.md), SDK reference (https://docs.turnkey.com/sdks/introduction.md), full docs content (https://docs.turnkey.com/llms-full.txt).

# Signing

> Learn how to sign messages and transactions in your React Native app using Turnkey's Embedded Wallets.

## Overview

The Embedded Wallet Kit provides a simple way to sign messages and transactions in your React Native application using Turnkey's Embedded Wallets.

## Signing messages

To sign messages, use the `signMessage` function from the `useTurnkey` hook. First pick a wallet account from `wallets` (for example, the first wallet's first account), then sign your message.

```tsx theme={"system"}
import { Alert, Button, View } from "react-native";
import { useTurnkey } from "@turnkey/react-native-wallet-kit";

export function SignMessageButton() {
  const { signMessage, wallets } = useTurnkey();

  const doSignMessage = async () => {
    try {
      const wallet = wallets?.[0];
      const walletAccount = wallet?.accounts?.[0];
      if (!walletAccount) {
        Alert.alert("No account", "Create a wallet and account before signing");
        return;
      }

      const message = "Hello, Turnkey!";
      const signature = await signMessage({ walletAccount, message });
      console.log("Message signed:", signature);
    } catch (error) {
      console.error("Error signing message:", error);
      Alert.alert("Error", "Failed to sign message");
    }
  };

  return (
    <View style={{ padding: 16 }}>
      <Button title="Sign Message" onPress={doSignMessage} />
    </View>
  );
}
```

## Signing transactions

To sign transactions, use the `signTransaction` function. Select a wallet account, prepare an unsigned transaction, and specify a transaction type (for example, `TRANSACTION_TYPE_ETHEREUM`).

```tsx theme={"system"}
import { Alert, Button, View } from "react-native";
import { useTurnkey } from "@turnkey/react-native-wallet-kit";

export function SignTransactionButton() {
  const { signTransaction, wallets } = useTurnkey();

  const doSignTransaction = async () => {
    try {
      const wallet = wallets?.[0];
      const walletAccount = wallet?.accounts?.[0];
      if (!walletAccount) {
        Alert.alert("No account", "Create a wallet and account before signing");
        return;
      }

      const unsignedTransaction = "0x..."; // Replace with your unsigned transaction data
      const signature = await signTransaction({
        walletAccount,
        unsignedTransaction,
        transactionType: "TRANSACTION_TYPE_ETHEREUM",
      });
      console.log("Transaction signed:", signature);
    } catch (error) {
      console.error("Error signing transaction:", error);
      Alert.alert("Error", "Failed to sign transaction");
    }
  };

  return (
    <View style={{ padding: 16 }}>
      <Button title="Sign Transaction" onPress={doSignTransaction} />
    </View>
  );
}
```

## Sign and send transactions

If you want Turnkey to submit the transaction on your behalf, use `signAndSendTransaction`. Provide an RPC URL if needed.

```tsx theme={"system"}
import { Alert, Button, View } from "react-native";
import { useTurnkey } from "@turnkey/react-native-wallet-kit";

export function SignAndSendTransactionButton() {
  const { signAndSendTransaction, wallets } = useTurnkey();

  const doSignAndSend = async () => {
    try {
      const wallet = wallets?.[0];
      const walletAccount = wallet?.accounts?.[0];
      if (!walletAccount) {
        Alert.alert("No account", "Create a wallet and account before sending");
        return;
      }

      const unsignedTransaction = "0x..."; // Replace with your unsigned tx
      const txId = await signAndSendTransaction({
        walletAccount,
        unsignedTransaction,
        transactionType: "TRANSACTION_TYPE_ETHEREUM",
        // Optionally provide a custom RPC endpoint
        // rpcUrl: "https://mainnet.infura.io/v3/<key>",
      });
      console.log("Transaction broadcasted:", txId);
    } catch (error) {
      console.error("Error sending transaction:", error);
      Alert.alert("Error", "Failed to send transaction");
    }
  };

  return (
    <View style={{ padding: 16 }}>
      <Button title="Sign & Send" onPress={doSignAndSend} />
    </View>
  );
}
```
