TransactionController Actions
36 actions registered.
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:
| Name | Description |
|---|---|
transactionId | The 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:
| Name | Description |
|---|---|
txParams | Standard parameters for an Ethereum transaction. |
options | Additional 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:
| Name | Description |
|---|---|
request | Request 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:
| Name | Description |
|---|---|
listOfTxParams | The list of transaction params to approve. |
opts | Options bag. |
opts.hasNonce | Whether 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:
| Name | Description |
|---|---|
transactionMeta | TransactionMeta to add transactions. |
transactionReceipt | TransactionReceipt of the external transaction. |
baseFeePerGas | Base 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:
| Name | Description |
|---|---|
transactionId | The transaction ID. |
Handler signature:
(transactionId: string) => void
TransactionController:emulateTransactionUpdate
Package: @metamask/transaction-controller
Emulate a transaction update.
Parameters:
| Name | Description |
|---|---|
transactionMeta | Transaction metadata. |
Handler signature:
(transactionMeta: TransactionMeta) => void
TransactionController:estimateGas
Package: @metamask/transaction-controller
Estimates required gas for a given transaction.
Parameters:
| Name | Description |
|---|---|
transaction | The transaction to estimate gas for. |
networkClientId | The network client id to use for the estimate. |
options | Additional options for the estimate. |
options.ignoreDelegationSignatures | Ignore 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:
| Name | Description |
|---|---|
request | Request object. |
request.chainId | Chain ID of the transactions. |
request.from | Address of the sender. |
request.transactions | Array 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:
| Name | Description |
|---|---|
transaction | The transaction parameters to estimate. |
multiplier | The buffer multiplier, or undefined to resolve it from feature flags. |
networkClientId | The 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:
| Name | Description |
|---|---|
args | The arguments for estimating gas fees. |
args.transactionParams | The transaction parameters to estimate fees for. |
args.chainId | The chain ID to use. If not provided, the network client ID is used to determine the chain. |
args.networkClientId | The 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to mark as failed. |
error | The 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:
| Name | Description |
|---|---|
transactionId | ID of the transaction to finalise. |
transactionHash | On-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:
| Name | Description |
|---|---|
request | The 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:
| Name | Description |
|---|---|
request | The request object. |
request.transactionParams | The transaction parameters to estimate the layer 1 gas fee for. |
request.chainId | The ID of the chain where the transaction will be executed. |
request.networkClientId | The 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:
| Name | Description |
|---|---|
address | The account address for which to acquire the nonce lock. |
networkClientId | The 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:
| Name | Description |
|---|---|
opts | Options bag. |
opts.initialList | The transactions to search. Defaults to the current state. |
opts.limit | The maximum number of transactions to return. No limit by default. |
opts.searchCriteria | An 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:
| Name | Description |
|---|---|
fourBytePrefix | The method prefix. |
networkClientId | The 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:
| Name | Description |
|---|---|
request | Request 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to update. |
isActive | The 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to speed up. |
gasValues | The gas values to use for the speed up transaction. |
options | The options for the speed up transaction. |
options.actionId | Unique ID persisted on transaction metadata. |
options.estimatedBaseFee | The 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to cancel. |
gasValues | The gas values to use for the cancellation transaction. |
options | The options for the cancellation transaction. |
options.actionId | Unique ID persisted on transaction metadata. |
options.estimatedBaseFee | The 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:
| Name | Description |
|---|---|
options | The options bag. |
options.transactionId | ID of the atomic batch transaction. |
options.transactionIndex | Index of the nested transaction within the atomic batch transaction. |
options.transactionData | New 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:
| Name | Description |
|---|---|
request | The request object. |
request.transactionId | The ID of the transaction to update. |
request.batchTransactions | The new batch transactions. |
Handler signature:
({ transactionId, batchTransactions, }: {
transactionId: string;
batchTransactions: BatchTransactionParams[];
}) => void
TransactionController:updateCustodialTransaction
Package: @metamask/transaction-controller
Update a custodial transaction.
Parameters:
| Name | Description |
|---|---|
request | The 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:
| Name | Description |
|---|---|
txId | The ID of the transaction to update. |
params | The editable parameters to update. |
params.containerTypes | Container types applied to the parameters. |
params.data | Data to pass with the transaction. |
params.from | Address to send the transaction from. |
params.gas | Maximum number of units of gas to use for the transaction. |
params.gasPrice | Price per gas for legacy transactions. |
params.maxFeePerGas | Maximum amount per gas to pay for the transaction, including the priority fee. |
params.maxPriorityFeePerGas | Maximum amount per gas to give to validator as incentive. |
params.updateType | Whether to update the transaction type. Defaults to true. |
params.to | Address to send the transaction to. |
params.value | Value 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to update. |
previousGas | Previous gas values to update. |
previousGas.gasLimit | Maximum number of units of gas to use for this transaction. |
previousGas.maxFeePerGas | Maximum amount per gas to pay for the transaction, including the priority fee. |
previousGas.maxPriorityFeePerGas | Maximum 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:
| Name | Description |
|---|---|
request | The request object. |
request.transactionId | The ID of the transaction to update. |
request.requiredTransactionIds | The additional required transaction IDs. |
request.append | Whether 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:
| Name | Description |
|---|---|
transactionId | ID of the transaction. |
securityAlertResponse | The 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to update. |
contractAddress | The 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:
| Name | Description |
|---|---|
transactionMeta | The new transaction to store in state. |
note | A 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:
| Name | Description |
|---|---|
transactionId | The ID of the transaction to update. |
gasValues | Gas values to update. |
gasValues.gas | Same as transaction.gasLimit. |
gasValues.gasLimit | Maxmimum number of units of gas to use for this transaction. |
gasValues.gasPrice | Price per gas for legacy transactions. |
gasValues.maxPriorityFeePerGas | Maximum amount per gas to give to validator as incentive. |
gasValues.maxFeePerGas | Maximum amount per gas to pay for the transaction, including the priority fee. |
gasValues.estimateUsed | Which estimate level was used. |
gasValues.estimateSuggested | Which estimate level that the API suggested. |
gasValues.defaultGasEstimates | The default estimate for gas. |
gasValues.originalGasEstimate | Original estimate for gas. |
gasValues.userEditedGasLimit | The gas limit supplied by user. |
gasValues.userFeeLevel | Estimate 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:
| Name | Description |
|---|---|
options | Update options. |
options.transactionId | ID of the transaction to update. |
options.callback | Function that mutates the transaction metadata. |
options.skipResimulate | Whether 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:
| Name | Description |
|---|---|
options | The options bag. |
options.address | Remove transactions from this account only. Defaults to all accounts. |
options.chainId | Remove transactions for the specified chain only. Defaults to all chains. |
Handler signature:
({ address, chainId, }?: {
address?: string;
chainId?: string;
}) => void