# submitTx

> For the complete documentation index, see [llms.txt](https://docs.midnight.network/llms.txt)

[**Midnight.js API Reference v4.1.0**](https://docs.midnight.network/api-reference/midnight-js.md)

***

[Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages.md) / [@midnight-ntwrk/midnight-js-contracts](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts.md) / submitTx

# Function: submitTx()

> **submitTx**<`C`, `PCK`>(`providers`, `options`): `Promise`<`FinalizedTxData`>

Proves, balances, and submits an unproven deployment or call transaction using the given providers, according to the given options.

## Blocking Behavior[​](#blocking-behavior "Direct link to Blocking Behavior")

This method **waits indefinitely** for the transaction to appear on the blockchain via `providers.publicDataProvider.watchForTxData(txId)`. It will not return until:

* The transaction is successfully included in the blockchain, OR
* An error occurs during proving, balancing, or submission

## Conditions When Transaction May Not Appear[​](#conditions-when-transaction-may-not-appear "Direct link to Conditions When Transaction May Not Appear")

A submitted transaction may fail to appear on-chain if:

* Transaction is invalid in ways not detected during local validation
* Network issues prevent propagation to validators
* Transaction is rejected by validator consensus
* Insufficient fees or resources
* Contract state has changed making the transaction invalid

## Implications of Aborting This Method[​](#implications-of-aborting-this-method "Direct link to Implications of Aborting This Method")

If the application terminates this method before it returns:

* Transaction may still be pending/processing on-chain
* **Private state updates are NOT stored** (even if transaction later succeeds on-chain)
* **Signing keys are NOT updated** (for deploy/replace authority transactions)
* Application state will be out of sync with blockchain state
* Manual recovery may be required to reconcile state

**Recommendation**: Use [submitTxAsync](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitTxAsync.md) for non-blocking submission with manual finalization handling and timeout control.

## Type Parameters[​](#type-parameters "Direct link to Type Parameters")

### C[​](#c "Direct link to C")

`C` *extends* `Any`

### PCK[​](#pck "Direct link to PCK")

`PCK` *extends* `string`

## Parameters[​](#parameters "Direct link to Parameters")

### providers[​](#providers "Direct link to providers")

[`SubmitTxProviders`](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/SubmitTxProviders.md)<`C`, `PCK`>

The providers used to manage the transaction lifecycle.

### options[​](#options "Direct link to options")

[`SubmitTxOptions`](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/SubmitTxOptions.md)<`PCK`>

Configuration.

## Returns[​](#returns "Direct link to Returns")

`Promise`<`FinalizedTxData`>

A promise that resolves with the finalized transaction data for the invocation, or rejects if an error occurs along the way.
