MPCTransactionService APIs are used for transaction orchestration. The lifecycle of an MPC-signed transaction on the blockchain is complex, and MPCTransactionService conveniently abstracts these details.
CreateMPCTransaction is the primary MPCTransactionService API. A typical transaction has 5 states that it goes through in the following order:
CREATED- The request was received by the service.
SIGNING- The MPCTransaction is waiting to be signed. At this point, the WaaS SDK must poll for and process the
CREATE_SIGNATURE MPCOperationof the DeviceGroup associated with the underlying Address. For any given Address, only one MPCTransaction can be in the SIGNING state at a given time - i.e., an MPCTransaction must be successfully signed before the next one can be signed.
SIGNED- The MPCTransaction was signed and is waiting to be broadcast on-chain. MPCTransactions are broadcast on a periodic schedule proportional to the block production speed of the Network.
CONFIRMING- The MPCTransaction was successfully broadcast on-chain and is awaiting confirmation.
CONFIRMED- The MPCTransaction was confirmed on-chain. It is possible for the MPCTransaction to revert to
CONFIRMINGif there is an on-chain reorganization.
Because of the concurrent nature of MPC-based signing, MPCTransactionService handles nonce management. Unless the
override_nonce bit is set to true, the nonce in the provided
TransactionInput is ignored and MPCTransactionService determines the next nonce to sign.
The long-running operation returned from
Done when the transaction is broadcast on-chain.
To create and complete an MPCTransaction:
Follow steps 1-3 from the MPCKeyService guide to create a pool and register your Device with WaaS.
Follow steps 2-3 from the MPCWalletService guide to create an MPCWallet.
Generate an Address within MPCWallet.caution
Ensure your Address is funded with enough of the native gas token, so that outgoing transaction fees can be paid.
Create an MPCTransaction by calling CreateMPCTransaction. Unde the hood, this constructs the transaction and calls CreateSignature on MPCKeyService. You can invoke the API from a server using our client libraries.
Use ListMPCOperations to poll for the
CreateSignatureGroupoperation with the DeviceGroup as parent. Invoke the API from the application using the WaaS SDK.info
There can be a delay between when an MPC operation is created and when it materializes in polling via ListMPCOperations.
Compute the MPC operation in the application using the WaaS SDK.
Wait for the transaction to be broadcast on-chain. Signed transactions are broadcast on a regular periodic schedule proportional to the block production speed of the Network.info
A typical MPC transaction takes ~30 seconds end-to-end to be broadcast on-chain, from the time the CreateMPCTransaction request is received.
In the normal course of the service, the MPCTransactionService handles nonce assignment to transactions, keeping track of the next nonce to sign. The
override_nonce option is provided for the scenario in which transactions get stuck in the mempool due to too low of a specified gas price. When
override_nonce is set to true, the nonce in the TransactionInput is respected. Specifying this also has the effect of canceling any subsequent transaction that has not yet been broadcast on-chain.
Was this helpful?