The signMessage method is a low-level API that signs raw bytes directly without any modifications. This is useful for verifying your Para integration with a simple “Hello, Para!” test after initial setup and authentication.
Important: signMessage signs raw bytes without standard modifications like EIP-191 message prefixes that libraries like Ethers and Viem automatically add. For production use, always use proper Web3 libraries that handle message formatting, encoding standards, and chain-specific requirements.
When to use signMessage: This method is best suited for signing simple text messages and basic authentication flows. For complex operations like transactions, typed data (EIP-712), or chain-specific functionality, you should use the appropriate Web3 library (Viem, Ethers, Solana Web3.js, CosmJS). These libraries provide proper encoding, type safety, and chain-specific features that signMessage alone cannot offer.
Message Signing
This method signs the exact bytes you provide — perfect for initial “hello world” testing:
import { useSignMessage, useWallet } from "@getpara/react-native-wallet";
import { View, Button, Alert } from "react-native";
export default function SignMessageExample() {
const { signMessageAsync, isPending } = useSignMessage();
const { data: wallet } = useWallet();
const handleSign = async () => {
if (!wallet) return;
const message = "Hello, Para!";
const messageBase64 = btoa(message);
try {
const result = await signMessageAsync({
walletId: wallet.id,
messageBase64,
});
Alert.alert("Signature", `0x${result.signature}`);
} catch (err) {
console.error("Failed to sign:", err);
}
};
return (
<View>
<Button title={isPending ? "Signing..." : "Sign Message"} onPress={handleSign} disabled={isPending} />
</View>
);
}
Next Steps
Now that you’ve verified your Para setup, explore chain-specific libraries for more advanced operations: