Sign Transaction
This method allows users to sign a raw transaction using their MPC wallet.
Method Signature
async signTransaction(config: SignTransactionConfig): Promise<string>
Parameters
config
: SignTransactionConfig
- An object with the following properties:
network
:Network
(required) - The network used for transactions. You can use theNetwork
enum to specify the network.transaction
:object
(required) - Raw transaction data user wants to sign.from
:string
(required) - The address of the sender.to
:string
(required) - The address of the recipient.value
:string
(optional) - The amount of value to send.data
:string
(optional) - The data to send.nonce
:string
(optional) - The number used once to prevent duplicate transactions (this will be calculated automatically if not provided).gasPrice
:string
(optional) - Gas price in Wei (this will be calculated automatically if not provided).gasLimit
:string
(optional) - Gas limit for single transaction, transaction will be reverted if actual gas consumption is higher than gas limit (this will be calculated automatically if not provided).maxPriorityFeePerGas
:string
(optional) - Maximum priority fee per gas you are willing to pay, this only used in EIP1559 support blockchain.
walletToken
:string
(required) - The wallet token of the wallet to sign the transaction 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 signed transaction hash, and the new wallet token and refresh token if the refresh token is provided.
Example Usage
const signature = await sdk.wallet.signTransaction({
network: Network.ETHEREUM,
transaction: {
from: "0x5B3A69CD0984c8621c75c54aa4dCA89e382523A9",
to: "0x5B3A69CD0984c8621c75c54aa4dCA89e382523A9",
data: "0x",
nonce: "0x00",
gasPrice: "0x1cb3fa334b",
gasLimit: "0x5208",
value: "0x00"
},
walletToken: 'your-wallet-token',
refreshToken: 'your-refresh-token' // Optional
});
console.log(signature);
Response Example
{
"signature": "0xf87184307830308c30783163623366613333346280945b3a69cd0984c8621c75c54aa4dca89e382523a98430783030801ca0bc01b69137a06e64c6f9a02e04b650d4a46cd98d04ae3fee0c1e3fe8d8186d58a02477caf3a20b4a44a16dc3c2c9b7a8edf78db712af0920d769a23d164c242c0f",
"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 signed transaction hash.
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. - Optional transaction parameters (
nonce
,gasPrice
,gasLimit
) will be calculated automatically if not provided. - For EIP1559 supported blockchains, you can provide
maxPriorityFeePerGas
to set the maximum priority fee per gas you are willing to pay.
For more information, see the Xellar Sign Transaction API Documentation (opens in a new tab).