function SignRawPayloadButton() {
const { httpClient } = turnkeyClient; // Assuming you have initialized TurnkeyClient
const doSignRawPayload = async () => {
try {
const signWith = "0xYourWalletAddress"; // Use the address of the wallet you want to sign with
const message = "Hello, Turnkey!";
const hashedMessage = Buffer.from(message, "utf8").toString("hex"); // Convert message to hex format
const response = await httpClient.signRawPayload({
signWith,
payload: hashedMessage,
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
hashFunction: "HASH_FUNCTION_NOT_APPLICABLE",
});
const signature = {response.r, response.s, response.v}; // Extract the signature from the response
console.log("Message signed:", signature);
} catch (error) {
console.error("Error signing message:", error);
}
};
return <button onClick={doSignRawPayload}>Sign Message</button>;
}