Skip to main content

WaaS MPCTransactionService

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.

Transaction States

CreateMPCTransaction is the primary MPCTransactionService API. A typical transaction has 5 states that it goes through in the following order:

  1. CREATED - The request was received by the service.
  2. SIGNING - The MPCTransaction is waiting to be signed. At this point, the WaaS SDK must poll for and process the CREATE_SIGNATURE MPCOperation of 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.
  3. 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.
  4. CONFIRMING - The MPCTransaction was successfully broadcast on-chain and is awaiting confirmation.
  5. CONFIRMED - The MPCTransaction was confirmed on-chain. It is possible for the MPCTransaction to revert to CONFIRMING if 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 CreateMPCTransaction returns Done when the transaction is broadcast on-chain.

Creating MPCTransactions

To create and complete an MPCTransaction:

  1. Follow steps 1-3 from the MPCKeyService guide to create a pool and register your Device with WaaS.

  2. Follow steps 2-3 from the MPCWalletService guide to create an MPCWallet.

  3. 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.

  4. 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.

  5. Use ListMPCOperations to poll for the CreateSignatureGroup operation 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.

  6. Compute the MPC operation in the application using the WaaS SDK.

  7. 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.

Nonce Override

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?