Skip to main content

TransactionController Actions

36 actions registered.

NameDeprecated
abortTransactionSigning
addTransaction
addTransactionBatch
approveTransactionsWithSameNonce
clearUnapprovedTransactions
confirmExternalTransaction
emulateNewTransaction
emulateTransactionUpdate
estimateGas
estimateGasBatch
estimateGasBuffered
estimateGasFee
failTransaction
finalizeResumedTransaction
getGasFeeTokens
getLayer1GasFee
getNonceLock
getState
getTransactions
handleMethodData
isAtomicBatchSupported
setTransactionActive
speedUpTransaction
stopTransaction
updateAtomicBatchData
updateBatchTransactions
updateCustodialTransaction
updateEditableParams
updatePreviousGasParams
updateRequiredTransactionIds
updateSecurityAlertResponse
updateSelectedGasFeeToken
updateTransaction
updateTransactionGasFees
updateTransactionMetadata
wipeTransactions

TransactionController:abortTransactionSigning​

Package: @metamask/transaction-controller

Stop the signing process for a specific transaction. Throws an error causing the transaction status to be set to failed.

Parameters:

NameDescription
transactionIdThe ID of the transaction to stop signing.

Handler signature:

(transactionId: string) => void

TransactionController:addTransaction​

Package: @metamask/transaction-controller

Add a new unapproved transaction to state. Parameters will be validated, a unique transaction ID will be generated, and gas and gasPrice will be calculated if not provided. A <tx.id>:unapproved hub event will be emitted once added.

Parameters:

NameDescription
txParamsStandard parameters for an Ethereum transaction.
optionsAdditional options to control how the transaction is added.

Returns: Object containing a promise resolving to the transaction hash if approved.

Handler signature:

(txParams: TransactionParams, options: AddTransactionOptions) => Promise<Result>

TransactionController:addTransactionBatch​

Package: @metamask/transaction-controller

Add a batch of transactions to be submitted after approval.

Parameters:

NameDescription
requestRequest object containing the transactions to add.

Returns: Result object containing the generated batch ID.

Handler signature:

(request: TransactionBatchRequest) => Promise<TransactionBatchResult>

TransactionController:approveTransactionsWithSameNonce​

Package: @metamask/transaction-controller

Signs and returns the raw transaction data for provided transaction params list.

Parameters:

NameDescription
listOfTxParamsThe list of transaction params to approve.
optsOptions bag.
opts.hasNonceWhether the transactions already have a nonce.

Returns: The raw transactions.

Handler signature:

(listOfTxParams?: (TransactionParams & {
chainId: Hex;
})[], { hasNonce }?: {
hasNonce?: boolean;
}) => Promise<string | string[]>

TransactionController:clearUnapprovedTransactions​

Package: @metamask/transaction-controller

Removes unapproved transactions from state.

Handler signature:

() => void

TransactionController:confirmExternalTransaction​

Package: @metamask/transaction-controller

Adds external provided transaction to state as confirmed transaction.

Parameters:

NameDescription
transactionMetaTransactionMeta to add transactions.
transactionReceiptTransactionReceipt of the external transaction.
baseFeePerGasBase fee per gas of the external transaction.

Handler signature:

(transactionMeta: TransactionMeta, transactionReceipt: TransactionReceipt, baseFeePerGas: Hex) => Promise<void>

TransactionController:emulateNewTransaction​

Package: @metamask/transaction-controller

Emulate a new transaction.

Parameters:

NameDescription
transactionIdThe transaction ID.

Handler signature:

(transactionId: string) => void

TransactionController:emulateTransactionUpdate​

Package: @metamask/transaction-controller

Emulate a transaction update.

Parameters:

NameDescription
transactionMetaTransaction metadata.

Handler signature:

(transactionMeta: TransactionMeta) => void

TransactionController:estimateGas​

Package: @metamask/transaction-controller

Estimates required gas for a given transaction.

Parameters:

NameDescription
transactionThe transaction to estimate gas for.
networkClientIdThe network client id to use for the estimate.
optionsAdditional options for the estimate.
options.ignoreDelegationSignaturesIgnore signature errors if submitting delegations to the DelegationManager.

Returns: The gas and gas price.

Handler signature:

(transaction: TransactionParams, networkClientId: NetworkClientId, { ignoreDelegationSignatures, }?: {
ignoreDelegationSignatures?: boolean;
}) => Promise<{
gas: string;
simulationFails: TransactionMeta['simulationFails'];
}>

TransactionController:estimateGasBatch​

Package: @metamask/transaction-controller

Estimates required gas for a batch of transactions.

Parameters:

NameDescription
requestRequest object.
request.chainIdChain ID of the transactions.
request.fromAddress of the sender.
request.transactionsArray of transactions within a batch request.

Returns: Object containing the gas limit.

Handler signature:

({ chainId, from, transactions, }: {
chainId: Hex;
from: Hex;
transactions: BatchTransactionParams[];
}) => Promise<EstimateGasBatchResult>

TransactionController:estimateGasBuffered​

Package: @metamask/transaction-controller

Estimates gas for a transaction and applies a buffer.

If multiplier is undefined, the buffer is resolved from the confirmations_gas_buffer feature flags for the network and transaction shape, as in the controller's own gas estimation.

simulationFails does not disable the buffer, unlike the controller's own gas estimation. When estimation fails, estimatedGas is the fallback (a fixed value or a percentage of the block gas limit, capped by the chain's maxGasLimit); buffering it keeps callers that size amounts from the estimate conservative.

Parameters:

NameDescription
transactionThe transaction parameters to estimate.
multiplierThe buffer multiplier, or undefined to resolve it from feature flags.
networkClientIdThe network client to estimate on.

Returns: The gas estimate after buffering, and the simulation failure if the estimate failed.

Handler signature:

(transaction: TransactionParams, multiplier: number | undefined, networkClientId: NetworkClientId) => Promise<{
gas: string;
simulationFails: TransactionMeta['simulationFails'];
}>

TransactionController:estimateGasFee​

Package: @metamask/transaction-controller

Estimates the gas fees for a transaction.

Parameters:

NameDescription
argsThe arguments for estimating gas fees.
args.transactionParamsThe transaction parameters to estimate fees for.
args.chainIdThe chain ID to use. If not provided, the network client ID is used to determine the chain.
args.networkClientIdThe network client ID to use for the estimation.

Returns: A promise that resolves to the estimated gas fee response.

Handler signature:

({ transactionParams, chainId, networkClientId: requestNetworkClientId, }: {
transactionParams: TransactionParams;
chainId?: Hex;
networkClientId?: NetworkClientId;
}) => Promise<GasFeeFlowResponse>

TransactionController:failTransaction​

Package: @metamask/transaction-controller

Mark a transaction as failed, transitioning it through the standard failure path.

Unlike updateTransaction, this emits the transaction lifecycle events (transactionFailed, transactionStatusUpdated, transactionFinished), so downstream subscribers such as the bridge status controller and metrics are notified. Intended for callers that finalize a transaction out-of-band, for example the smart transactions controller when the relay cancels a smart transaction that never landed on chain.

Parameters:

NameDescription
transactionIdThe ID of the transaction to mark as failed.
errorThe error describing why the transaction failed.

Handler signature:

(transactionId: string, error: Error) => void

TransactionController:finalizeResumedTransaction​

Package: @metamask/transaction-controller

Marks a pending resumed transaction as submitted, using the same event path as a normal publish. Only valid when the transaction is in approved or signed status; throws otherwise.

Parameters:

NameDescription
transactionIdID of the transaction to finalise.
transactionHashOn-chain hash returned by the resuming controller.

Handler signature:

(transactionId: string, transactionHash: string) => void

TransactionController:getGasFeeTokens​

Package: @metamask/transaction-controller

Retrieve available gas fee tokens for a transaction.

Parameters:

NameDescription
requestThe request object containing transaction details.

