Signing a Message
Last updated
Last updated
When a dApp is connected to Phantom, it can also request that the user signs a given message. Applications are free to write their own messages which will be displayed to users from within Phantom's signature prompt. Message signatures do not involve network fees and are a convenient way for apps to verify ownership of an address.
Phantom’s signMessage
function accepts two parameters: an encoded message
and an address
that should be used to sign the message. It returns a Promise that resolves if the user approves the signature request. Once resolved, it contains the resulting signature
.
The following is an example of how to construct and sign a message with Phantom:
To verify that a message was signed by a given address, we recommend using the bip322-js library like so: