Skip to content

Transaction Dependency Estimation

Previously, we mentioned that a contract call might require you to manually specify external contracts or variable outputs.

However, the SDK always automatically estimates these dependencies and double-checks if everything is in order whenever you invoke a contract function or attempt to send a transaction.

The SDK uses the estimateTxDependencies helper function to set any missing dependencies identified during the estimation process. This requires simulating the transaction a few times in the background.

ts
async sendTransaction(
  transactionRequestLike: TransactionRequestLike,
  { estimateTxDependencies = true }: ProviderSendTxParams = {}
): Promise<TransactionResponse> {
  const transactionRequest = transactionRequestify(transactionRequestLike);
  if (estimateTxDependencies) {
    await this.estimateTxDependencies(transactionRequest);
  }
See code in context

While relying on the SDK's automatic estimation is a decent default behavior, we recommend manually specifying the dependencies if they are known in advance to avoid the performance impact of the estimation process.