Returns: The list of available gas fee tokens.

Handler signature:

(request: GetGasFeeTokensRequest) => Promise<GasFeeToken[]>

TransactionController:getLayer1GasFee​

Package: @metamask/transaction-controller

Determine the layer 1 gas fee for the given transaction parameters.

Parameters:

NameDescription
requestThe request object.
request.transactionParamsThe transaction parameters to estimate the layer 1 gas fee for.
request.chainIdThe ID of the chain where the transaction will be executed.
request.networkClientIdThe ID of a specific network client to process the transaction.

Returns: The layer 1 gas fee.

Handler signature:

({ transactionParams, chainId, networkClientId, }: {
transactionParams: TransactionParams;
chainId?: Hex;
networkClientId?: NetworkClientId;
}) => Promise<Hex | undefined>

TransactionController:getNonceLock​

Package: @metamask/transaction-controller

Acquires a nonce lock for the given address on the specified network, ensuring that nonces are assigned sequentially without conflicts.

Parameters:

NameDescription
addressThe account address for which to acquire the nonce lock.
networkClientIdThe ID of the network client to use.

Returns: A promise that resolves to a nonce lock containing the next nonce and a release function.

Handler signature:

(address: string, networkClientId: NetworkClientId) => Promise<NonceLock>

TransactionController:getState​

Package: @metamask/transaction-controller

Represents the TransactionController:getState action.

Handler signature:

() => TransactionControllerState

TransactionController:getTransactions​

Package: @metamask/transaction-controller

Search transaction metadata for matching entries.

Parameters:

NameDescription
optsOptions bag.
opts.initialListThe transactions to search. Defaults to the current state.
opts.limitThe maximum number of transactions to return. No limit by default.
opts.searchCriteriaAn object containing values or functions for transaction properties to filter transactions with.

Returns: An array of transactions matching the provided options.

Handler signature:

({ initialList, limit, searchCriteria, }?: {
initialList?: TransactionMeta[];
limit?: number;
searchCriteria?: any;
}) => TransactionMeta[]

TransactionController:handleMethodData​

Package: @metamask/transaction-controller

Handle new method data request.

Parameters:

NameDescription
fourBytePrefixThe method prefix.
networkClientIdThe ID of the network client used to fetch the method data.

Returns: The method data object corresponding to the given signature prefix.

Handler signature:

(fourBytePrefix: string, networkClientId: NetworkClientId) => Promise<MethodData>

TransactionController:isAtomicBatchSupported​

Package: @metamask/transaction-controller

Determine which chains support atomic batch transactions with the given account address.

Parameters:

NameDescription
requestRequest object containing the account address and other parameters.

Returns: Result object containing the supported chains and related information.

Handler signature:

(request: IsAtomicBatchSupportedRequest) => Promise<IsAtomicBatchSupportedResult>

TransactionController:setTransactionActive​

Package: @metamask/transaction-controller

Update the isActive state of a transaction.

Parameters:

NameDescription
transactionIdThe ID of the transaction to update.
isActiveThe active state.

Handler signature:

(transactionId: string, isActive: boolean) => void

TransactionController:speedUpTransaction​

Package: @metamask/transaction-controller

Attempts to speed up a transaction increasing transaction gasPrice by ten percent.

Parameters:

NameDescription
transactionIdThe ID of the transaction to speed up.
gasValuesThe gas values to use for the speed up transaction.
optionsThe options for the speed up transaction.
options.actionIdUnique ID persisted on transaction metadata.
options.estimatedBaseFeeThe estimated base fee of the transaction.

Handler signature:

(transactionId: string, gasValues?: GasPriceValue | FeeMarketEIP1559Values, { actionId, estimatedBaseFee, }?: {
actionId?: string;
estimatedBaseFee?: string;
}) => Promise<void>

TransactionController:stopTransaction​

Package: @metamask/transaction-controller

Attempts to cancel a transaction based on its ID by setting its status to "rejected" and emitting a <tx.id>:finished hub event.

