Vana SDK - v2.2.2
    Preparing search index...

    Interface GasEstimate

    Gas estimate information for transaction cost prediction.

    Provides detailed gas pricing estimates to help users understand transaction costs before execution. Supports both legacy (gasPrice) and EIP-1559 (maxFeePerGas) pricing models. The estimatedCost is calculated based on current network conditions and may vary by the time of actual execution.

    // Get gas estimate before transaction
    const estimate: GasEstimate = await vana.permissions.estimateGas({
    grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
    dataId: 123
    });

    // Convert to human-readable format
    const costInEth = Number(estimate.estimatedCost) / 1e18;
    console.log(`Estimated cost: ${costInEth.toFixed(6)} ETH`);

    // Check if user has sufficient balance
    const balance = await vana.protocol.getBalance(userAddress);
    if (balance < estimate.estimatedCost) {
    throw new Error(`Insufficient balance. Need ${costInEth} ETH`);
    }

    // Use estimate for transaction with buffer
    await vana.permissions.grant(params, {
    gasLimit: estimate.gasLimit * 110n / 100n, // 10% buffer
    maxFeePerGas: estimate.maxFeePerGas,
    maxPriorityFeePerGas: estimate.maxPriorityFeePerGas
    });
    interface GasEstimate {
        gasLimit: bigint;
        gasPrice: bigint;
        maxFeePerGas?: bigint;
        maxPriorityFeePerGas?: bigint;
        estimatedCost: bigint;
    }
    Index

    Properties

    gasLimit: bigint

    Gas limit

    gasPrice: bigint

    Gas price

    maxFeePerGas?: bigint

    Max fee per gas

    maxPriorityFeePerGas?: bigint

    Max priority fee per gas

    estimatedCost: bigint

    Estimated cost in wei