원클릭으로
sign-message
Implement message signing with Phantom Connect SDK for Solana and EVM, including Sign-in with Solana (SIWS) authentication
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Implement message signing with Phantom Connect SDK for Solana and EVM, including Sign-in with Solana (SIWS) authentication
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Build wallet-connected applications with the Phantom Connect SDK for Solana. Use when integrating Phantom wallets into React, React Native, or vanilla JS/TS apps — including wallet connection, social login (Google/Apple), transaction signing, message signing, token-gated access, crypto payments, and NFT minting. Covers @phantom/react-sdk, @phantom/react-native-sdk, and @phantom/browser-sdk.
Configure Google and Apple social login with Phantom Connect SDK to enable embedded wallet creation
Build and send SOL transfers with Phantom Connect SDK, including transaction construction, signing, and verification
Scaffold a vanilla JS/TS app with Phantom Browser SDK for wallet integration, without any framework dependency
Scaffold a React app with Phantom Connect SDK for wallet integration, including social login and Solana support
Scaffold a React Native (Expo) app with Phantom React Native SDK for mobile wallet integration, including polyfills and deep linking
| name | sign-message |
| description | Implement message signing with Phantom Connect SDK for Solana and EVM, including Sign-in with Solana (SIWS) authentication |
import { useSolana } from "@phantom/react-sdk";
function SignMessage() {
const solana = useSolana();
const handleSign = async () => {
const message = new TextEncoder().encode("Hello from my dApp!");
try {
const { signature } = await solana.signMessage(message);
console.log("Signature:", signature);
} catch (error) {
console.error("Signing failed:", error);
}
};
return <button onClick={handleSign}>Sign Message</button>;
}
async function signMessage(sdk: BrowserSDK) {
const message = new TextEncoder().encode("Hello from my dApp!");
try {
const { signature } = await sdk.solana.signMessage(message);
console.log("Signature:", signature);
} catch (error) {
console.error("Signing failed:", error);
}
}
For Ethereum/EVM chains, use signPersonalMessage:
import { useEthereum } from "@phantom/react-sdk";
function SignEVMMessage() {
const ethereum = useEthereum();
const handleSign = async () => {
try {
const { signature } = await ethereum.signPersonalMessage("Hello from my dApp!");
console.log("Signature:", signature);
} catch (error) {
console.error("Signing failed:", error);
}
};
return <button onClick={handleSign}>Sign EVM Message</button>;
}
SIWS provides a standardized authentication flow — proving wallet ownership to your backend:
import { useSolana, useAccounts } from "@phantom/react-sdk";
function SignInWithSolana() {
const solana = useSolana();
const { accounts } = useAccounts();
const handleSIWS = async () => {
const solanaAccount = accounts.find((a) => a.chain === "solana");
if (!solanaAccount) return;
// Construct the SIWS message
const domain = window.location.host;
const uri = window.location.origin;
const nonce = await fetch("/api/auth/nonce").then((r) => r.text()); // Must be server-issued
const issuedAt = new Date().toISOString();
const message = [
`${domain} wants you to sign in with your Solana account:`,
solanaAccount.address,
"",
"Sign in to access your account.",
"",
`URI: ${uri}`,
`Version: 1`,
`Nonce: ${nonce}`,
`Issued At: ${issuedAt}`,
].join("\n");
try {
const { signature } = await solana.signMessage(
new TextEncoder().encode(message)
);
// Send signature + message to your backend for verification
const response = await fetch("/api/auth/verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
message,
signature,
publicKey: solanaAccount.address,
}),
});
if (response.ok) {
console.log("Authenticated successfully!");
}
} catch (error) {
console.error("SIWS failed:", error);
}
};
return <button onClick={handleSIWS}>Sign in with Solana</button>;
}
| Chain | Method | Input | Output |
|---|---|---|---|
| Solana | solana.signMessage(bytes) | Uint8Array | { signature } |
| Ethereum | ethereum.signPersonalMessage(msg) | string | { signature } |
signMessage expects a Uint8Array — use new TextEncoder().encode(...) to convert strings.signPersonalMessage accepts a plain string.