Sign a message
Overview
This guide describes how to sign string messages using Lockbox. In the MPC's collaborative process, the user and the Sky Mavis backend both participate in signing messages, creating a unique signature prefixed with the standard \x19Ethereum Signed Message
. Message signatures serve as irrefutable proof of identity, enabling you to build secure verification systems within your game.
Prerequisites
Complete the steps in Create a wallet.
Sign a message
- Web
- Unity
info
Before signing a message, encode it to Base64.
const txHash = await walletProvider.getSigner().signMessage(message);
Example:
const encodedMessage =
"Sign this message to breed Axie #223495 with Axie #123232";
const txHash = await walletProvider.getSigner().signMessage(encodedMessage);
//...
Task<(string signedMessage, MPCError error)> MPC.SignMessage(string message, string password);
Example:
string password = $"{RECOVERY_PASSWORD}";
string message = "Sign this message to breed Axie #223495 with Axie #123232";
var (data, error) = await MPC.SignMessage(message, password);
if (error != null)
{
Debug.LogError($"Error when signing message: {JsonConvert.SerializeObject(error)}");
}
else
{
Debug.Log($"Signature: {JsonConvert.SerializeObject(data)}");
}