Parameters:

NameDescription
transactionIdThe ID of the transaction to cancel.
gasValuesThe gas values to use for the cancellation transaction.
optionsThe options for the cancellation transaction.
options.actionIdUnique ID persisted on transaction metadata.
options.estimatedBaseFeeThe estimated base fee of the transaction.

Handler signature:

(transactionId: string, gasValues?: GasPriceValue | FeeMarketEIP1559Values, { estimatedBaseFee, actionId, }?: {
estimatedBaseFee?: string;
actionId?: string;
}) => Promise<void>

TransactionController:updateAtomicBatchData​

Package: @metamask/transaction-controller

Update the transaction data of a single nested transaction within an atomic batch transaction.

Parameters:

NameDescription
optionsThe options bag.
options.transactionIdID of the atomic batch transaction.
options.transactionIndexIndex of the nested transaction within the atomic batch transaction.
options.transactionDataNew data to set for the nested transaction.

Returns: The updated data for the atomic batch transaction.

Handler signature:

({ transactionId, transactionIndex, transactionData, }: {
transactionId: string;
transactionIndex: number;
transactionData: Hex;
}) => Promise<Hex>

TransactionController:updateBatchTransactions​

Package: @metamask/transaction-controller

Update the batch transactions associated with a transaction. These transactions will be submitted with the main transaction as a batch.

Parameters:

NameDescription
requestThe request object.
request.transactionIdThe ID of the transaction to update.
request.batchTransactionsThe new batch transactions.

Handler signature:

({ transactionId, batchTransactions, }: {
transactionId: string;
batchTransactions: BatchTransactionParams[];
}) => void

TransactionController:updateCustodialTransaction​

Package: @metamask/transaction-controller

Update a custodial transaction.

Parameters:

NameDescription
requestThe custodial transaction update request.

Returns: The updated transaction metadata.

Handler signature:

(request: UpdateCustodialTransactionRequest) => TransactionMeta

TransactionController:updateEditableParams​

Package: @metamask/transaction-controller

Updates the editable parameters of a transaction.

Parameters:

NameDescription
txIdThe ID of the transaction to update.
paramsThe editable parameters to update.
params.containerTypesContainer types applied to the parameters.
params.dataData to pass with the transaction.
params.fromAddress to send the transaction from.
params.gasMaximum number of units of gas to use for the transaction.
params.gasPricePrice per gas for legacy transactions.
params.maxFeePerGasMaximum amount per gas to pay for the transaction, including the priority fee.
params.maxPriorityFeePerGasMaximum amount per gas to give to validator as incentive.
params.updateTypeWhether to update the transaction type. Defaults to true.
params.toAddress to send the transaction to.
params.valueValue associated with the transaction.

Returns: The updated transaction metadata.

Handler signature:

(txId: string, { containerTypes, data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, updateType, value, }: {
containerTypes?: TransactionContainerType[];
data?: string;
from?: string;
gas?: string;
gasPrice?: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
to?: string;
updateType?: boolean;
value?: string;
}) => Promise<Readonly<TransactionMeta> | undefined>

TransactionController:updatePreviousGasParams​

Package: @metamask/transaction-controller

Update the previous gas values of a transaction.

Parameters:

NameDescription
transactionIdThe ID of the transaction to update.
previousGasPrevious gas values to update.
previousGas.gasLimitMaximum number of units of gas to use for this transaction.
previousGas.maxFeePerGasMaximum amount per gas to pay for the transaction, including the priority fee.
previousGas.maxPriorityFeePerGasMaximum amount per gas to give to validator as incentive.

Returns: The updated transactionMeta.

Handler signature:

(transactionId: string, { gasLimit, maxFeePerGas, maxPriorityFeePerGas, }: {
gasLimit?: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
}) => TransactionMeta

TransactionController:updateRequiredTransactionIds​

Package: @metamask/transaction-controller

Update the required transaction IDs for a transaction.

Parameters:

