Sign Messages
WaaP supports signing personal messages as per Sui Wallet Standard for sui:signPersonalMessage.
sui:signPersonalMessage- Prompt the user to sign a message buffer and return the signature to the app.
Sign Message (standard)
Ensure the user has already connected (so wallet.accounts is populated), then call the feature:
import { getWallets } from '@mysten/wallet-standard'
const wallets = getWallets().get()
const wallet = wallets.find(w => w.name === 'WaaP')
if (!wallet || wallet.accounts.length === 0) return
const message = new TextEncoder().encode('Hello, WaaP!')
const result = await wallet.features['sui:signPersonalMessage'].signPersonalMessage({
message,
account: wallet.accounts[0],
})
console.log('Signature:', result.signature)
console.log('Bytes:', result.bytes)
Sign Message (with @mysten/dapp-kit)
@mysten/dapp-kit provides convenient hooks for signing messages.
import { useSignPersonalMessage } from '@mysten/dapp-kit'
export function SignMessage() {
const { mutate: signPersonalMessage } = useSignPersonalMessage()
const handleSign = () => {
signPersonalMessage(
{
message: new TextEncoder().encode('Hello, WaaP!'),
},
{
onSuccess: (result) => {
console.log('Signature:', result.signature)
console.log('Signed Bytes:', result.bytes)
},
onError: (error) => {
console.error('Sign failed', error)
},
},
)
}
return (
<button onClick={handleSign}>
Sign Message
</button>
)
}
Security and User Experience
- User Consent: All signing and transaction actions require explicit user approval via the WaaP modal.
- No Private Key Exposure: The private key is never reconstructed anywhere but done via 2PC (Two-party computation) and 2PC-MPC (Two-party computation - Multi-party computation).