mina_signMessage

This method is used to sign message.

Params

type SignMessageArgs = {
    // The message that need to sign.
    readonly message: string
}

Result

interface SignedData {
    // sign account address.
    publicKey: string;
    // sign message.
    data: string;
    // sign result.
    signature: {
        field: string;
        scalar: string;
    }
}

interface ProviderError extends Error {
    message: string; // error message.
    code: number; // error code.
    data?: unknown; // error body. 
}


Promise<SignedData | ProviderError> 

Errors

Example

Request

const content = `Click "Sign" to sign in. No password needed!

This request will not trigger a blockchain transaction or cost any gas fees.

I accept the Auro Test zkApp Terms of Service: ${window.location.href}

address: ${currentAccount}
iat: ${new Date().getTime()}`;

await window.mina?.signMessage({ message: content }).catch((err: any) => err);

Result

// successful result.
{
  "signature": {
    "field": "13468724101429370746602596170094552502200193721398063751467629418902449650534",
    "scalar": "5638584219029837254561020594864591092072844530049610703222272818700774330907"
  },
  "publicKey": "B62qr2zNMypNKXmzMYSVotChTBRfXzHRtshvbuEjAQZLq6aEa8RxLyD",
  "data": "Click \"Sign\" to sign in. No password needed!\n\nThis request will not trigger a blockchain transaction or cost any gas fees.\n\nI accept the Auro Test zkApp Terms of Service: http://localhost:3000/\n\naddress: \niat: 1699294808439"
}

// can not get connect address.
{
  "code": 1001,
  "message": "User disconnect, please connect first."
}

// user reject.
{
  "code": 1002,
  "message": "User rejected the request."
}

Last updated