Sign arbitrary bytes to prove ownership of a Stellar address without submitting a transaction. This is useful for authentication and off-chain verification.
Sign Bytes
Use the ParaStellarSigner class API to sign arbitrary bytes directly:
import { useParaStellarSigner } from "@getpara/react-native-wallet/stellar";
import { Networks } from "@stellar/stellar-sdk";
import { View, Text, Button } from "react-native";
function SignMessage() {
const { stellarSigner, isLoading } = useParaStellarSigner({
networkPassphrase: Networks.PUBLIC,
});
const signMessage = async () => {
if (!stellarSigner) return;
const message = "Hello, Stellar!";
const messageBytes = Buffer.from(new TextEncoder().encode(message));
const signature = await stellarSigner.signBytes(messageBytes);
console.log("Message:", message);
console.log("Signature:", signature.toString("hex"));
console.log("Signer:", stellarSigner.address);
};
if (isLoading) return <Text>Loading...</Text>;
return <Button title="Sign Message" onPress={signMessage} />;
}
Stellar does not have a standardized message signing format like EIP-191 on Ethereum. The signBytes method signs raw bytes using Ed25519. Both parties must agree on how to encode and hash the message before signing.
Next Steps