Sign Typed Data
This method allows users to sign typed data using their MPC wallet.
Method Signature
async signTypedData(config: SignTypedDataConfig): Promise<string>
Parameters
config
: SignTypedDataConfig
- An object with the following properties:
network
:Network
(required) - The network used for transactions. You can use theNetwork
enum to specify the network.data
:string
(required) - The raw data you get from dApps or WalletConnect.walletToken
:string
(required) - The wallet token of the wallet to sign the typed data 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 typed data, and the new wallet token and refresh token if the refresh token is provided.
Example Usage
const signature = await sdk.wallet.sign.signTypedData({
network: Network.ETHEREUM,
data: '0x', // Replace with actual typed data
walletToken: 'your-wallet-token',
refreshToken: 'your-refresh-token' // Optional
});
console.log(signature);
Response Example
{
"signature": "0x7e335fd65539e5c6c726be97f93e3e69019d899969d21023d2c6da51622a817d016c2e036a06b734d6de93f01a63e49460d783af8d2eb467d95a487e2028f9751c",
"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 typed data.
Additional Information
- This method requires a valid wallet token in the SDK configuration.
- The
network
parameter is required to determine which blockchain network's signing algorithm to use. - The
data
parameter should contain the raw typed data message you receive from dApps or WalletConnect.
For more information, see the Xellar Sign Typed Data API Documentation (opens in a new tab).