Embedded Wallets
SDK
Javascript
How to
Wallet Operation
Sign Message

Sign Message

This method allows users to sign a message using their MPC wallet.

Method Signature

async signMessage(config: SignMessageConfig): Promise<string>

Parameters

config: SignMessageConfig - An object with the following properties:

  • network: Network (required) - The network used for transactions. You can use the Network enum to specify the network.
  • message: string (required) - The message to sign.
  • walletToken: string (required) - The wallet token of the wallet to sign the message for.
  • refreshToken: string (optional) - The refresh token for authentication. Use this if you want to allow SDK automatically refresh the wallet token.

Returns

Promise<{signature: string, walletToken?: string, refreshToken?: string}> - An object containing the signature of the message, and the new wallet token and refresh token if the refresh token is provided.

Example Usage

const signature = await sdk.wallet.signMessage({
  network: Network.ETHEREUM,
  message: 'Hello, world!',
  walletToken: 'your-wallet-token',
  refreshToken: 'your-refresh-token' // Optional
});
console.log(signature);

Response Example

{
  "signature": "0x6b589c68bdcd3024232d60d10ec12a6ed1c5efd14855d3ea49a43b7f79c01649514a73d2d1a25151642f1a207ffcd3ba0b22f7241970f0fc8612b1d7718ca4ed1b",
  "walletToken": "your-new-wallet-token",
  "refreshToken": "your-new-refresh-token"
}
ℹ️

The SDK will automatically refresh the wallet token and return the new wallet token and refresh token if the refresh token is provided.

ℹ️

The response is a string representing the signature of the message.

Additional Information

  • This method requires a valid wallet token in the SDK configuration.
  • The signature can be used to prove that the owner of the private key signed the message without revealing the private key.
  • The network parameter is required to determine which blockchain network's signing algorithm to use.

For more information, see the Xellar Sign Message API Documentation (opens in a new tab).