App Development
GOAT Network uses an EIP-1559-style fee model with BTC-denominated gas costs. Estimate fees by combining gas usage with live base fee and priority fee data.
Component Meaning Gas limit Estimated execution cost for the transaction Base fee Dynamic network fee from the latest block Priority fee Optional tip to encourage faster inclusion Max fee per gas The cap your wallet or script is willing to pay
Estimate gas usage
|
v
Read live fee data
|
v
Set maxPriorityFeePerGas
|
v
Compute maxFeePerGas
|
v
Send transaction with final limits
ethers.js v6 web3.js
import { JsonRpcProvider, parseUnits } from 'ethers' ;
const provider = new JsonRpcProvider ( 'https://rpc.testnet3.goat.network' );
const feeData = await provider. getFeeData ();
const gas = await provider. estimateGas ({
from: senderAddress,
to: tokenAddress,
data: transferCalldata,
});
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? parseUnits ( '0.00013' , 'gwei' );
const maxFeePerGas = (feeData.maxFeePerGas ?? 0 n ) || ((feeData.gasPrice ?? 0 n ) + maxPriorityFeePerGas);
const totalFee = gas * maxFeePerGas; const gas = await web3.eth. estimateGas ({
from: senderAddress,
to: tokenAddress,
data: transferCalldata,
});
const block = await web3.eth. getBlock ( 'latest' );
const priorityFee = BigInt ( await web3.eth. getMaxPriorityFeePerGas ());
const baseFee = BigInt (block.baseFeePerGas);
const maxFeePerGas = (baseFee * 2 n ) + priorityFee;
const totalFee = BigInt (gas) * maxFeePerGas;
ethers.js token transfer estimate const gas = await provider. estimateGas ({
from: senderAddress,
to: tokenAddress,
data: transferCalldata,
});
const feeData = await provider. getFeeData ();
const tx = {
from: senderAddress,
to: tokenAddress,
data: transferCalldata,
gasLimit: gas,
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
};
Re-estimate gas right before sending a write transaction.
Prefer live fee data over hard-coded values.
Show the result to users in BTC, not ETH.
Re-run the estimate if calldata or recipient values change.