Sign and Verify Messages
Last updated
Last updated
Much like how we described in "How to use access tokens for offchain services & verify them", you can use the access token as a method to verify the ownership of a wallet; but you may not want to use of the Emergence login access token (the token the player signs whenever they log into Emergence).
Using the method "RequestToSign" will send a message signing request to the currently WalletConnect'd user's device (in multiplayer games, you would need to call this client-side). Once they sign the message, "OnRequestToSignCompleted" will execute and the signed message string will be available. If they choose to not sign the message, an error code will be given.
In the example above, the message is sent to the server using Unreals RPC networking system. On the server-side, its received as shown below. The method "ValidateSignedMessage" is used to validate the message, and the bool "Response" will be true if the message is the same as the signed message, and was signed by the given address, and will be false in all other cases.