Skip to Content
TachyonSDK ReferenceEstimate Relay Tx Fee

Get Transaction Quote

Before submitting a transaction, you can request a quote to estimate the cost in USD and the minimum balance required. This helps you understand the transaction cost upfront and ensure your account has sufficient balance.

Quick Start

EVM Chains (Ethereum, Base, Polygon, etc.)

import-sdk.js
import { Tachyon, ChainId } from '@rathfi/tachyon'; // Initialize the SDK const tachyon = new Tachyon({ apiKey: 'YOUR_API_KEY', }); // Get a quote for a Base transaction const quote = await tachyon.getQuote({ chainId: ChainId.BASE, // 8453 to: '0x3dbE34f2C21b3B2980d4dc53f3c7E51e39663F49', value: '1', // 1 wei callData: '0x', label: 'My Base Transaction', }); console.log('Estimated cost (USD):', quote.costUSD); console.log('Minimum balance required:', quote.minBalanceRequired);

Methods

getQuote(params)

Retrieves an estimated quote for relaying a transaction, including the cost in USD and minimum balance required. This allows you to inform users of costs before they commit to a transaction.

Parameters

The getQuote() method accepts a RelayParams object with the following properties:

NameTypeRequiredDescription
chainIdnumberYesThe blockchain network ID where the transaction will be executed. Must be a supported chain.
tostringYesThe recipient wallet address or smart contract address. Format varies by chain (hex for EVM, base58 for Solana, named for NEAR). Must be a valid address for the specified chain.
callDatastringYesEncoded transaction data in hexadecimal format (use ‘0x’ for simple transfers).
valuestringNo (default: '0')Amount of native currency to send in the smallest unit (wei for EVM, lamports for Solana, yoctoNEAR for NEAR, MIST for Sui). Use ‘0’ for contract calls with no value transfer.
labelstringNoHuman-readable label for easier transaction identification and tracking.
gasLimitstringNoGas limit for the transaction. If not specified, it will be estimated automatically. Required for Aptos transactions.
gasPricestringNoGas price for legacy transactions. Cannot be used with maxFeePerGas or maxPriorityFeePerGas.
maxFeePerGasstringNoMaximum fee per gas for EIP-1559 transactions. Must be provided together with maxPriorityFeePerGas.
maxPriorityFeePerGasstringNoMaximum priority fee per gas for EIP-1559 transactions. Must be provided together with maxFeePerGas.
maxUSDnumberNoMaximum USD cost limit for the transaction. Quote will reflect if estimated cost exceeds this value.
retriesnumberNo (default: 0)Number of retry attempts for failed transactions.
shouldBatchInMulticallbooleanNoWhether to batch this transaction in a multicall for gas optimization.
isAuthenticatedTxbooleanNo (default: false)Enable authenticated relay mode for additional security and verification.
derivationPathstringNoHD wallet derivation path for transaction signing (useful for multi-account setups).
transactionType"flash" | "authenticated" | "funding-signed" | "flash-blocks"No (default: "flash")Type of relay transaction. "flash-blocks" is only supported on Base (8453) and Base Sepolia (84532).
authorizationListAuthorizationListItem[]NoList of authorization entries for delegated transactions or batched operations. Not allowed for "flash-blocks" transactions.

Important Constraints

  • Gas Parameters: gasPrice cannot be used together with maxFeePerGas or maxPriorityFeePerGas
  • EIP-1559 Fees: Both maxFeePerGas and maxPriorityFeePerGas must be provided together if either is specified
  • Flash-blocks Support: transactionType: "flash-blocks" is only supported on Base (8453) and Base Sepolia (84532)
  • Authorization List: authorizationList cannot be used with "flash-blocks" transaction type
  • Address Validation: The to address must be valid for the specified chainId

Response

Returns: Promise<QuoteResponse>

The QuoteResponse object contains:

PropertyTypeDescription
costUSDnumberEstimated transaction cost in USD.
minBalanceRequiredstringMinimum balance required in the smallest unit (wei for EVM, lamports for Solana, yoctoNEAR for NEAR, MIST for Sui) to execute the transaction.

Example Output

quote-response.json
{ "costUSD": 0.0009221670934825817, "minBalanceRequired": "223171904787" }

Response Details:

  • costUSD: The estimated cost to relay the transaction, denominated in US dollars. This includes gas fees and relay service charges.
  • minBalanceRequired: The minimum balance that must be available in your account to successfully execute this transaction. The unit varies by chain:
    • EVM chains: Wei (1 ETH = 10^18 wei)
    • Solana: Lamports (1 SOL = 10^9 lamports)
    • NEAR: yoctoNEAR (1 NEAR = 10^24 yoctoNEAR)
    • Aptos: Octas (1 APT = 10^8 octas)
    • Sui: MIST (1 SUI = 10^9 MIST)

Use Cases

  • Pre-transaction validation: Check if users have sufficient balance before attempting a transaction.
  • Cost transparency: Display estimated costs to users in your application UI.
  • Budget planning: Help users understand the financial impact of their transactions.
  • Multi-chain comparison: Compare costs across different blockchain networks for the same operation.
Last updated on