Estimate Transaction Fee (Quote)
Get an estimate of the fee required to relay a transaction before submitting it across multiple blockchain networks.
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 { 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);Aptos
import { Tachyon, ChainId } from '@rathfi/tachyon';
// Initialize the SDK
const tachyon = new Tachyon({
apiKey: 'YOUR_API_KEY',
});
// Get a quote for an Aptos transaction
const quote = await tachyon.getQuote({
chainId: 88888888, // Aptos chain ID
to: '0x09ebf332aa3e4edad203aff521bd8a47597119de1956885711223ec157eac219',
value: '1',
callData: '0x',
gasLimit: '100', // Required for Aptos
label: 'My Aptos Transaction',
});
console.log('Estimated cost (USD):', quote.costUSD);
console.log('Minimum balance required:', quote.minBalanceRequired);Solana
import { Tachyon, ChainId } from '@rathfi/tachyon';
// Initialize the SDK
const tachyon = new Tachyon({
apiKey: 'YOUR_API_KEY',
});
// Get a quote for a Solana transaction
const quote = await tachyon.getQuote({
chainId: 10100000, // Solana chain ID
to: 'BSNsLtDDM1wN8rjEJQaZreVqRhibsUtsEq9m1G2deAm',
value: '1', // 1 lamport
callData: '0x',
label: 'My Solana Transaction',
});
console.log('Estimated cost (USD):', quote.costUSD);
console.log('Minimum balance required:', quote.minBalanceRequired);Sui
import { Tachyon, ChainId } from '@rathfi/tachyon';
// Initialize the SDK
const tachyon = new Tachyon({
apiKey: 'YOUR_API_KEY',
});
// Get a quote for a Sui transaction
const quote = await tachyon.getQuote({
chainId: 897796746, // Sui chain ID
to: '0xf78da4499004aa2d594143d69a7804f6f989ab8152de59d3726def827c9fe1f0',
value: '100000000', // 0.1 SUI in MIST (1 SUI = 10^9 MIST)
callData: '0x',
gasLimit: '3000000', // Gas limit for Sui
label: 'send-native-sui',
});
console.log('Estimated cost (USD):', quote.costUSD);
console.log('Minimum balance required:', quote.minBalanceRequired);NEAR
import { Tachyon, ChainId } from '@rathfi/tachyon';
// Initialize the SDK
const tachyon = new Tachyon({
apiKey: 'YOUR_API_KEY',
});
// Get a quote for a NEAR transaction
const quote = await tachyon.getQuote({
chainId: 7777777, // NEAR chain ID
to: 'deeprice6887.near',
value: '1', // 1 yoctoNEAR
callData: '0x',
label: 'My NEAR Transaction',
});
console.log('Estimated cost (USD):', quote.costUSD);
console.log('Minimum balance required:', quote.minBalanceRequired);Starknet
import { Tachyon, ChainId } from '@rathfi/tachyon';
// Initialize the SDK
const tachyon = new Tachyon({
apiKey: 'YOUR_API_KEY',
});
// Get a quote for the Starknet transaction
const quote = await tachyon.getQuote({
to: "0x021Af6FEc4753c4C7C248Dc68d1B43ed721f0246e9dC8A9e5b7d74Ff3373764B",
callData: "0x",
value: "1",
chainId: 23448594291968334,
label: "send strk",
retries: 0
});
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:
| Name | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | The blockchain network ID where the transaction will be executed. Must be a supported chain. |
to | string | Yes | The 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. |
callData | string | Yes | Encoded transaction data in hexadecimal format (use '0x' for simple transfers). |
value | string | No (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. |
label | string | No | Human-readable label for easier transaction identification and tracking. |
gasLimit | string | No | Gas limit for the transaction. If not specified, it will be estimated automatically. Required for Aptos transactions. |
gasPrice | string | No | Gas price for legacy transactions. Cannot be used with maxFeePerGas or maxPriorityFeePerGas. |
maxFeePerGas | string | No | Maximum fee per gas for EIP-1559 transactions. Must be provided together with maxPriorityFeePerGas. |
maxPriorityFeePerGas | string | No | Maximum priority fee per gas for EIP-1559 transactions. Must be provided together with maxFeePerGas. |
maxUSD | number | No | Maximum USD cost limit for the transaction. Quote will reflect if estimated cost exceeds this value. |
retries | number | No (default: 0) | Number of retry attempts for failed transactions. |
shouldBatchInMulticall | boolean | No | Whether to batch this transaction in a multicall for gas optimization. |
isAuthenticatedTx | boolean | No (default: false) | Enable authenticated relay mode for additional security and verification. |
derivationPath | string | No | HD 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). |
authorizationList | AuthorizationListItem[] | No | List of authorization entries for delegated transactions or batched operations. Not allowed for "flash-blocks" transactions. |
Important Constraints
- Gas Parameters:
gasPricecannot be used together withmaxFeePerGasormaxPriorityFeePerGas - EIP-1559 Fees: Both
maxFeePerGasandmaxPriorityFeePerGasmust 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:
authorizationListcannot be used with"flash-blocks"transaction type - Address Validation: The
toaddress must be valid for the specifiedchainId
Response
Returns: Promise<QuoteResponse>
The QuoteResponse object contains:
| Property | Type | Description |
|---|---|---|
costUSD | number | Estimated transaction cost in USD. |
minBalanceRequired | string | Minimum balance required in the smallest unit (wei for EVM, lamports for Solana, yoctoNEAR for NEAR, MIST for Sui) to execute the transaction. |
Example Output
{
"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.