When you request a signature or transaction from a user’s embedded wallet from another app, Privy requires the user to explicitly confirm the signature or transaction. This is accomplished by opening a popup to the provider app’s domain, where the user confirms the action in an isolated environment.
To request signatures and transactions from a user’s embedded wallet from a provider app, use the signMessage, signTypedData, and sendTransaction methods returned by Privy’s useCrossAppAccounts hook
import {useCrossAppAccounts} from '@privy-io/react-auth';

const {signMessage, signTypedData, sendTransaction} = useCrossAppAccounts();
These methods are similar to the signMessage, signTypedData, and sendTransaction methods returned by usePrivy except they all require an additional CrossAppWalletOptions object of the following type:
address
string
required
The address for the cross-app embedded wallet that you’d like to request a signature/transaction from.
If the address you specify in this CrossAppWalletOptions object is not a valid embedded wallet that has been linked to the current user from a provider app, these wallet methods will error.

signMessage

To the signMessage method returned by useCrossAppAccounts, pass the following parameters:
message
string
required
The message the user must sign as a string.
options
CrossAppWalletOptions
required
Options for the cross-app embedded wallet, which must include the requested wallet’s address.

signTypedData

To the signTypedData method returned by useCrossAppAccounts, pass the following parameters:
typedData
SignedTypedDataParams
required
A JSON object that conforms to the EIP-712 TypedData JSON schema.
options
CrossAppWalletOptions
required
Options for the cross-app embedded wallet, which must include the requested wallet’s address.

sendTransaction

To the sendTransaction method returned by useCrossAppAccounts, pass the following parameters:
requestData
UnsignedTransactionRequest
required
The transaction request to be sent.
options
CrossAppWalletOptions
required
Options for the cross-app embedded wallet, which must include the requested wallet’s address.

Example signature request

As an example, you might request a signature from a user’s cross-app wallet like so:
import {usePrivy, useCrossAppAccounts} from '@privy-io/react-auth';

function Button() {
  const {user} = usePrivy();
  const {signMessage} = useCrossAppAccounts();
  const crossAppAccount = user.linkedAccounts.find((account) => account.type === 'cross_app');
  const address = crossAppAccount.embeddedWallets[0].address;

  return (
    <button onClick={() => signMessage('Hello world', {address: address})} disabled={!address}>
      Sign a message with your cross-app wallet
    </button>
  );
}