Sign a message
π Message Signing Methods
Method 1: Direct signMessage()
signMessage()const provider = getProvider();
await provider.connect(); // Must connect first
const message = "To avoid digital dognappers, sign below to authenticate with CryptoCorgis";
const encodedMessage = new TextEncoder().encode(message);
try {
const result = await provider.signMessage(encodedMessage, "utf8");
console.log('β
Message signed successfully!');
console.log('Signature:', result.signature); // Uint8Array (64 bytes)
console.log('Public Key:', result.publicKey); // PublicKey object
console.log('Address:', result.publicKey.toString()); // Base58 address
} catch (error) {
console.error('β Signing failed:', error.message);
}Method 2: JSON RPC request()
request()Input Requirements
Return Value Structure
β
Signature Verification
Verification Example with Manual Public Key
Sign-In with Solana (SIWS)
Last updated