Skip to main content

Simulate gas and fees

Safrochain uses globalfee with a typical minimum of 0.05 usaf per gas unit. Always simulate before broadcasting high-value txs.

REST simulate

REST="https://rest.testnet.safrochain.com"
# POST /cosmos/tx/v1beta1/simulate with encoded tx bytes

CosmJS "auto" gas calls simulate under the hood.

// MsgSend with auto gas
await client.sendTokens(from, to, [{ denom: 'usaf', amount: '1000' }], 'auto');

// MsgExecuteContract with explicit fee after simulate
const fee = await client.simulate(address, [executeMsg], '');
const gasUsed = Math.ceil(Number(fee) * 1.3);
const result = await client.signAndBroadcast(address, [executeMsg], {
amount: [{ denom: 'usaf', amount: String(Math.ceil(gasUsed * 0.05)) }],
gas: String(gasUsed),
});

CLI flags (reference)

FlagRole
--gas autoSimulate and set gas limit
--gas-adjustment 1.3Safety margin on simulated gas
--gas-prices 0.05usafFee rate per gas unit

See globalfee module for chain-wide minimums.

Next