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 leveragesignTransactions 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 aTransactionSigner 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
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
TransactionModifyingSigner that can be used with kit SDK to sign transactions using MWA.