Skip to main content
In this guide we will look at how to sign a transaction using mobile wallet by implementing a generic hook to interact with MWA and create a signer that can be used to work with Kit SDK.

Signing Transactions

I’ll skip most of the details here as we have already covered establishing a MWA session and authorizing it in the previous guides. Here is a snippet of a hook returning a abortable promise for signing transactions. We leverage signTransactions method provided by MWA to sign the multiple transactions in parallel.
services/mwa/useSignTransaction.ts

Creating a TransactionSigner

Now that we have a hook for signing transactions, we can create a TransactionSigner abstraction for it. Again similar to the case of message signer, we have 2 signers here, TransactionPartialSigner and TransactionModifyingSigner. We will implement modifying signer in this guide, but the partial signer can be implemented in a similar way.
mwa/SignTransactionSigner.ts
Everything is similar to our previous implementation of message signer. What is new here is the validation for lifetimeConstraint property on the transactions. This is important because sendAndConfirmTransaction method from Kit SDK for sending transactions requires this property to be set on the signed transaction in order to track its confirmation status. The signed transactions returned from MWA do not have this property set, so we need to merge the signed transaction with the original transaction input to retain this property.
ts/services/mwa/useSignTransaction.ts
Alright! Now we have successfully created a TransactionModifyingSigner that can be used with kit SDK to sign transactions using MWA.