NameDescription
requestThe request object.
request.transactionIdThe ID of the transaction to update.
request.requiredTransactionIdsThe additional required transaction IDs.
request.appendWhether to append the IDs to any existing values. Defaults to true.

Handler signature:

({ transactionId, requiredTransactionIds, append, }: {
transactionId: string;
requiredTransactionIds: string[];
append?: boolean;
}) => void

TransactionController:updateSecurityAlertResponse​

Package: @metamask/transaction-controller

Update the security alert response for a transaction.

Parameters:

NameDescription
transactionIdID of the transaction.
securityAlertResponseThe new security alert response for the transaction.

Handler signature:

(transactionId: string, securityAlertResponse: SecurityAlertResponse) => void

TransactionController:updateSelectedGasFeeToken​

Package: @metamask/transaction-controller

Update the selected gas fee token for a transaction.

Parameters:

NameDescription
transactionIdThe ID of the transaction to update.
contractAddressThe contract address of the selected gas fee token.

Handler signature:

(transactionId: string, contractAddress: Hex | undefined) => void

TransactionController:updateTransaction​

Package: @metamask/transaction-controller

Updates an existing transaction in state.

Parameters:

NameDescription
transactionMetaThe new transaction to store in state.
noteA note or update reason to be logged.

Handler signature:

(transactionMeta: TransactionMeta, note: string) => void

TransactionController:updateTransactionGasFees​

Package: @metamask/transaction-controller

Update the gas values of a transaction.

Parameters:

NameDescription
transactionIdThe ID of the transaction to update.
gasValuesGas values to update.
gasValues.gasSame as transaction.gasLimit.
gasValues.gasLimitMaxmimum number of units of gas to use for this transaction.
gasValues.gasPricePrice per gas for legacy transactions.
gasValues.maxPriorityFeePerGasMaximum amount per gas to give to validator as incentive.
gasValues.maxFeePerGasMaximum amount per gas to pay for the transaction, including the priority fee.
gasValues.estimateUsedWhich estimate level was used.
gasValues.estimateSuggestedWhich estimate level that the API suggested.
gasValues.defaultGasEstimatesThe default estimate for gas.
gasValues.originalGasEstimateOriginal estimate for gas.
gasValues.userEditedGasLimitThe gas limit supplied by user.
gasValues.userFeeLevelEstimate level user selected.

Returns: The updated transactionMeta.

Handler signature:

(transactionId: string, { defaultGasEstimates, estimateUsed, estimateSuggested, gas, gasLimit, gasPrice, maxPriorityFeePerGas, maxFeePerGas, originalGasEstimate, userEditedGasLimit, userFeeLevel: userFeeLevelParam, }: {
defaultGasEstimates?: string;
estimateUsed?: string;
estimateSuggested?: string;
gas?: string;
gasLimit?: string;
gasPrice?: string;
maxPriorityFeePerGas?: string;
maxFeePerGas?: string;
originalGasEstimate?: string;
userEditedGasLimit?: boolean;
userFeeLevel?: string;
}) => TransactionMeta

TransactionController:updateTransactionMetadata​

Package: @metamask/transaction-controller

Updates transaction metadata.

Parameters:

NameDescription
optionsUpdate options.
options.transactionIdID of the transaction to update.
options.callbackFunction that mutates the transaction metadata.
options.skipResimulateWhether to skip automatic re-simulation.

Returns: The updated transaction metadata.

Handler signature:

({ transactionId, callback, skipResimulate, }: {
transactionId: string;
callback: (transactionMeta: TransactionMeta) => void;
skipResimulate?: boolean;
}) => Readonly<TransactionMeta>

TransactionController:wipeTransactions​

Package: @metamask/transaction-controller

Remove transactions from state.

Parameters:

NameDescription
optionsThe options bag.
options.addressRemove transactions from this account only. Defaults to all accounts.
options.chainIdRemove transactions for the specified chain only. Defaults to all chains.

Handler signature:

({ address, chainId, }?: {
address?: string;
chainId?: string;
}) => void