Skip to main content

Sign a message

Overview

This guide describes how to sign messages using the MPC SDK. 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.

info

The MPC SDK exclusively supports signing string-type messages.

Prerequisites

Complete the steps in Create an MPC wallet.

Sign a message

To sign a message using mpcCore, use the private key shard correspondent to the public address that you generated in Create an MPC wallet, as well as the user's access token after they signed in with their Sky Mavis account.

const result = await mpcCore.signMessage(accessToken, privateKeyShard, message);

Example:

const accessToken = `${ACCESS_TOKEN}`;
const privateKeyShard = `${PRIVATE_KEY}`;
// "Sign this message to breed Axie #223495 with Axie #123232"
const encodedMessage = "U2lnbiB0aGlzIG1lc3NhZ2UgdG8gYnJlZWQgQXhpZSAjMjIzNDk1IHdpdGggQXhpZSAjMTIzMjMy";
const result = await mpcCore.signMessage(accessToken, privateKeyShard, encodedMessage);
//...
Was this helpful?
Happy React is loading...