For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

useSignatureRequest

Hook to send a JSON-RPC signing request through Wallet Services. Unlike signing directly with connection.ethereumProvider, Wallet Services shows the user a confirmation screen in the in-app browser before it signs.

Import​

import { useSignatureRequest } from '@web3auth/react-native-sdk'

Usage​

import { useSignatureRequest, useWeb3Auth } from '@web3auth/react-native-sdk'
import { Button, Text, View } from 'react-native'
import { createWalletClient, custom, parseEther, stringToHex, toHex } from 'viem'

function SigningView() {
const { request, loading, error } = useSignatureRequest()
const { connection } = useWeb3Auth()

const getAddress = async () => {
const walletClient = createWalletClient({
transport: custom(connection!.ethereumProvider!),
})
const [address] = await walletClient.getAddresses()
return address
}

const signPersonalMessage = async () => {
const address = await getAddress()
const signature = await request('personal_sign', [
stringToHex('Hello from Embedded Wallets'),
address,
])
console.log('Signature:', signature)
}

const sendTransaction = async () => {
const address = await getAddress()
const txHash = await request('eth_sendTransaction', [
{
from: address,
to: '0x0000000000000000000000000000000000000001',
value: toHex(parseEther('0.001')),
},
])
console.log('Transaction hash:', txHash)
}

return (
<View>
<Button title="Sign message" disabled={loading} onPress={signPersonalMessage} />
<Button title="Send ETH" disabled={loading} onPress={sendTransaction} />
{error && <Text>{error.message}</Text>}
</View>
)
}

Return type​

import { type IUseSignatureRequest } from '@web3auth/react-native-sdk'

request​

(method: string, params: unknown[], path?: string) => Promise<string>

Opens Wallet Services with a confirmation screen for the JSON-RPC request and resolves with the result after the user approves. If the user rejects or the request fails, request resolves with undefined and sets error. The optional path is wallet/request by default.

Common method values:

MethodDescription
personal_signSign a personal message (EIP-191).
eth_signTypedData_v4Sign typed structured data (EIP-712).
eth_sendTransactionSign and send a transaction.
eth_signTransactionSign a transaction without broadcasting.

loading​

boolean

true while the request is waiting for the user or the network.

error​

Web3authRNError | null

Error from the most recent request call, or null.