Transactions

Estimate a transaction's gas cost.

Changed on

Estimates the gas cost of a transaction without sending it.

With a fee sponsorship that charges the user in an ERC-20 token, feeInToken is the estimated amount of that token.

post/v2/transactions/estimate

Request

  • Base URL: https://api.openfort.io
  • URL: https://api.openfort.io/v2/transactions/estimate
  • Auth: one of:
    • HTTP bearer
    • HTTP bearer
    • HTTP bearer
    • HTTP bearer

Request body

chainIdinteger required

The chain ID. Must be a supported chain.

accountIdstring required

ID of the account that executes the transaction (starts with acc_).

feeSponsorshipIdstring

ID of the fee sponsorship that pays for gas (starts with pol_). Omit to pay gas from the account's native token balance.

feeSponsorshipTokenstring

For a fee sponsorship that accepts several user-pay ERC-20 tokens, the on-chain address of the token the user pays the fee in. Must be one of the sponsorship's configured tokens on this chain.

waitForReceiptboolean

Whether to hold the request until the transaction is mined and the receipt is available (default true). Set to false to respond as soon as the transaction is broadcast (status: "submitted") and poll GET /v2/transactions/{id} for the outcome.

authorizationstring

EIP-7702 signed authorization (hex) for a delegated account that is not yet delegated on-chain.

Example request

{
  "chainId": 80002,
  "accountId": "acc_e1b24353-1741-4a3d-9e91-2b0fd2942f60",
  "feeSponsorshipId": "pol_7e07ae30-2a4d-48fa-803f-361da94905dd",
  "feeSponsorshipToken": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
  "calls": [
    {
      "to": "0x3994801f2BF191D22aA60c2ce3728c4D0e856a7B",
      "value": "1000000000000000000",
      "contractId": "con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35",
      "functionName": "mint"
    }
  ],
  "authorization": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1c"
}

Response

Successful response.

gasstring required

Estimated gas.

gasPricestring required

Gas price used for the estimation (wei).

feestring required

Estimated fee in the chain's native token (wei).

feeUsdstring required

Estimated fee in USD.

feeInTokenstring

Estimated fee in the sponsorship's ERC-20 token (token base units). Present for token-paying sponsorships.

Example response

{
  "gas": "210000",
  "gasPrice": "1000000000",
  "fee": "210000000000000",
  "feeUsd": "0.42"
}

Changes

    • breaking

      the / request property type changed from no type to object

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • breaking

      added the new required request property

    • warning

      removed the request property

    • warning

      removed the request property

    • info

      added the new optional request property